Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
bznein committed Oct 15, 2024
1 parent 72a4725 commit 87b3d87
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions modules/core/04-channel/v2/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,18 +355,18 @@ func (suite *KeeperTestSuite) TestMsgAcknowledgement() {
// Modify the callback to return an error.
// This way, we can verify that the callback is not executed in a No-op case.
path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.PacketData, []byte, sdk.AccAddress) error {
return errors.New("OnAcknowledgementPacket callback failed")
return mock.MockApplicationCallbackError
}
},
},
{
name: "failure: callback fails",
malleate: func() {
path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnAcknowledgementPacket = func(context.Context, string, string, channeltypesv2.PacketData, []byte, sdk.AccAddress) error {
return errors.New("OnAcknowledgementPacket callback failed")
return mock.MockApplicationCallbackError
}
},
expError: errors.New("OnAcknowledgementPacket callback failed"),
expError: mock.MockApplicationCallbackError,
},
{
name: "failure: counterparty not found",
Expand Down Expand Up @@ -455,12 +455,12 @@ func (suite *KeeperTestSuite) TestMsgTimeout() {
{
name: "failure: no-op",
malleate: func() {
suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeletePacketCommitment(suite.chainA.GetContext(), packet.DestinationChannel, packet.Sequence)
suite.chainA.App.GetIBCKeeper().ChannelKeeperV2.DeletePacketCommitment(suite.chainA.GetContext(), packet.SourceChannel, packet.Sequence)

// Modify the callback to return a different error.
// This way, we can verify that the callback is not executed in a No-op case.
path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, channeltypesv2.PacketData, sdk.AccAddress) error {
return errors.New("OnTimeoutPacket callback failed")
return mock.MockApplicationCallbackError
}
},
expError: channeltypesv1.ErrNoOpMsg,
Expand All @@ -476,10 +476,10 @@ func (suite *KeeperTestSuite) TestMsgTimeout() {
name: "failure: callback fails",
malleate: func() {
path.EndpointA.Chain.GetSimApp().MockModuleV2A.IBCApp.OnTimeoutPacket = func(context.Context, string, string, channeltypesv2.PacketData, sdk.AccAddress) error {
return errors.New("OnTimeoutPacket callback failed")
return mock.MockApplicationCallbackError
}
},
expError: errors.New("OnTimeoutPacket callback failed"),
expError: mock.MockApplicationCallbackError,
},
{
name: "failure: channel not found",
Expand Down Expand Up @@ -513,26 +513,26 @@ func (suite *KeeperTestSuite) TestMsgTimeout() {

// Send packet from A to B
timeoutTimestamp := suite.chainA.GetTimeoutTimestamp()

mockData := mockv2.NewMockPacketData(mockv2.ModuleNameA, mockv2.ModuleNameB)
msgSendPacket := channeltypesv2.NewMsgSendPacket(path.EndpointA.ChannelID, timeoutTimestamp, suite.chainA.SenderAccount.GetAddress().String(), mockData)
res, err := path.EndpointA.Chain.SendMsgs(msgSendPacket)
packet, err := path.EndpointA.MsgSendPacket(timeoutTimestamp, mockData)
// msgSendPacket := channeltypesv2.NewMsgSendPacket(path.EndpointA.ChannelID, timeoutTimestamp, suite.chainA.SenderAccount.GetAddress().String(), mockData)
// res, err := path.EndpointA.Chain.SendMsgs(msgSendPacket)
suite.Require().NoError(err)
suite.Require().NotNil(res)
suite.Require().NoError(path.EndpointB.UpdateClient())
suite.Require().NotNil(packet)
// suite.Require().NoError(path.EndpointB.UpdateClient())

suite.coordinator.IncrementTimeBy(time.Hour * 20)
suite.Require().NoError(path.EndpointA.UpdateClient())

packet = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, mockData)
// packet = channeltypesv2.NewPacket(1, path.EndpointA.ChannelID, path.EndpointB.ChannelID, timeoutTimestamp, mockData)

packetKey := hostv2.PacketReceiptKey(packet.DestinationChannel, packet.Sequence)
proof, proofHeight := path.EndpointB.QueryProof(packetKey)
msgTimeout = channeltypesv2.NewMsgTimeout(packet, proof, proofHeight, 1, suite.chainA.SenderAccount.GetAddress().String())

tc.malleate()

res, err = suite.chainA.SendMsgs(msgTimeout)
res, err := suite.chainA.SendMsgs(msgTimeout)

expPass := tc.expError == nil
if expPass {
Expand Down

0 comments on commit 87b3d87

Please sign in to comment.