diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index 137e7f58aef..b787a7f0bad 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -183,17 +183,11 @@ func (suite *KeeperTestSuite) TestHandleRecvPacket() { _, err := suite.chainB.App.GetIBCKeeper().RecvPacket(suite.chainB.GetContext(), msg) suite.Require().NoError(err) - // check that callback state was handled correctly - _, exists := suite.chainB.GetSimApp().ScopedIBCMockKeeper.GetCapability(suite.chainB.GetContext(), ibcmock.GetMockRecvCanaryCapabilityName(packet)) if tc.expRevert { - suite.Require().False(exists, "capability exists in store even after callback reverted") - // context events should contain error events suite.Require().Contains(events, keeper.ConvertToErrorEvents(sdk.Events{ibcmock.NewMockRecvPacketEvent()})[0]) suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) } else { - suite.Require().True(exists, "callback state not persisted when revert is false") - if tc.replay { // context should not contain application events suite.Require().NotContains(events, ibcmock.NewMockRecvPacketEvent()) diff --git a/testing/mock/ibc_module.go b/testing/mock/ibc_module.go index 8542dc43ffe..5f37f5150e8 100644 --- a/testing/mock/ibc_module.go +++ b/testing/mock/ibc_module.go @@ -3,9 +3,7 @@ package mock import ( "bytes" "context" - "fmt" "reflect" - "strconv" "strings" sdk "github.com/cosmos/cosmos-sdk/types" @@ -113,14 +111,6 @@ func (im IBCModule) OnRecvPacket(ctx context.Context, channelVersion string, pac return im.IBCApp.OnRecvPacket(ctx, channelVersion, packet, relayer) } - // set state by claiming capability to check if revert happens return - capName := GetMockRecvCanaryCapabilityName(packet) - if _, err := im.IBCApp.ScopedKeeper.NewCapability(ctx, capName); err != nil { - // application callback called twice on same packet sequence - // must never occur - panic(err) - } - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 sdkCtx.EventManager().EmitEvent(NewMockRecvPacketEvent()) @@ -139,13 +129,6 @@ func (im IBCModule) OnAcknowledgementPacket(ctx context.Context, channelVersion return im.IBCApp.OnAcknowledgementPacket(ctx, channelVersion, packet, acknowledgement, relayer) } - capName := GetMockAckCanaryCapabilityName(packet) - if _, err := im.IBCApp.ScopedKeeper.NewCapability(ctx, capName); err != nil { - // application callback called twice on same packet sequence - // must never occur - panic(err) - } - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 sdkCtx.EventManager().EmitEvent(NewMockAckPacketEvent()) @@ -158,13 +141,6 @@ func (im IBCModule) OnTimeoutPacket(ctx context.Context, channelVersion string, return im.IBCApp.OnTimeoutPacket(ctx, channelVersion, packet, relayer) } - capName := GetMockTimeoutCanaryCapabilityName(packet) - if _, err := im.IBCApp.ScopedKeeper.NewCapability(ctx, capName); err != nil { - // application callback called twice on same packet sequence - // must never occur - panic(err) - } - sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/7223 sdkCtx.EventManager().EmitEvent(NewMockTimeoutPacketEvent()) @@ -213,18 +189,3 @@ func (IBCModule) UnmarshalPacketData(ctx context.Context, portID string, channel } return nil, "", MockApplicationCallbackError } - -// GetMockRecvCanaryCapabilityName generates a capability name for testing OnRecvPacket functionality. -func GetMockRecvCanaryCapabilityName(packet channeltypes.Packet) string { - return fmt.Sprintf("%s%s%s%s", MockRecvCanaryCapabilityName, packet.GetDestPort(), packet.GetDestChannel(), strconv.Itoa(int(packet.GetSequence()))) -} - -// GetMockAckCanaryCapabilityName generates a capability name for OnAcknowledgementPacket functionality. -func GetMockAckCanaryCapabilityName(packet channeltypes.Packet) string { - return fmt.Sprintf("%s%s%s%s", MockAckCanaryCapabilityName, packet.GetSourcePort(), packet.GetSourceChannel(), strconv.Itoa(int(packet.GetSequence()))) -} - -// GetMockTimeoutCanaryCapabilityName generates a capability name for OnTimeoutacket functionality. -func GetMockTimeoutCanaryCapabilityName(packet channeltypes.Packet) string { - return fmt.Sprintf("%s%s%s%s", MockTimeoutCanaryCapabilityName, packet.GetSourcePort(), packet.GetSourceChannel(), strconv.Itoa(int(packet.GetSequence()))) -} diff --git a/testing/mock/ibc_module_test.go b/testing/mock/ibc_module_test.go deleted file mode 100644 index dd6d09a73b9..00000000000 --- a/testing/mock/ibc_module_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package mock_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" - "github.com/cosmos/ibc-go/v9/testing/mock" -) - -func TestCreateCapabilityName(t *testing.T) { - packet := channeltypes.NewPacket( - []byte{}, - 1, - mock.PortID, - "channel-0", - mock.PortID, - "channel-0", - clienttypes.NewHeight(0, 100), - 0, - ) - - name := mock.GetMockRecvCanaryCapabilityName(packet) - require.Equal(t, "mock receive canary capability namemockchannel-01", name) - - name = mock.GetMockAckCanaryCapabilityName(packet) - require.Equal(t, "mock acknowledgement canary capability namemockchannel-01", name) - - name = mock.GetMockTimeoutCanaryCapabilityName(packet) - require.Equal(t, "mock timeout canary capability namemockchannel-01", name) -} diff --git a/testing/mock/middleware.go b/testing/mock/middleware.go index c0295d8fb8b..7a07de0e13b 100644 --- a/testing/mock/middleware.go +++ b/testing/mock/middleware.go @@ -104,14 +104,6 @@ func (im BlockUpgradeMiddleware) OnRecvPacket(ctx context.Context, channelVersio return im.IBCApp.OnRecvPacket(ctx, channelVersion, packet, relayer) } - // set state by claiming capability to check if revert happens return - capName := GetMockRecvCanaryCapabilityName(packet) - if _, err := im.IBCApp.ScopedKeeper.NewCapability(ctx, capName); err != nil { - // application callback called twice on same packet sequence - // must never occur - panic(err) - } - if bytes.Equal(MockPacketData, packet.GetData()) { return MockAcknowledgement } else if bytes.Equal(MockAsyncPacketData, packet.GetData()) { @@ -127,13 +119,6 @@ func (im BlockUpgradeMiddleware) OnAcknowledgementPacket(ctx context.Context, ch return im.IBCApp.OnAcknowledgementPacket(ctx, channelVersion, packet, acknowledgement, relayer) } - capName := GetMockAckCanaryCapabilityName(packet) - if _, err := im.IBCApp.ScopedKeeper.NewCapability(ctx, capName); err != nil { - // application callback called twice on same packet sequence - // must never occur - panic(err) - } - return nil } @@ -143,13 +128,6 @@ func (im BlockUpgradeMiddleware) OnTimeoutPacket(ctx context.Context, channelVer return im.IBCApp.OnTimeoutPacket(ctx, channelVersion, packet, relayer) } - capName := GetMockTimeoutCanaryCapabilityName(packet) - if _, err := im.IBCApp.ScopedKeeper.NewCapability(ctx, capName); err != nil { - // application callback called twice on same packet sequence - // must never occur - panic(err) - } - return nil }