Skip to content

Commit

Permalink
more simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Oct 15, 2024
1 parent 51442c7 commit ae5a456
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions integration-tests/deployment/devenv/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/sethvargo/go-retry"
chainselectors "github.com/smartcontractkit/chain-selectors"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
Expand Down Expand Up @@ -62,31 +61,26 @@ func NewChains(logger logger.Logger, configs []ChainConfig) (map[uint64]deployme
}
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancel()
err := retry.Do(ctx,
retry.WithMaxDuration(3*time.Minute, retry.NewFibonacci(1*time.Second)),
func(ctx context.Context) error {
chainId, err := ec.ChainID(ctx)
if err != nil {
return fmt.Errorf("failed to get chain id: %w", err)
}
receipt, err := bind.WaitMined(ctx, ec, tx)
if err != nil {
return retry.RetryableError(fmt.Errorf("failed to get receipt for chain %d: %w", chainId, err))
}
if receipt == nil {
return retry.RetryableError(fmt.Errorf("receipt was nil for tx %s", tx.Hash().Hex()))
}
blockNumber = receipt.BlockNumber.Uint64()
if receipt.Status == 0 {
errReason, err := deployment.GetErrorReasonFromTx(ec, chainCfg.DeployerKey.From, *tx, receipt)
if err == nil && errReason != "" {
return fmt.Errorf("tx %s reverted,error reason: %s", tx.Hash().Hex(), errReason)
}
return fmt.Errorf("tx %s reverted, could not decode error reason", tx.Hash().Hex())
}
return nil
})
return blockNumber, err
chainId, err := ec.ChainID(ctx)
if err != nil {
return blockNumber, fmt.Errorf("failed to get chain id: %w", err)
}
receipt, err := bind.WaitMined(ctx, ec, tx)
if err != nil {
return blockNumber, fmt.Errorf("failed to get confirmed receipt for chain %d: %w", chainId, err)
}
if receipt == nil {
return blockNumber, fmt.Errorf("receipt was nil for tx %s", tx.Hash().Hex())
}
blockNumber = receipt.BlockNumber.Uint64()
if receipt.Status == 0 {
errReason, err := deployment.GetErrorReasonFromTx(ec, chainCfg.DeployerKey.From, *tx, receipt)
if err == nil && errReason != "" {
return blockNumber, fmt.Errorf("tx %s reverted,error reason: %s", tx.Hash().Hex(), errReason)
}
return blockNumber, fmt.Errorf("tx %s reverted, could not decode error reason", tx.Hash().Hex())
}
return blockNumber, nil
},
}
}
Expand Down

0 comments on commit ae5a456

Please sign in to comment.