Skip to content

test(evm): make 'insufficient gas' test actually reject on autobahn#3394

Open
wen-coding wants to merge 3 commits intomainfrom
wen/fix_insufficient_gas_test_for_autobahn
Open

test(evm): make 'insufficient gas' test actually reject on autobahn#3394
wen-coding wants to merge 3 commits intomainfrom
wen/fix_insufficient_gas_test_for_autobahn

Conversation

@wen-coding
Copy link
Copy Markdown
Contributor

Summary

  • The Should fail if insufficient gas is provided test in contracts/test/EVMCompatabilityTest.js was silently passing under V2 but cascading into a nonce conflict under Autobahn. Two bugs combined:
    • gasPrice: feeData.gasPrice - 1 only crosses the chain's 1 gwei minimum when eth_gasPrice == 1 gwei exactly. Under V2's idle blocks that's true; under Autobahn's faster basefee dynamics eth_gasPrice sits at ~1.1 gwei, so -1 wei does not bring the price below the min and the tx is accepted.
    • The chai matcher expect(...).to.be.reverted ran on a still-pending promise (no await), so the assertion never actually checked anything. The submitted tx silently landed, bumped the sender's nonce, and broke the next test (Should deduct correct amount even if higher gas price is used) with incorrect account sequence.
  • Fix: hardcode gasPrice: 1 (1 wei, far below any plausible basefee), add the missing await, and switch to .to.be.rejected since hardhat-ethers rejects pre-flight via estimateGas — not an EVM revert, so the previous matcher would not match anyway.

Test plan

  • npx hardhat test test/EVMCompatabilityTest.js --grep "Gas tests" --network seilocal against an Autobahn cluster: 8/8 runs, all 8 tests passing (was 5/5 failing before).
  • CI / V2 path still green.

🤖 Generated with Claude Code

The test previously did `gasPrice: feeData.gasPrice - 1` and used
`expect(...).to.be.reverted` without an `await`, so two things went
wrong on Autobahn but not on V2:

1. Under V2 with idle blocks, eth_gasPrice == 1 gwei (the chain min),
   so `gasPrice - 1` was below min and the tx was rejected. Under
   Autobahn, basefee dynamics push eth_gasPrice slightly above 1 gwei
   (we observe ~1.1 gwei idle), so `gasPrice - 1` stayed above the
   min and the tx was accepted.
2. Without `await`, the chai matcher ran on a still-pending promise —
   the assertion never actually checked anything.

The combination caused the "Should fail" test to silently leak a tx
that bumped the on-chain nonce, breaking the next test
("Should deduct correct amount even if higher gas price is used")
with an "incorrect account sequence" mempool error.

Fix: hardcode `gasPrice: 1` (1 wei, far below any plausible basefee),
add the missing `await`, and use `.to.be.rejected` since hardhat-ethers
rejects pre-flight via estimateGas (not an EVM revert, so
`.to.be.reverted` doesn't match).

Verified: 8/8 runs of `Gas tests` pass under Autobahn cluster.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMay 5, 2026, 6:00 PM

wen-coding and others added 2 commits May 5, 2026 10:42
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Use rejectedWith(/max fee per gas less than block base fee/) instead
of plain rejected so the test fails loud if the chain's rejection
path or error message changes (e.g. admission vs estimateGas).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@wen-coding wen-coding requested review from jewei1997 and pompon0 May 5, 2026 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants