From 8d5c66da501a0162f2f66749ae2d77afa1ef88fe Mon Sep 17 00:00:00 2001 From: Sean King Date: Tue, 8 Feb 2022 18:14:49 +0100 Subject: [PATCH] testing: Adding MockEmptyAcknowledgement to testing library --- modules/core/04-channel/keeper/packet_test.go | 2 +- testing/mock/ack.go | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 testing/mock/ack.go diff --git a/modules/core/04-channel/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index 7f17144be0a..3746bd2352b 100644 --- a/modules/core/04-channel/keeper/packet_test.go +++ b/modules/core/04-channel/keeper/packet_test.go @@ -551,7 +551,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgement() { func() { suite.coordinator.Setup(path) packet = types.NewPacket(ibctesting.MockPacketData, 1, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, timeoutHeight, disabledTimeoutTimestamp) - ack = types.NewResultAcknowledgement(nil) + ack = ibcmock.NewMockEmptyAcknowledgement() channelCap = suite.chainB.GetChannelCapability(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) }, false, diff --git a/testing/mock/ack.go b/testing/mock/ack.go new file mode 100644 index 00000000000..c25176a02da --- /dev/null +++ b/testing/mock/ack.go @@ -0,0 +1,23 @@ +package mock + +// MockEmptyAcknowledgement implements the exported.Acknowledgement interface and always returns an empty byte string as Response +type MockEmptyAcknowledgement struct { + Response []byte +} + +// NewMockEmptyAcknowledgement returns a new instance of MockEmptyAcknowledgement +func NewMockEmptyAcknowledgement() MockEmptyAcknowledgement { + return MockEmptyAcknowledgement{ + Response: []byte{}, + } +} + +// Success implements the Acknowledgement interface +func (ack MockEmptyAcknowledgement) Success() bool { + return true +} + +// Acknowledgement implements the Acknowledgement interface +func (ack MockEmptyAcknowledgement) Acknowledgement() []byte { + return []byte{} +}