Skip to content

Commit

Permalink
Fix rounding in test
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph committed Mar 1, 2025
1 parent 2ed1ec2 commit 5e6bc5f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/e2e/c/dynamic_fees.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
expectedGasPriceIncreaseDenominator = 5
)
var (
bigExpectedGasPriceIncreaseNumerator = big.NewInt(expectedGasPriceIncreaseNumerator)
bigExpectedGasPriceIncreaseDenominator = big.NewInt(expectedGasPriceIncreaseDenominator)
bigExpectedGasPriceIncreaseDenominatorMinus1 = big.NewInt(expectedGasPriceIncreaseDenominator - 1)

gasFeeCap = big.NewInt(maxFeePerGas)
gasTipCap = big.NewInt(minFeePerGas)
)
Expand Down Expand Up @@ -138,8 +142,10 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {

initialGasPrice := latest.BaseFee
targetGasPrice := new(big.Int).Set(initialGasPrice)
targetGasPrice.Mul(targetGasPrice, big.NewInt(expectedGasPriceIncreaseNumerator))
targetGasPrice.Div(targetGasPrice, big.NewInt(expectedGasPriceIncreaseDenominator))
targetGasPrice.Mul(targetGasPrice, bigExpectedGasPriceIncreaseNumerator)
targetGasPrice.Add(targetGasPrice, bigExpectedGasPriceIncreaseDenominatorMinus1)
targetGasPrice.Div(targetGasPrice, bigExpectedGasPriceIncreaseDenominator)

tc.Log().Info("initializing gas prices",
zap.Stringer("initialPrice", initialGasPrice),
zap.Stringer("targetPrice", targetGasPrice),
Expand All @@ -158,7 +164,7 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
require.NoError(err)

// If the gas price has increased, stop the loop.
if latest.BaseFee.Cmp(targetGasPrice) > 0 {
if latest.BaseFee.Cmp(targetGasPrice) >= 0 {
tc.Log().Info("gas price has increased",
zap.Stringer("initialPrice", initialGasPrice),
zap.Stringer("targetPrice", targetGasPrice),
Expand Down Expand Up @@ -207,7 +213,7 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
require.NoError(err)

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

0 comments on commit 5e6bc5f

Please sign in to comment.