Skip to content
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

test(protocol): check LibEIP1559 function results in fuzz tests #18475

Merged
merged 2 commits into from
Nov 11, 2024
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
28 changes: 20 additions & 8 deletions packages/protocol/test/layer2/LibEIP1559.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,37 @@ contract TestLibEIP1559 is TaikoL2Test {

/// forge-config: layer2.fuzz.runs = 1000
/// forge-config: layer2.fuzz.show-logs = true
function test_fuzz_ethQty(uint64 _gasTarget, uint64 _gasExcess) external pure {
function test_fuzz_ethQty(uint64 _gasTarget, uint64 _gasExcess) external {
if (_gasTarget == 0) _gasTarget = 1;
uint256 result = LibEIP1559.ethQty(_gasTarget, _gasExcess);
assertTrue(result > 0);
}

LibEIP1559.ethQty(_gasTarget, _gasExcess);
/// forge-config: layer2.fuzz.runs = 2000
/// forge-config: layer2.fuzz.show-logs = true
function test_fuzz_basefee(uint64 _gasTarget, uint64 _gasExcess) external {
uint256 result = LibEIP1559.basefee(_gasTarget, _gasExcess);
assertTrue(result >= 1);
}

/// forge-config: layer2.fuzz.runs = 2000
/// forge-config: layer2.fuzz.show-logs = true
function test_fuzz_adjustExcess(
uint64 _gasTarget,
uint64 _oldGasTarget,
uint64 _newGasTarget,
uint64 _gasExcess
uint64 _oldGasExcess
)
external
pure
{
if (_gasTarget == 0) _gasTarget = 1;
if (_newGasTarget == 0) _newGasTarget = 1;
LibEIP1559.adjustExcess(_gasTarget, _newGasTarget, _gasExcess);
(uint64 newGasTarget_, uint64 newGasExcess_) =
LibEIP1559.adjustExcess(_oldGasTarget, _newGasTarget, _oldGasExcess);

if (_oldGasTarget == 0 && _newGasTarget == 0) {
assertEq(newGasTarget_, 0);
assertEq(newGasExcess_, _oldGasExcess);
} else {
assertTrue(newGasTarget_ != 0);
}
}

/// forge-config: layer2.fuzz.runs = 2000
Expand Down