@@ -619,7 +619,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
619
619
var (
620
620
path * ibctesting.Path
621
621
packet types.Packet
622
- ack = ibcmock . MockAcknowledgement
622
+ ack [] byte
623
623
624
624
channelCap * capabilitytypes.Capability
625
625
expError * sdkerrors.Error
@@ -673,7 +673,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
673
673
674
674
channelCap = suite .chainA .GetChannelCapability (path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
675
675
676
- err = path .EndpointA .AcknowledgePacket (packet , ack . Acknowledgement () )
676
+ err = path .EndpointA .AcknowledgePacket (packet , ack )
677
677
suite .Require ().NoError (err )
678
678
}, false },
679
679
{"packet already acknowledged unordered channel (no-op)" , func () {
@@ -693,9 +693,60 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
693
693
694
694
channelCap = suite .chainA .GetChannelCapability (path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
695
695
696
- err = path .EndpointA .AcknowledgePacket (packet , ack . Acknowledgement () )
696
+ err = path .EndpointA .AcknowledgePacket (packet , ack )
697
697
suite .Require ().NoError (err )
698
698
}, false },
699
+ {
700
+ "fake acknowledgement" ,
701
+ func () {
702
+ // setup uses an UNORDERED channel
703
+ suite .coordinator .Setup (path )
704
+
705
+ // create packet commitment
706
+ sequence , err := path .EndpointA .SendPacket (defaultTimeoutHeight , disabledTimeoutTimestamp , ibctesting .MockPacketData )
707
+ suite .Require ().NoError (err )
708
+
709
+ channelCap = suite .chainA .GetChannelCapability (path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
710
+
711
+ // write packet acknowledgement directly
712
+ // Create a valid acknowledgement using deterministic serialization.
713
+ ack = types .NewResultAcknowledgement ([]byte {byte (1 )}).Acknowledgement ()
714
+ // Introduce non-determinism: insert an extra space after the first character '{'
715
+ // This will deserialize correctly but fail to re-serialize to the expected bytes.
716
+ if len (ack ) > 0 && ack [0 ] == '{' {
717
+ ack = []byte ("{ " + string (ack [1 :]))
718
+ }
719
+ path .EndpointB .Chain .Coordinator .UpdateTimeForChain (path .EndpointB .Chain )
720
+
721
+ path .EndpointB .Chain .App .GetIBCKeeper ().ChannelKeeper .SetPacketAcknowledgement (path .EndpointB .Chain .GetContext (), path .EndpointB .ChannelConfig .PortID , path .EndpointB .ChannelID , sequence , types .CommitAcknowledgement (ack ))
722
+
723
+ path .EndpointB .Chain .NextBlock ()
724
+ path .EndpointA .UpdateClient ()
725
+ },
726
+ false ,
727
+ },
728
+ {
729
+ "non-standard acknowledgement" , func () {
730
+ // setup uses an UNORDERED channel
731
+ suite .coordinator .Setup (path )
732
+
733
+ // create packet commitment
734
+ sequence , err := path .EndpointA .SendPacket (defaultTimeoutHeight , disabledTimeoutTimestamp , ibctesting .MockPacketData )
735
+ suite .Require ().NoError (err )
736
+
737
+ channelCap = suite .chainA .GetChannelCapability (path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
738
+
739
+ // write packet acknowledgement directly
740
+ ack = []byte (`{"somethingelse":"anything"}` )
741
+ path .EndpointB .Chain .Coordinator .UpdateTimeForChain (path .EndpointB .Chain )
742
+
743
+ path .EndpointB .Chain .App .GetIBCKeeper ().ChannelKeeper .SetPacketAcknowledgement (path .EndpointB .Chain .GetContext (), path .EndpointB .ChannelConfig .PortID , path .EndpointB .ChannelID , sequence , types .CommitAcknowledgement (ack ))
744
+
745
+ path .EndpointB .Chain .NextBlock ()
746
+ path .EndpointA .UpdateClient ()
747
+ },
748
+ true ,
749
+ },
699
750
{"channel not found" , func () {
700
751
expError = types .ErrChannelNotFound
701
752
@@ -835,7 +886,7 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
835
886
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 ))
836
887
837
888
// manually set packet acknowledgement and capability
838
- suite .chainB .App .GetIBCKeeper ().ChannelKeeper .SetPacketAcknowledgement (suite .chainB .GetContext (), path .EndpointB .ChannelConfig .PortID , path .EndpointB .ChannelID , packet .GetSequence (), types .CommitAcknowledgement (ack . Acknowledgement () ))
889
+ suite .chainB .App .GetIBCKeeper ().ChannelKeeper .SetPacketAcknowledgement (suite .chainB .GetContext (), path .EndpointB .ChannelConfig .PortID , path .EndpointB .ChannelID , packet .GetSequence (), types .CommitAcknowledgement (ack ))
839
890
840
891
suite .chainA .CreateChannelCapability (suite .chainA .GetSimApp ().ScopedIBCMockKeeper , path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
841
892
channelCap = suite .chainA .GetChannelCapability (path .EndpointA .ChannelConfig .PortID , path .EndpointA .ChannelID )
@@ -872,14 +923,15 @@ func (suite *KeeperTestSuite) TestAcknowledgePacket() {
872
923
suite .Run (fmt .Sprintf ("Case %s, %d/%d tests" , tc .msg , i , len (testCases )), func () {
873
924
suite .SetupTest () // reset
874
925
expError = nil // must explcitly set error for failed cases
926
+ ack = ibcmock .MockAcknowledgement .Acknowledgement ()
875
927
path = ibctesting .NewPath (suite .chainA , suite .chainB )
876
928
877
929
tc .malleate ()
878
930
879
931
packetKey := host .PacketAcknowledgementKey (packet .GetDestPort (), packet .GetDestChannel (), packet .GetSequence ())
880
932
proof , proofHeight := path .EndpointB .QueryProof (packetKey )
881
933
882
- err := suite .chainA .App .GetIBCKeeper ().ChannelKeeper .AcknowledgePacket (suite .chainA .GetContext (), channelCap , packet , ack . Acknowledgement () , proof , proofHeight )
934
+ err := suite .chainA .App .GetIBCKeeper ().ChannelKeeper .AcknowledgePacket (suite .chainA .GetContext (), channelCap , packet , ack , proof , proofHeight )
883
935
pc := suite .chainA .App .GetIBCKeeper ().ChannelKeeper .GetPacketCommitment (suite .chainA .GetContext (), packet .GetSourcePort (), packet .GetSourceChannel (), packet .GetSequence ())
884
936
885
937
channelA , _ := suite .chainA .App .GetIBCKeeper ().ChannelKeeper .GetChannel (suite .chainA .GetContext (), packet .GetSourcePort (), packet .GetSourceChannel ())
0 commit comments