Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BCI-3381] Implement GetTransactionStatus for the EVM ChainWriter. #13691

Merged
merged 4 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading