From eacfd870d5429b3c72d20c7467770d679f126176 Mon Sep 17 00:00:00 2001 From: Philip Offtermatt Date: Thu, 30 Nov 2023 09:49:26 +0100 Subject: [PATCH] Fix acct sequences not incrementing when messages error ot --- testutil/simibc/relay_util.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/testutil/simibc/relay_util.go b/testutil/simibc/relay_util.go index f6be32cd60..e113c02fef 100644 --- a/testutil/simibc/relay_util.go +++ b/testutil/simibc/relay_util.go @@ -49,14 +49,13 @@ func UpdateReceiverClient(sender, receiver *ibctesting.Endpoint, header *ibctmty true, !expectExpiration, receiver.Chain.SenderPrivKey, ) + setSequenceErr := receiver.Chain.SenderAccount.SetSequence(receiver.Chain.SenderAccount.GetSequence() + 1) if err != nil { return err } - err = receiver.Chain.SenderAccount.SetSequence(receiver.Chain.SenderAccount.GetSequence() + 1) - - if err != nil { - return err + if setSequenceErr != nil { + return setSequenceErr } return nil @@ -85,14 +84,14 @@ func TryRecvPacket(sender, receiver *ibctesting.Endpoint, packet channeltypes.Pa []uint64{receiver.Chain.SenderAccount.GetSequence()}, true, !expectError, receiver.Chain.SenderPrivKey, ) + // need to set the sequence even if there was an error in delivery + setSequenceErr := receiver.Chain.SenderAccount.SetSequence(receiver.Chain.SenderAccount.GetSequence() + 1) if err != nil { return nil, err } - err = receiver.Chain.SenderAccount.SetSequence(receiver.Chain.SenderAccount.GetSequence() + 1) - - if err != nil { - return nil, err + if setSequenceErr != nil { + return nil, setSequenceErr } ack, err = ibctesting.ParseAckFromEvents(resWithAck.GetEvents()) @@ -129,14 +128,13 @@ func TryRecvAck(sender, receiver *ibctesting.Endpoint, packet channeltypes.Packe true, true, receiver.Chain.SenderPrivKey, ) + setSequenceErr := receiver.Chain.SenderAccount.SetSequence(receiver.Chain.SenderAccount.GetSequence() + 1) if err != nil { return err } - err = receiver.Chain.SenderAccount.SetSequence(receiver.Chain.SenderAccount.GetSequence() + 1) - - if err != nil { - return err + if setSequenceErr != nil { + return setSequenceErr } return nil