From 0bb565fe4a7dd6a7f698864ca2e76107667d1905 Mon Sep 17 00:00:00 2001 From: yihuang Date: Wed, 30 Jul 2025 19:01:28 +0800 Subject: [PATCH 1/3] Problem: get receipt should not return error on tx not found --- rpc/backend/tx_info.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpc/backend/tx_info.go b/rpc/backend/tx_info.go index d6316119c..6d99034a0 100644 --- a/rpc/backend/tx_info.go +++ b/rpc/backend/tx_info.go @@ -147,7 +147,7 @@ func (b *Backend) GetTransactionReceipt(hash common.Hash) (map[string]interface{ res, err := b.GetTxByEthHash(hash) if err != nil { b.Logger.Debug("tx not found", "hash", hexTx, "error", err.Error()) - return nil, err + return nil, nil } resBlock, err := b.TendermintBlockByNumber(rpctypes.BlockNumber(res.Height)) From 2120f59cc5f1a1bd4ced40ff2cfcf523e30ee96e Mon Sep 17 00:00:00 2001 From: yihuang Date: Thu, 31 Jul 2025 14:35:27 +0800 Subject: [PATCH 2/3] fix unit test --- tests/integration/rpc/backend/test_tx_info.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/integration/rpc/backend/test_tx_info.go b/tests/integration/rpc/backend/test_tx_info.go index 432cbf2a2..f4ff10d39 100644 --- a/tests/integration/rpc/backend/test_tx_info.go +++ b/tests/integration/rpc/backend/test_tx_info.go @@ -567,7 +567,7 @@ func (s *TestSuite) TestGetTransactionReceipt() { }{ // TODO test happy path { - name: "fail - tx not found", + name: "success - tx not found", registerMock: func() {}, block: &types.Block{Header: types.Header{Height: 1}, Data: types.Data{Txs: []types.Tx{txBz}}}, tx: msgEthereumTx2, @@ -586,8 +586,7 @@ func (s *TestSuite) TestGetTransactionReceipt() { }, }, }, - expPass: false, - expErr: fmt.Errorf("tx not found, hash: %s", txHash.Hex()), + expPass: true, }, { name: "fail - block not found", From d2b78b1964b24a993518bcb3e6fd8b710587addc Mon Sep 17 00:00:00 2001 From: yihuang Date: Thu, 7 Aug 2025 16:33:23 +0800 Subject: [PATCH 3/3] fix test --- tests/integration/rpc/backend/test_tx_info.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/integration/rpc/backend/test_tx_info.go b/tests/integration/rpc/backend/test_tx_info.go index f4ff10d39..c9dfb8344 100644 --- a/tests/integration/rpc/backend/test_tx_info.go +++ b/tests/integration/rpc/backend/test_tx_info.go @@ -586,7 +586,8 @@ func (s *TestSuite) TestGetTransactionReceipt() { }, }, }, - expPass: true, + expPass: false, + expErr: nil, }, { name: "fail - block not found", @@ -699,8 +700,11 @@ func (s *TestSuite) TestGetTransactionReceipt() { s.Require().Nil(res["contractAddress"]) // no contract creation s.Require().NoError(err) } else { - s.Require().Error(err) - s.Require().ErrorContains(err, tc.expErr.Error()) + if tc.expErr == nil { + s.Require().Nil(err) + } else { + s.Require().ErrorContains(err, tc.expErr.Error()) + } } }) }