Skip to content

Commit

Permalink
chore(protocol): fix issues in test:coverage (#18582)
Browse files Browse the repository at this point in the history
Co-authored-by: xiaodino <[email protected]>
Co-authored-by: Daniel Wang <[email protected]>
Co-authored-by: dantaik <[email protected]>
  • Loading branch information
4 people authored Dec 16, 2024
1 parent b7c31e9 commit 29682b7
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
5 changes: 2 additions & 3 deletions packages/protocol/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ gas_price = 10_000_000_000 # 10 Gwei
gas_limit = "18446744073709551615" # u64::MAX
optimizer = true
optimizer_runs = 200
fuzz_runs = 200
fuzz_runs_show_logs = false
ffi = true
memory_limit = 2_073_741_824
solc_version = "0.8.27"
Expand Down Expand Up @@ -44,9 +46,6 @@ fs_permissions = [
# 5740: Unreachable code
ignored_error_codes = [2394, 3860, 5574, 5740]

[fuzz]
runs = 200

[fmt]
bracket_spacing = true
line_length = 100
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"test:deploy:l1": "./script/download_solc.sh && ./script/layer1/deploy_protocol_on_l1.sh",
"eslint": "pnpm exec eslint --fix --ignore-path .eslintignore --ext .js,.ts .",
"fmt:sol": "forge fmt && pnpm solhint 'contracts/**/*.sol'",
"test:coverage": "mkdir -p coverage && forge coverage --report lcov && lcov --remove ./lcov.info -o ./coverage/lcov.info 'test/' 'script/' 'contracts/thirdparty/' && genhtml coverage/lcov.info --branch-coverage --output-dir coverage --ignore-errors category && open coverage/index.html",
"test:coverage": "mkdir -p coverage && forge coverage --report lcov && lcov --ignore-errors inconsistent --ignore-errors unused --remove ./lcov.info -o ./coverage/lcov.info 'test/' 'script/' 'contracts/thirdparty/' && genhtml coverage/lcov.info --branch-coverage --output-dir coverage --ignore-errors category --ignore-errors inconsistent --ignore-errors corrupt && open coverage/index.html",
"genesis:gen": "pnpm compile:l2 && ts-node ./test/genesis/generate/generate.ts",
"genesis:test": "./test/genesis/genesis.test.sh",
"export:simconf": "mkdir -p simulation/out && FOUNDRY_PROFILE=layer2 forge test --match-test 'test_L2_NoFeeCheck_simulation' -vv > simulation/out/simconf_$(date +%s).txt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ contract SendMessageToDelegateOwner is BaseScript {
address public delegateOwnerImpl = 0x1f0511cDae2fbfD93563469dA02b82dEd320C8Bd;
address public multicall3 = 0xcA11bde05977b3631167028862bE2a173976CA11;
address public l1Bridge = 0xd60247c6848B7Ca29eDdF63AA924E53dB6Ddd8EC;
address public testAddress1 = vm.envAddress("TEST_ADDRESS_1");
address public testAddress1 =
vm.envOr("TEST_ADDRESS_1", address(0x0000000000000000000000000000000000000000));

function run() external broadcast {
Multicall3.Call3[] memory calls = new Multicall3.Call3[](2);
Expand Down
4 changes: 2 additions & 2 deletions packages/protocol/snapshots/TaikoL1Test_Suite1.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"proposeBlocksV3": "84973",
"proveBlocksV3": "133553"
"proposeBlocksV3": "84963",
"proveBlocksV3": "133546"
}
22 changes: 11 additions & 11 deletions packages/protocol/test/layer1/based/TaikoL1TestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ abstract contract TaikoL1TestBase is Layer1Test {
}

function _logAllBlocksAndTransitions() internal view {
console2.log(unicode"───────────────────────────────────────────────────────────────");
console2.log(unicode"|───────────────────────────────────────────────────────────────");
ITaikoL1.Stats1 memory stats1 = taikoL1.getStats1();
console2.log("Stats1 - lastSyncedBlockId:", stats1.lastSyncedBlockId);
console2.log("Stats1 - lastSyncedAt:", stats1.lastSyncedAt);
Expand All @@ -153,25 +153,25 @@ abstract contract TaikoL1TestBase is Layer1Test {
for (uint64 i = firstBlockId; i < stats2.numBlocks; ++i) {
ITaikoL1.BlockV3 memory blk = taikoL1.getBlockV3(i);
if (blk.blockId <= stats2.lastVerifiedBlockId) {
console2.log(unicode"─ ✔ block#", blk.blockId);
console2.log(unicode"|─ ✔ block#", blk.blockId);
} else {
console2.log(unicode"─── block#", blk.blockId);
console2.log(unicode"|─── block#", blk.blockId);
}
console2.log(unicode"── metahash:", Strings.toHexString(uint256(blk.metaHash)));
console2.log(unicode"── timestamp:", blk.timestamp);
console2.log(unicode"── anchorBlockId:", blk.anchorBlockId);
console2.log(unicode"── nextTransitionId:", blk.nextTransitionId);
console2.log(unicode"── verifiedTransitionId:", blk.verifiedTransitionId);
console2.log(unicode"|── metahash:", Strings.toHexString(uint256(blk.metaHash)));
console2.log(unicode"|── timestamp:", blk.timestamp);
console2.log(unicode"|── anchorBlockId:", blk.anchorBlockId);
console2.log(unicode"|── nextTransitionId:", blk.nextTransitionId);
console2.log(unicode"|── verifiedTransitionId:", blk.verifiedTransitionId);

for (uint24 j = 1; j < blk.nextTransitionId; ++j) {
ITaikoL1.TransitionV3 memory tran = taikoL1.getTransitionV3(blk.blockId, j);
console2.log(unicode"── transition#", j);
console2.log(unicode"|── transition#", j);
console2.log(
unicode"│ │ ── parentHash:",
unicode"│ │ |── parentHash:",
Strings.toHexString(uint256(tran.parentHash))
);
console2.log(
unicode"│ │ ── blockHash:",
unicode"│ │ |── blockHash:",
Strings.toHexString(uint256(tran.blockHash))
);
console2.log(
Expand Down
16 changes: 8 additions & 8 deletions packages/protocol/test/layer2/LibEIP1559.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,23 @@ contract TestLibEIP1559 is Layer2Test {
assertEq(baselineBasefee, basefee);
}

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

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

/// forge-config: layer2.fuzz.runs = 2000
/// forge-config: layer2.fuzz.show-logs = true
/// forge-config: default.fuzz_runs = 2000
/// forge-config: default.fuzz_runs_show_logs = true
function test_fuzz_adjustExcess(
uint64 _oldGasTarget,
uint64 _newGasTarget,
Expand All @@ -134,8 +134,8 @@ contract TestLibEIP1559 is Layer2Test {
}
}

/// forge-config: layer2.fuzz.runs = 2000
/// forge-config: layer2.fuzz.show-logs = true
/// forge-config: default.fuzz_runs = 2000
/// forge-config: default.fuzz_runs_show_logs = true
function test_fuzz_calc1559BaseFee(
uint64 _gasTarget,
uint64 _gasExcess,
Expand Down
8 changes: 4 additions & 4 deletions packages/protocol/test/layer2/TaikoL2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ contract TestTaikoL2 is Layer2Test {
assertEq(taikoL2.getBlockHash(uint64(1000)), 0);
}

/// forge-config: layer2.fuzz.runs = 2000
/// forge-config: layer2.fuzz.show-logs = true
/// forge-config: default.fuzz_runs = 2000
/// forge-config: default.fuzz_runs_show_logs = true
function test_fuzz_getBasefeeV2(
uint32 _parentGasUsed,
uint32 _gasIssuancePerSecond,
Expand All @@ -103,8 +103,8 @@ contract TestTaikoL2 is Layer2Test {
assertTrue(basefee_ != 0, "basefee is 0");
}

/// forge-config: layer2.fuzz.runs = 2000
/// forge-config: layer2.fuzz.show-logs = true
/// forge-config: default.fuzz_runs = 2000
/// forge-config: default.fuzz_runs_show_logs = true
function test_fuzz_anchorV2(
uint32 _parentGasUsed,
uint32 _gasIssuancePerSecond,
Expand Down

0 comments on commit 29682b7

Please sign in to comment.