diff --git a/modules/apps/callbacks/ibc_middleware.go b/modules/apps/callbacks/ibc_middleware.go index fb89b03b7d6..be61c50d751 100644 --- a/modules/apps/callbacks/ibc_middleware.go +++ b/modules/apps/callbacks/ibc_middleware.go @@ -107,7 +107,7 @@ func (im IBCMiddleware) SendPacket( return 0, err } - types.EmitCallbackEvent(ctx, sourceChannel, sourcePort, seq, types.CallbackTypeSendPacket, callbackData, nil) + types.EmitCallbackEvent(ctx, sourcePort, sourceChannel, seq, types.CallbackTypeSendPacket, callbackData, nil) return seq, nil } @@ -144,7 +144,7 @@ func (im IBCMiddleware) OnAcknowledgementPacket( // callback execution errors are not allowed to block the packet lifecycle, they are only used in event emissions err = im.processCallback(ctx, types.CallbackTypeAcknowledgementPacket, callbackData, callbackExecutor) types.EmitCallbackEvent( - ctx, packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence(), + ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence(), types.CallbackTypeAcknowledgementPacket, callbackData, err, ) @@ -176,7 +176,7 @@ func (im IBCMiddleware) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Pac // callback execution errors are not allowed to block the packet lifecycle, they are only used in event emissions err = im.processCallback(ctx, types.CallbackTypeTimeoutPacket, callbackData, callbackExecutor) types.EmitCallbackEvent( - ctx, packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence(), + ctx, packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence(), types.CallbackTypeTimeoutPacket, callbackData, err, ) @@ -212,7 +212,7 @@ func (im IBCMiddleware) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet // callback execution errors are not allowed to block the packet lifecycle, they are only used in event emissions err = im.processCallback(ctx, types.CallbackTypeReceivePacket, callbackData, callbackExecutor) types.EmitCallbackEvent( - ctx, packet.GetDestChannel(), packet.GetDestPort(), packet.GetSequence(), + ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), types.CallbackTypeReceivePacket, callbackData, err, ) @@ -250,7 +250,7 @@ func (im IBCMiddleware) WriteAcknowledgement( // callback execution errors are not allowed to block the packet lifecycle, they are only used in event emissions err = im.processCallback(ctx, types.CallbackTypeReceivePacket, callbackData, callbackExecutor) types.EmitCallbackEvent( - ctx, packet.GetDestChannel(), packet.GetDestPort(), packet.GetSequence(), + ctx, packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence(), types.CallbackTypeReceivePacket, callbackData, err, ) diff --git a/modules/apps/callbacks/types/events_test.go b/modules/apps/callbacks/types/events_test.go index edcbb00ab5f..ffc99b94454 100644 --- a/modules/apps/callbacks/types/events_test.go +++ b/modules/apps/callbacks/types/events_test.go @@ -184,21 +184,24 @@ func (s *CallbacksTypesTestSuite) TestEvents() { } for _, tc := range testCases { - newCtx := sdk.Context{}.WithEventManager(sdk.NewEventManager()) + tc := tc + s.Run(tc.name, func() { + newCtx := sdk.Context{}.WithEventManager(sdk.NewEventManager()) - switch tc.callbackType { - case types.CallbackTypeReceivePacket: - types.EmitCallbackEvent( - newCtx, tc.packet.GetDestChannel(), tc.packet.GetDestPort(), - tc.packet.GetSequence(), tc.callbackType, tc.callbackData, tc.callbackError, - ) - default: - types.EmitCallbackEvent( - newCtx, tc.packet.GetSourceChannel(), tc.packet.GetSourcePort(), - tc.packet.GetSequence(), tc.callbackType, tc.callbackData, tc.callbackError, - ) - } - events := newCtx.EventManager().Events().ToABCIEvents() - ibctesting.AssertEvents(&s.Suite, tc.expEvents, events) + switch tc.callbackType { + case types.CallbackTypeReceivePacket: + types.EmitCallbackEvent( + newCtx, tc.packet.GetDestPort(), tc.packet.GetDestChannel(), + tc.packet.GetSequence(), tc.callbackType, tc.callbackData, tc.callbackError, + ) + default: + types.EmitCallbackEvent( + newCtx, tc.packet.GetSourcePort(), tc.packet.GetSourceChannel(), + tc.packet.GetSequence(), tc.callbackType, tc.callbackData, tc.callbackError, + ) + } + events := newCtx.EventManager().Events().ToABCIEvents() + ibctesting.AssertEvents(&s.Suite, tc.expEvents, events) + }) } }