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(zk): migrate ZkLargeFactoryDependenciesTest #528

Merged
merged 5 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
74 changes: 74 additions & 0 deletions crates/forge/tests/it/zk/factory_deps.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//! Forge tests for zksync factory contracts.

use forge::revm::primitives::SpecId;
use foundry_test_utils::{forgetest_async, util, Filter, ZkSyncNode};

use crate::{config::TestConfig, test_helpers::TEST_DATA_DEFAULT};

#[tokio::test(flavor = "multi_thread")]
#[ignore = "disabled since #476"] //FIXME
Jrigada marked this conversation as resolved.
Show resolved Hide resolved
async fn test_zk_can_deploy_large_factory_deps() {
let runner = TEST_DATA_DEFAULT.runner_zksync();
{
let filter = Filter::new(".*", "ZkLargeFactoryDependenciesTest", ".*");
TestConfig::with_filter(runner, filter).evm_spec(SpecId::SHANGHAI).run().await;
}
}

forgetest_async!(
#[ignore = "disabled since #476"] //FIXME
Jrigada marked this conversation as resolved.
Show resolved Hide resolved
script_zk_can_deploy_large_factory_deps,
|prj, cmd| {
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 = 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 invariant;
mod logs;
Expand Down
Loading