@@ -756,7 +756,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
756
756
err = path .EndpointA .ChanUpgradeAck ()
757
757
suite .Require ().NoError (err )
758
758
759
- // TODO: Manually set until #3928 is implemented.
759
+ // TODO: Manually set until #3929 is implemented.
760
760
channel := path .EndpointA .GetChannel ()
761
761
channel .FlushStatus = types .FLUSHCOMPLETE
762
762
path .EndpointA .SetChannel (channel )
@@ -956,43 +956,70 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
956
956
// TestAcknowledgeFlush tests that Acknowledging the last in-flight packet moves the channel
957
957
// state to FLUSHINGCOMPLETE.
958
958
func (suite * KeeperTestSuite ) TestAcknowledgeFlushStatus () {
959
- var channelCap * capabilitytypes. Capability
959
+ var path * ibctesting. Path
960
960
961
- suite .SetupTest () // reset
962
- path := ibctesting .NewPath (suite .chainA , suite .chainB )
961
+ testCases := []struct {
962
+ msg string
963
+ malleate func ()
964
+ expectedFlushStatus types.FlushStatus
965
+ }{
966
+ {
967
+ "success: final packet commitment cleared, flush status set to FLUSHCOMPLETE" ,
968
+ func () {},
969
+ types .FLUSHCOMPLETE ,
970
+ },
971
+ {
972
+ "success: has in-flight packets, flush status remains FLUSHING" ,
973
+ func () {
974
+ // Send an additional packet
975
+ sequence , err := path .EndpointA .SendPacket (defaultTimeoutHeight , disabledTimeoutTimestamp , ibctesting .MockPacketData )
976
+ suite .Require ().Equal (uint64 (1 ), sequence )
977
+ suite .Require ().NoError (err )
978
+ },
979
+ types .FLUSHING ,
980
+ },
981
+ }
963
982
964
- // setup uses an UNORDERED channel
965
- suite .coordinator .Setup (path )
983
+ for i , tc := range testCases {
984
+ tc := tc
985
+ suite .Run (fmt .Sprintf ("Case %s, %d/%d tests" , tc .msg , i , len (testCases )), func () {
986
+ suite .SetupTest () // reset
987
+ path = ibctesting .NewPath (suite .chainA , suite .chainB )
988
+ suite .coordinator .Setup (path )
966
989
967
- // create packet commitment
968
- sequence , err := path .EndpointA .SendPacket (defaultTimeoutHeight , disabledTimeoutTimestamp , ibctesting .MockPacketData )
969
- suite .Require ().NoError (err )
990
+ tc .malleate ()
970
991
971
- // create packet receipt and acknowledgement
972
- packet := types .NewPacket (ibctesting .MockPacketData , sequence , path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID , path .EndpointB .ChannelConfig .PortID , path .EndpointB .ChannelID , defaultTimeoutHeight , disabledTimeoutTimestamp )
973
- err = path .EndpointB .RecvPacket (packet )
974
- suite .Require ().NoError (err )
992
+ // create packet commitment
993
+ sequence , err := path .EndpointA .SendPacket (defaultTimeoutHeight , disabledTimeoutTimestamp , ibctesting .MockPacketData )
994
+ suite .Require ().NoError (err )
995
+
996
+ // create packet receipt and acknowledgement
997
+ packet := types .NewPacket (ibctesting .MockPacketData , sequence , path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID , path .EndpointB .ChannelConfig .PortID , path .EndpointB .ChannelID , defaultTimeoutHeight , disabledTimeoutTimestamp )
998
+ err = path .EndpointB .RecvPacket (packet )
999
+ suite .Require ().NoError (err )
975
1000
976
- // Move channel to UPGRADE_ACK, flush status set to flushing due to previous SendPacket
977
- path .EndpointA .ChannelConfig .ProposedUpgrade .Fields .Version = ibcmock .UpgradeVersion
1001
+ // Move channel to UPGRADE_ACK, flush status set to flushing due to previous SendPacket
1002
+ path .EndpointA .ChannelConfig .ProposedUpgrade .Fields .Version = ibcmock .UpgradeVersion
978
1003
979
- err = path .EndpointA .ChanUpgradeInit ()
980
- suite .Require ().NoError (err )
1004
+ err = path .EndpointA .ChanUpgradeInit ()
1005
+ suite .Require ().NoError (err )
981
1006
982
- err = path .EndpointB .ChanUpgradeTry ()
983
- suite .Require ().NoError (err )
1007
+ err = path .EndpointB .ChanUpgradeTry ()
1008
+ suite .Require ().NoError (err )
984
1009
985
- err = path .EndpointA .ChanUpgradeAck ()
986
- suite .Require ().NoError (err )
1010
+ err = path .EndpointA .ChanUpgradeAck ()
1011
+ suite .Require ().NoError (err )
987
1012
988
- packetKey := host .PacketAcknowledgementKey (packet .GetDestPort (), packet .GetDestChannel (), packet .GetSequence ())
989
- proof , proofHeight := path .EndpointB .QueryProof (packetKey )
1013
+ packetKey := host .PacketAcknowledgementKey (packet .GetDestPort (), packet .GetDestChannel (), packet .GetSequence ())
1014
+ proof , proofHeight := path .EndpointB .QueryProof (packetKey )
990
1015
991
- channelCap = suite .chainA .GetChannelCapability (path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
992
- err = suite .chainA .App .GetIBCKeeper ().ChannelKeeper .AcknowledgePacket (suite .chainA .GetContext (), channelCap , packet , ibcmock .MockAcknowledgement .Acknowledgement (), proof , proofHeight )
993
- suite .Require ().NoError (err )
1016
+ channelCap : = suite .chainA .GetChannelCapability (path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
1017
+ err = suite .chainA .App .GetIBCKeeper ().ChannelKeeper .AcknowledgePacket (suite .chainA .GetContext (), channelCap , packet , ibcmock .MockAcknowledgement .Acknowledgement (), proof , proofHeight )
1018
+ suite .Require ().NoError (err )
994
1019
995
- // Check that we've moved to FLUSHCOMPLETE
996
- channelA := path .EndpointA .GetChannel ()
997
- suite .Require ().Equal (types .FLUSHCOMPLETE , channelA .FlushStatus )
1020
+ // Check that we've moved to FLUSHCOMPLETE
1021
+ channelA := path .EndpointA .GetChannel ()
1022
+ suite .Require ().Equal (tc .expectedFlushStatus , channelA .FlushStatus )
1023
+ })
1024
+ }
998
1025
}
0 commit comments