From 87007ee17b9bfbfcbe26194a045066679c396170 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Wed, 22 Jan 2025 21:00:48 +0530 Subject: [PATCH 1/2] check ack if only ack not async --- tests/e2e/e2e_ibc_memo_test.go | 7 +++++++ x/uibc/uics20/ibc_module.go | 3 ++- x/uibc/uics20/memo_handler_test.go | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/e2e/e2e_ibc_memo_test.go b/tests/e2e/e2e_ibc_memo_test.go index 9f02663551..32a09c3751 100644 --- a/tests/e2e/e2e_ibc_memo_test.go +++ b/tests/e2e/e2e_ibc_memo_test.go @@ -86,4 +86,11 @@ func (s *E2ETest) testIBCTokenTransferWithMemo(umeeAPIEndpoint string, atomQuota updatedIBCAtomBalance = updatedIBCAtomBalance.Add(atomFromGaia.Amount) s.checkSupply(umeeAPIEndpoint, uatomIBCHash, updatedIBCAtomBalance) s.checkLeverageAccountBalance(umeeAPIEndpoint, accs.Alice.String(), uatomIBCHash, atomFromGaia.Amount) + + // ignore ibc forward memo msgs + invalidM := "{\"forward\":{\"channel\":\"channel-123\",\"port\":\"transfer\",\"receiver\":\"secret1xs0xv4h9d2y2fpagyt99vpm3d3f8jxh9kywh6x\",\"retries\":2,\"timeout\":1733978966221063114}}" + s.SendIBC(setup.GaiaChainID, s.Chain.ID, accs.Alice.String(), atomFromGaia, "", invalidM, "") + updatedIBCAtomBalance = updatedIBCAtomBalance.Add(atomFromGaia.Amount) + s.checkSupply(umeeAPIEndpoint, uatomIBCHash, updatedIBCAtomBalance) + s.checkLeverageAccountBalance(umeeAPIEndpoint, accs.Alice.String(), uatomIBCHash, atomFromGaia.Amount) } diff --git a/x/uibc/uics20/ibc_module.go b/x/uibc/uics20/ibc_module.go index aa54430eee..0cccae80fd 100644 --- a/x/uibc/uics20/ibc_module.go +++ b/x/uibc/uics20/ibc_module.go @@ -98,8 +98,9 @@ func (im ICS20Module) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, execCtx, execCtxFlush := transferCtx.CacheContext() // call transfer module app + // ack is nil if acknowledgement is asynchronous ack := im.IBCModule.OnRecvPacket(transferCtx, packet, relayer) - if !ack.Success() { + if ack != nil && !ack.Success() { goto end } diff --git a/x/uibc/uics20/memo_handler_test.go b/x/uibc/uics20/memo_handler_test.go index e8ddd6ca31..52d8890e45 100644 --- a/x/uibc/uics20/memo_handler_test.go +++ b/x/uibc/uics20/memo_handler_test.go @@ -142,6 +142,10 @@ func TestMsgMarshalling(t *testing.T) { bz = []byte(`{"messages": ["any message"]}`) memo2, err = deserializeMemo(cdc, bz) assert.Error(err) + + bz = []byte(`"{\"forward\":{\"channel\":\"channel-123\",\"port\":\"transfer\",\"receiver\":\"secret1xs0xv4h9d2y2fpagyt99vpm3d3f8jxh9kywh6x\",\"retries\":2,\"timeout\":1733978966221063114}}"`) + memo2, err = deserializeMemo(cdc, bz) + assert.Error(err) } func TestAdjustOperatedCoin(t *testing.T) { From abfb28a1a06eb280131ef6dc86996a97f9f8258a Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Tue, 28 Jan 2025 15:51:33 +0530 Subject: [PATCH 2/2] fix the tests --- tests/e2e/e2e_ibc_memo_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/e2e/e2e_ibc_memo_test.go b/tests/e2e/e2e_ibc_memo_test.go index 32a09c3751..8cdb115537 100644 --- a/tests/e2e/e2e_ibc_memo_test.go +++ b/tests/e2e/e2e_ibc_memo_test.go @@ -1,6 +1,8 @@ package e2e import ( + "encoding/json" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx" @@ -89,7 +91,9 @@ func (s *E2ETest) testIBCTokenTransferWithMemo(umeeAPIEndpoint string, atomQuota // ignore ibc forward memo msgs invalidM := "{\"forward\":{\"channel\":\"channel-123\",\"port\":\"transfer\",\"receiver\":\"secret1xs0xv4h9d2y2fpagyt99vpm3d3f8jxh9kywh6x\",\"retries\":2,\"timeout\":1733978966221063114}}" - s.SendIBC(setup.GaiaChainID, s.Chain.ID, accs.Alice.String(), atomFromGaia, "", invalidM, "") + bz, err = json.Marshal(invalidM) + assert.Nil(err) + s.SendIBC(setup.GaiaChainID, s.Chain.ID, accs.Alice.String(), atomFromGaia, "", string(bz), "") updatedIBCAtomBalance = updatedIBCAtomBalance.Add(atomFromGaia.Amount) s.checkSupply(umeeAPIEndpoint, uatomIBCHash, updatedIBCAtomBalance) s.checkLeverageAccountBalance(umeeAPIEndpoint, accs.Alice.String(), uatomIBCHash, atomFromGaia.Amount)