@@ -588,7 +588,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
588
588
var (
589
589
path * ibctesting.Path
590
590
packet types.Packet
591
- ack = ibcmock . MockAcknowledgement
591
+ ack [] byte
592
592
593
593
channelCap * capabilitytypes.Capability
594
594
expError * sdkerrors.Error
@@ -642,7 +642,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
642
642
643
643
channelCap = suite .chainA .GetChannelCapability (path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
644
644
645
- err = path .EndpointA .AcknowledgePacket (packet , ack . Acknowledgement () )
645
+ err = path .EndpointA .AcknowledgePacket (packet , ack )
646
646
suite .Require ().NoError (err )
647
647
}, false },
648
648
{"packet already acknowledged unordered channel (no-op)" , func () {
@@ -662,7 +662,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
662
662
663
663
channelCap = suite .chainA .GetChannelCapability (path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
664
664
665
- err = path .EndpointA .AcknowledgePacket (packet , ack . Acknowledgement () )
665
+ err = path .EndpointA .AcknowledgePacket (packet , ack )
666
666
suite .Require ().NoError (err )
667
667
}, false },
668
668
{"channel not found" , func () {
@@ -804,7 +804,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
804
804
suite .chainA .App .GetIBCKeeper ().ChannelKeeper .SetPacketCommitment (suite .chainA .GetContext (), path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID , packet .GetSequence (), types .CommitPacket (suite .chainA .App .AppCodec (), packet ))
805
805
806
806
// manually set packet acknowledgement and capability
807
- suite .chainB .App .GetIBCKeeper ().ChannelKeeper .SetPacketAcknowledgement (suite .chainB .GetContext (), path .EndpointB .ChannelConfig .PortID , path .EndpointB .ChannelID , packet .GetSequence (), types .CommitAcknowledgement (ack . Acknowledgement () ))
807
+ suite .chainB .App .GetIBCKeeper ().ChannelKeeper .SetPacketAcknowledgement (suite .chainB .GetContext (), path .EndpointB .ChannelConfig .PortID , path .EndpointB .ChannelID , packet .GetSequence (), types .CommitAcknowledgement (ack ))
808
808
809
809
suite .chainA .CreateChannelCapability (suite .chainA .GetSimApp ().ScopedIBCMockKeeper , path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
810
810
channelCap = suite .chainA .GetChannelCapability (path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
@@ -832,21 +832,74 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
832
832
suite .chainA .App .GetIBCKeeper ().ChannelKeeper .SetNextSequenceAck (suite .chainA .GetContext (), path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID , 10 )
833
833
channelCap = suite .chainA .GetChannelCapability (path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
834
834
}, false },
835
+ {
836
+ "fake acknowledgement" ,
837
+ func () {
838
+ expError = types .ErrInvalidAcknowledgement
839
+ // setup uses an UNORDERED channel
840
+ suite .coordinator .Setup (path )
841
+
842
+ // create packet commitment
843
+ sequence , err := path .EndpointA .SendPacket (defaultTimeoutHeight , disabledTimeoutTimestamp , ibctesting .MockPacketData )
844
+ suite .Require ().NoError (err )
845
+
846
+ channelCap = suite .chainA .GetChannelCapability (path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
847
+
848
+ // write packet acknowledgement directly
849
+ // Create a valid acknowledgement using deterministic serialization.
850
+ ack = types .NewResultAcknowledgement ([]byte {byte (1 )}).Acknowledgement ()
851
+ // Introduce non-determinism: insert an extra space after the first character '{'
852
+ // This will deserialize correctly but fail to re-serialize to the expected bytes.
853
+ if len (ack ) > 0 && ack [0 ] == '{' {
854
+ ack = []byte ("{ " + string (ack [1 :]))
855
+ }
856
+ path .EndpointB .Chain .Coordinator .UpdateTimeForChain (path .EndpointB .Chain )
857
+
858
+ path .EndpointB .Chain .App .GetIBCKeeper ().ChannelKeeper .SetPacketAcknowledgement (path .EndpointB .Chain .GetContext (), path .EndpointB .ChannelConfig .PortID , path .EndpointB .ChannelID , sequence , types .CommitAcknowledgement (ack ))
859
+
860
+ path .EndpointB .Chain .NextBlock ()
861
+ path .EndpointA .UpdateClient ()
862
+ },
863
+ false ,
864
+ },
865
+ {
866
+ "non-standard acknowledgement" , func () {
867
+ // setup uses an UNORDERED channel
868
+ suite .coordinator .Setup (path )
869
+
870
+ // create packet commitment
871
+ sequence , err := path .EndpointA .SendPacket (defaultTimeoutHeight , disabledTimeoutTimestamp , ibctesting .MockPacketData )
872
+ suite .Require ().NoError (err )
873
+
874
+ channelCap = suite .chainA .GetChannelCapability (path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
875
+
876
+ // write packet acknowledgement directly
877
+ ack = []byte (`{"somethingelse":"anything"}` )
878
+ path .EndpointB .Chain .Coordinator .UpdateTimeForChain (path .EndpointB .Chain )
879
+
880
+ path .EndpointB .Chain .App .GetIBCKeeper ().ChannelKeeper .SetPacketAcknowledgement (path .EndpointB .Chain .GetContext (), path .EndpointB .ChannelConfig .PortID , path .EndpointB .ChannelID , sequence , types .CommitAcknowledgement (ack ))
881
+
882
+ path .EndpointB .Chain .NextBlock ()
883
+ path .EndpointA .UpdateClient ()
884
+ },
885
+ true ,
886
+ },
835
887
}
836
888
837
889
for i , tc := range testCases {
838
890
tc := tc
839
891
suite .Run (fmt .Sprintf ("Case %s, %d/%d tests" , tc .msg , i , len (testCases )), func () {
840
892
suite .SetupTest () // reset
841
893
expError = nil // must explcitly set error for failed cases
894
+ ack = ibcmock .MockAcknowledgement .Acknowledgement ()
842
895
path = ibctesting .NewPath (suite .chainA , suite .chainB )
843
896
844
897
tc .malleate ()
845
898
846
899
packetKey := host .PacketAcknowledgementKey (packet .GetDestPort (), packet .GetDestChannel (), packet .GetSequence ())
847
900
proof , proofHeight := path .EndpointB .QueryProof (packetKey )
848
901
849
- err := suite .chainA .App .GetIBCKeeper ().ChannelKeeper .AcknowledgePacket (suite .chainA .GetContext (), channelCap , packet , ack . Acknowledgement () , proof , proofHeight )
902
+ err := suite .chainA .App .GetIBCKeeper ().ChannelKeeper .AcknowledgePacket (suite .chainA .GetContext (), channelCap , packet , ack , proof , proofHeight )
850
903
pc := suite .chainA .App .GetIBCKeeper ().ChannelKeeper .GetPacketCommitment (suite .chainA .GetContext (), packet .GetSourcePort (), packet .GetSourceChannel (), packet .GetSequence ())
851
904
852
905
channelA , _ := suite .chainA .App .GetIBCKeeper ().ChannelKeeper .GetChannel (suite .chainA .GetContext (), packet .GetSourcePort (), packet .GetSourceChannel ())
0 commit comments