Skip to content

Use EstimateBaseFee in e2e tests #3782

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

Merged
merged 5 commits into from
Apr 24, 2025
Merged
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
19 changes: 9 additions & 10 deletions tests/e2e/c/dynamic_fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
contractAddress = receipt.ContractAddress
})

latest, err := ethClient.HeaderByNumber(tc.DefaultContext(), nil)
initialGasPrice, err := ethClient.EstimateBaseFee(tc.DefaultContext())
require.NoError(err)

initialGasPrice := latest.BaseFee
targetGasPrice := new(big.Int).Set(initialGasPrice)
targetGasPrice.Mul(targetGasPrice, bigExpectedGasPriceIncreaseNumerator)
targetGasPrice.Add(targetGasPrice, bigExpectedGasPriceIncreaseDenominatorMinus1)
Expand All @@ -162,22 +161,22 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {

tc.Eventually(func() bool {
// Check the gas price
latest, err := ethClient.HeaderByNumber(tc.DefaultContext(), nil)
gasPrice, err := ethClient.EstimateBaseFee(tc.DefaultContext())
require.NoError(err)

// If the gas price has increased, stop the loop.
if latest.BaseFee.Cmp(targetGasPrice) >= 0 {
if gasPrice.Cmp(targetGasPrice) >= 0 {
tc.Log().Info("gas price has increased",
zap.Stringer("initialPrice", initialGasPrice),
zap.Stringer("targetPrice", targetGasPrice),
zap.Stringer("newPrice", latest.BaseFee),
zap.Stringer("newPrice", gasPrice),
)
return true
}

tc.Log().Info("gas price hasn't sufficiently increased",
zap.Stringer("initialPrice", initialGasPrice),
zap.Stringer("newPrice", latest.BaseFee),
zap.Stringer("newPrice", gasPrice),
zap.Stringer("targetPrice", targetGasPrice),
)

Expand Down Expand Up @@ -213,21 +212,21 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
tc.By("sending small transactions until a sufficient gas price decrease is detected", func() {
tc.Eventually(func() bool {
// Check the gas price
latest, err := ethClient.HeaderByNumber(tc.DefaultContext(), nil)
gasPrice, err := ethClient.EstimateBaseFee(tc.DefaultContext())
require.NoError(err)

// If the gas price has decreased, stop the loop.
if latest.BaseFee.Cmp(initialGasPrice) <= 0 {
if gasPrice.Cmp(initialGasPrice) <= 0 {
tc.Log().Info("gas price has decreased",
zap.Stringer("initialPrice", initialGasPrice),
zap.Stringer("newPrice", latest.BaseFee),
zap.Stringer("newPrice", gasPrice),
)
return true
}

tc.Log().Info("gas price hasn't sufficiently decreased",
zap.Stringer("initialPrice", initialGasPrice),
zap.Stringer("newPrice", latest.BaseFee),
zap.Stringer("newPrice", gasPrice),
)

// Create the transaction
Expand Down