Skip to content

Commit

Permalink
[TT-1546] change the parameter of chains' Confirm() function (#14388)
Browse files Browse the repository at this point in the history
* pass *types.Transaction instead of common.Hash to chain's Confirm() function

* fix lints
  • Loading branch information
Tofel authored Sep 12, 2024
1 parent 9a3e76a commit a2514d7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/deployment/ccip/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/deployment/ccip/deploy_home_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func AddNodes(
if err != nil {
return err
}
_, err = chain.Confirm(tx.Hash())
_, err = chain.Confirm(tx)
return err
}

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/deployment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
15 changes: 10 additions & 5 deletions integration-tests/deployment/memory/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit a2514d7

Please sign in to comment.