Skip to content

Commit

Permalink
testing: Adding MockEmptyAcknowledgement to testing library
Browse files Browse the repository at this point in the history
  • Loading branch information
seantking committed Feb 8, 2022
1 parent 37ba44f commit 8d5c66d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/core/04-channel/keeper/packet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 23 additions & 0 deletions testing/mock/ack.go
Original file line number Diff line number Diff line change
@@ -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{}
}

0 comments on commit 8d5c66d

Please sign in to comment.