From a2514d725f66e2c4a66d9bd0dd211a617fa32367 Mon Sep 17 00:00:00 2001 From: Bartek Tofel Date: Thu, 12 Sep 2024 07:11:18 +0200 Subject: [PATCH] [TT-1546] change the parameter of chains' Confirm() function (#14388) * pass *types.Transaction instead of common.Hash to chain's Confirm() function * fix lints --- .../ccip/changeset/2_initial_deploy_test.go | 6 +++--- integration-tests/deployment/ccip/deploy.go | 2 +- .../deployment/ccip/deploy_home_chain.go | 2 +- integration-tests/deployment/environment.go | 4 ++-- .../deployment/memory/environment.go | 15 ++++++++++----- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/integration-tests/deployment/ccip/changeset/2_initial_deploy_test.go b/integration-tests/deployment/ccip/changeset/2_initial_deploy_test.go index 1100978bc8a..8098ebaef21 100644 --- a/integration-tests/deployment/ccip/changeset/2_initial_deploy_test.go +++ b/integration-tests/deployment/ccip/changeset/2_initial_deploy_test.go @@ -101,21 +101,21 @@ func Test0002_InitialDeploy(t *testing.T) { Value: fee, }) require.NoError(t, err) - _, err = srcChain.Confirm(tx.Hash()) + _, err = srcChain.Confirm(tx) require.NoError(t, err) // TODO: should be able to avoid this by using native? tx, err = state.Chains[src].Weth9.Approve(e.Chains[src].DeployerKey, state.Chains[src].Router.Address(), fee) require.NoError(t, err) - _, err = srcChain.Confirm(tx.Hash()) + _, err = srcChain.Confirm(tx) require.NoError(t, err) t.Logf("Sending CCIP request from chain selector %d to chain selector %d", src, dest) tx, err = state.Chains[src].Router.CcipSend(e.Chains[src].DeployerKey, dest, msg) require.NoError(t, err) - _, err = srcChain.Confirm(tx.Hash()) + _, err = srcChain.Confirm(tx) require.NoError(t, err) } } diff --git a/integration-tests/deployment/ccip/deploy.go b/integration-tests/deployment/ccip/deploy.go index 01368c14a40..eb2ddae2933 100644 --- a/integration-tests/deployment/ccip/deploy.go +++ b/integration-tests/deployment/ccip/deploy.go @@ -87,7 +87,7 @@ func deployContract[C Contracts]( lggr.Errorw("Failed to deploy contract", "err", contractDeploy.Err) return nil, contractDeploy.Err } - _, err := chain.Confirm(contractDeploy.Tx.Hash()) + _, err := chain.Confirm(contractDeploy.Tx) if err != nil { lggr.Errorw("Failed to confirm deployment", "err", err) return nil, err diff --git a/integration-tests/deployment/ccip/deploy_home_chain.go b/integration-tests/deployment/ccip/deploy_home_chain.go index 33e9c14f8b0..1fe6bd5d562 100644 --- a/integration-tests/deployment/ccip/deploy_home_chain.go +++ b/integration-tests/deployment/ccip/deploy_home_chain.go @@ -143,7 +143,7 @@ func AddNodes( if err != nil { return err } - _, err = chain.Confirm(tx.Hash()) + _, err = chain.Confirm(tx) return err } diff --git a/integration-tests/deployment/environment.go b/integration-tests/deployment/environment.go index 2e28bff5ab4..5dfa1cd24e4 100644 --- a/integration-tests/deployment/environment.go +++ b/integration-tests/deployment/environment.go @@ -43,7 +43,7 @@ type Chain struct { Client OnchainClient // Note the Sign function can be abstract supporting a variety of key storage mechanisms (e.g. KMS etc). DeployerKey *bind.TransactOpts - Confirm func(tx common.Hash) (uint64, error) + Confirm func(tx *types.Transaction) (uint64, error) } type Environment struct { @@ -72,7 +72,7 @@ func ConfirmIfNoError(chain Chain, tx *types.Transaction, err error) (uint64, er } return 0, err } - return chain.Confirm(tx.Hash()) + return chain.Confirm(tx) } func MaybeDataErr(err error) error { diff --git a/integration-tests/deployment/memory/environment.go b/integration-tests/deployment/memory/environment.go index fcccdca373d..30606f2e9e7 100644 --- a/integration-tests/deployment/memory/environment.go +++ b/integration-tests/deployment/memory/environment.go @@ -2,15 +2,17 @@ package memory import ( "context" + "fmt" "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" - "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" "github.com/hashicorp/consul/sdk/freeport" - chainsel "github.com/smartcontractkit/chain-selectors" "github.com/stretchr/testify/require" "go.uber.org/zap/zapcore" + chainsel "github.com/smartcontractkit/chain-selectors" + "github.com/smartcontractkit/chainlink/integration-tests/deployment" "github.com/smartcontractkit/chainlink-common/pkg/logger" @@ -39,16 +41,19 @@ func NewMemoryChains(t *testing.T, numChains int) map[uint64]deployment.Chain { Selector: sel, Client: chain.Backend, DeployerKey: chain.DeployerKey, - Confirm: func(tx common.Hash) (uint64, error) { + Confirm: func(tx *types.Transaction) (uint64, error) { + if tx == nil { + return 0, fmt.Errorf("tx was nil, nothing to confirm") + } for { chain.Backend.Commit() - receipt, err := chain.Backend.TransactionReceipt(context.Background(), tx) + receipt, err := chain.Backend.TransactionReceipt(context.Background(), tx.Hash()) if err != nil { t.Log("failed to get receipt", err) continue } if receipt.Status == 0 { - t.Logf("Status (reverted) %d for txhash %s\n", receipt.Status, tx.String()) + t.Logf("Status (reverted) %d for txhash %s\n", receipt.Status, tx.Hash().Hex()) } return receipt.BlockNumber.Uint64(), nil }