Skip to content

Commit

Permalink
test(zk): add large factory deps test
Browse files Browse the repository at this point in the history
  • Loading branch information
Karrq committed Aug 13, 2024
1 parent 0dc00ad commit 11bf9b3
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 0 deletions.
68 changes: 68 additions & 0 deletions crates/forge/tests/it/zk/factory_deps.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//! Forge tests for zksync factory contracts.
use super::test_zk;

test_zk!(
#[ignore] //FIXME
can_deploy_large_factory_deps,
".*",
"ZkLargeFactoryDependenciesTest"
);

foundry_test_utils::forgetest_async!(
#[ignore] //FIXME
script_zk_can_deploy_large_factory_deps,
|prj, cmd| {
foundry_test_utils::util::initialize(prj.root());

prj.add_source(
"LargeContracts.sol",
include_str!("../../../../../testdata/zk/LargeContracts.sol"),
)
.unwrap();
prj.add_script(
"LargeContracts.s.sol",
r#"
import "forge-std/Script.sol";
import "../src/LargeContracts.sol";
contract ZkLargeFactoryDependenciesScript is Script {
function run() external {
vm.broadcast();
new LargeContract();
}
}
"#,
)
.unwrap();

let node = foundry_test_utils::ZkSyncNode::start();

cmd.arg("script").args([
"--zk-startup",
"./script/LargeContracts.s.sol",
"--broadcast",
"--private-key",
"0x3d3cbc973389cb26f657686445bcc75662b415b656078503592ac8c1abb8810e",
"--chain",
"260",
"--gas-estimate-multiplier",
"310",
"--rpc-url",
node.url().as_str(),
"--slow",
"--evm-version",
"shanghai",
]);
assert!(cmd.stdout_lossy().contains("ONCHAIN EXECUTION COMPLETE & SUCCESSFUL"));

let run_latest = foundry_common::fs::json_files(prj.root().join("broadcast").as_path())
.find(|file| file.ends_with("run-latest.json"))
.expect("No broadcast artifacts");

let content = foundry_common::fs::read_to_string(run_latest).unwrap();

let json: serde_json::Value = serde_json::from_str(&content).unwrap();
assert_eq!(json["transactions"].as_array().expect("broadcastable txs").len(), 1);
}
);
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 factory_deps;
mod fuzz;
mod logs;
mod repros;
Expand Down
Loading

0 comments on commit 11bf9b3

Please sign in to comment.