Fix setting NextSequenceAck (#7181)
* Fix setting NextSequenceAck * Update x/ibc/04-channel/keeper/packet_test.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
This commit is contained in:
parent
a93329e98f
commit
41bc9fb8e6
|
@ -299,6 +299,8 @@ func (k Keeper) PacketExecuted(
|
|||
|
||||
nextSequenceRecv++
|
||||
|
||||
// incrementng nextSequenceRecv and storing under this chain's channelEnd identifiers
|
||||
// Since this is the receiving chain, our channelEnd is packet's destination port and channel
|
||||
k.SetNextSequenceRecv(ctx, packet.GetDestPort(), packet.GetDestChannel(), nextSequenceRecv)
|
||||
}
|
||||
|
||||
|
@ -462,7 +464,9 @@ func (k Keeper) AcknowledgementExecuted(
|
|||
|
||||
nextSequenceAck++
|
||||
|
||||
k.SetNextSequenceAck(ctx, packet.GetDestPort(), packet.GetDestChannel(), nextSequenceAck)
|
||||
// incrementng NextSequenceAck and storing under this chain's channelEnd identifiers
|
||||
// Since this is the original sending chain, our channelEnd is packet's source port and channel
|
||||
k.SetNextSequenceAck(ctx, packet.GetSourcePort(), packet.GetSourceChannel(), nextSequenceAck)
|
||||
}
|
||||
|
||||
// log that a packet has been acknowledged
|
||||
|
|
|
@ -607,6 +607,23 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() {
|
|||
|
||||
testCases := []testCase{
|
||||
{"success ORDERED", func() {
|
||||
clientA, clientB, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint)
|
||||
channelA, channelB := suite.coordinator.CreateTransferChannels(suite.chainA, suite.chainB, connA, connB, types.ORDERED)
|
||||
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp)
|
||||
|
||||
// create packet commitment
|
||||
err := suite.coordinator.SendPacket(suite.chainA, suite.chainB, packet, clientB)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
// create packet acknowledgement
|
||||
err = suite.coordinator.PacketExecuted(suite.chainB, suite.chainA, packet, clientA)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
chanCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
|
||||
|
||||
}, true},
|
||||
{"success UNORDERED", func() {
|
||||
// setup uses an UNORDERED channel
|
||||
clientA, clientB, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp)
|
||||
|
@ -644,9 +661,18 @@ func (suite *KeeperTestSuite) TestAcknowledgementExecuted() {
|
|||
err := suite.chainA.App.IBCKeeper.ChannelKeeper.AcknowledgementExecuted(suite.chainA.GetContext(), chanCap, packet)
|
||||
pc := suite.chainA.App.IBCKeeper.ChannelKeeper.GetPacketCommitment(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence())
|
||||
|
||||
channelA, _ := suite.chainA.App.IBCKeeper.ChannelKeeper.GetChannel(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel())
|
||||
sequenceAck, _ := suite.chainA.App.IBCKeeper.ChannelKeeper.GetNextSequenceAck(suite.chainA.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel())
|
||||
|
||||
if tc.expPass {
|
||||
suite.NoError(err)
|
||||
suite.Nil(pc)
|
||||
|
||||
if channelA.Ordering == types.ORDERED {
|
||||
suite.Require().Equal(packet.GetSequence()+1, sequenceAck, "sequence not incremented in ordered channel")
|
||||
} else {
|
||||
suite.Require().Equal(uint64(1), sequenceAck, "sequence incremented for UNORDERED channel")
|
||||
}
|
||||
} else {
|
||||
suite.Error(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue