Skip to content

Commit

Permalink
move nextSeqSend to a better place
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaSripal committed Jan 16, 2025
1 parent a5aa5ff commit adcb847
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions modules/core/04-channel/v2/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ func (k *Keeper) sendPacket(

sequence, found := k.GetNextSequenceSend(ctx, sourceClient)
if !found {
// initialize sequnce to 1 if it does not exist
sequence = 1
return 0, "", errorsmod.Wrapf(types.ErrSequenceSendNotFound, "source client: %s", sourceClient)
}

// construct packet from given fields and channel state
Expand Down
3 changes: 3 additions & 0 deletions modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func (k *Keeper) RegisterCounterparty(ctx context.Context, msg *clienttypes.MsgR
}
k.ClientKeeper.SetClientCounterparty(ctx, msg.ClientId, counterpartyInfo)

// initialize next sequence send to enable packet flow
k.ChannelKeeperV2.SetNextSequenceSend(ctx, msg.ClientId, 1)

k.ClientKeeper.DeleteClientCreator(ctx, msg.ClientId)
return &clienttypes.MsgRegisterCounterpartyResponse{}, nil
}
Expand Down
3 changes: 3 additions & 0 deletions modules/core/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func (suite *KeeperTestSuite) TestRegisterCounterparty() {
counterpartyInfo, ok := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientCounterparty(suite.chainA.GetContext(), path.EndpointA.ClientID)
suite.Require().True(ok)
suite.Require().Equal(counterpartyInfo, clienttypes.NewCounterpartyInfo(merklePrefix, path.EndpointB.ClientID))
nextSeqSend, ok := suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.GetNextSequenceSend(suite.chainA.GetContext(), path.EndpointA.ClientID)
suite.Require().True(ok)
suite.Require().Equal(nextSeqSend, uint64(1))
creator := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetClientCreator(suite.chainA.GetContext(), path.EndpointA.ClientID)
suite.Require().Empty(creator)
}
Expand Down

0 comments on commit adcb847

Please sign in to comment.