diff --git a/.changeset/purple-poets-film.md b/.changeset/purple-poets-film.md new file mode 100644 index 00000000000..cc858c72f0f --- /dev/null +++ b/.changeset/purple-poets-film.md @@ -0,0 +1,5 @@ +--- +"chainlink": minor +--- + +#internal Implemented the `GetTransactionStatus` method on the EVM implementation of the `ChainWriter`. diff --git a/core/services/relay/evm/chain_writer.go b/core/services/relay/evm/chain_writer.go index d0e76526dc5..3f2d0da499a 100644 --- a/core/services/relay/evm/chain_writer.go +++ b/core/services/relay/evm/chain_writer.go @@ -167,7 +167,7 @@ func (w *chainWriter) parseContracts() error { } func (w *chainWriter) GetTransactionStatus(ctx context.Context, transactionID string) (commontypes.TransactionStatus, error) { - return commontypes.Unknown, fmt.Errorf("not implemented") + return w.txm.GetTransactionStatus(ctx, transactionID) } // GetFeeComponents the execution and data availability (L1Oracle) fees for the chain. diff --git a/core/services/relay/evm/chain_writer_test.go b/core/services/relay/evm/chain_writer_test.go index 9344279da60..66c85bfc2c3 100644 --- a/core/services/relay/evm/chain_writer_test.go +++ b/core/services/relay/evm/chain_writer_test.go @@ -5,11 +5,13 @@ import ( "math/big" "testing" + "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/smartcontractkit/chainlink-common/pkg/types" + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets" evmclimocks "github.com/smartcontractkit/chainlink/v2/core/chains/evm/client/mocks" "github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" @@ -33,7 +35,6 @@ func TestChainWriter(t *testing.T) { chainWriterConfig := newBaseChainWriterConfig() cw, err := NewChainWriterService(lggr, client, txm, ge, chainWriterConfig) - require.NoError(t, err) t.Run("Initialization", func(t *testing.T) { @@ -60,6 +61,30 @@ func TestChainWriter(t *testing.T) { // TODO: implement }) + t.Run("GetTransactionStatus", func(t *testing.T) { + txs := []struct { + txid string + status commontypes.TransactionStatus + }{ + {uuid.NewString(), commontypes.Unknown}, + {uuid.NewString(), commontypes.Unconfirmed}, + {uuid.NewString(), commontypes.Finalized}, + {uuid.NewString(), commontypes.Failed}, + {uuid.NewString(), commontypes.Fatal}, + } + + for _, tx := range txs { + txm.On("GetTransactionStatus", mock.Anything, tx.txid).Return(tx.status, nil).Once() + } + + for _, tx := range txs { + var status commontypes.TransactionStatus + status, err = cw.GetTransactionStatus(ctx, tx.txid) + require.NoError(t, err) + require.Equal(t, tx.status, status) + } + }) + t.Run("GetFeeComponents", func(t *testing.T) { ge.On("GetFee", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(gas.EvmFee{ Legacy: assets.NewWei(big.NewInt(1000000001)),