Skip to content

Commit

Permalink
[BCI-3381] Implement GetTransactionStatus for the EVM ChainWriter. (
Browse files Browse the repository at this point in the history
#13691)

* evm: Implement get transaction status

* evm: Implement get transaction status

* evm: Fix linting issues
  • Loading branch information
nickcorin authored Jun 26, 2024
1 parent ec3eac5 commit f2630b2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/purple-poets-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#internal Implemented the `GetTransactionStatus` method on the EVM implementation of the `ChainWriter`.
2 changes: 1 addition & 1 deletion core/services/relay/evm/chain_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
27 changes: 26 additions & 1 deletion core/services/relay/evm/chain_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand All @@ -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)),
Expand Down

0 comments on commit f2630b2

Please sign in to comment.