Skip to content

Commit

Permalink
test(zk): Add setup fork failure test (#521)
Browse files Browse the repository at this point in the history
add setup fork failure with testFail

Co-authored-by: Jrigada <[email protected]>
  • Loading branch information
Jrigada and Jrigada authored Aug 16, 2024
1 parent a452f40 commit 184304b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
14 changes: 14 additions & 0 deletions crates/forge/tests/it/zk/fork.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! Fork tests.
use crate::{config::*, test_helpers::TEST_DATA_DEFAULT};
use forge::revm::primitives::SpecId;
use foundry_test_utils::Filter;

#[tokio::test(flavor = "multi_thread")]
async fn test_zk_setup_fork_failure() {
let runner = TEST_DATA_DEFAULT.runner_zksync();
let filter =
Filter::new("testFail_ZkSetupForkFailureExecutesTest", "ZkSetupForkFailureTest", ".*");

TestConfig::with_filter(runner, filter).evm_spec(SpecId::SHANGHAI).run().await;
}
1 change: 1 addition & 0 deletions crates/forge/tests/it/zk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod basic;
mod cheats;
mod contracts;
mod factory;
mod fork;
mod fuzz;
mod invariant;
mod logs;
Expand Down
19 changes: 19 additions & 0 deletions testdata/zk/SetupForkFailure.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "ds-test/test.sol";
import "../cheats/Vm.sol";

contract ZkSetupForkFailureTest is DSTest {
Vm constant vm = Vm(HEVM_ADDRESS);
uint256 constant ETH_FORK_BLOCK = 18993187;

function setUp() public {
vm.createSelectFork("https://eth-mainnet.alchemyapi.io/v2/Lc7oIGYeL_QvInzI0Wiu_pOZZDEKBrdf", ETH_FORK_BLOCK); // trufflehog:ignore
}

// We test that the following function is called after EVM fork from zk context
function testFail_ZkSetupForkFailureExecutesTest() public pure {
assert(false);
}
}

0 comments on commit 184304b

Please sign in to comment.