diff --git a/crates/forge/tests/fixtures/zk/Deploy.s.sol b/crates/forge/tests/fixtures/zk/Deploy.s.sol new file mode 100644 index 000000000..9674514ce --- /dev/null +++ b/crates/forge/tests/fixtures/zk/Deploy.s.sol @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.18; + +import {Script} from "forge-std/Script.sol"; +import {Greeter} from "../src/Greeter.sol"; + +contract DeployScript is Script { + // Vm constant vm = Vm(HEVM_ADDRESS); + + Greeter greeter; + string greeting; + + function run() external { + // test is using old Vm.sol interface, so we call manually + (bool success,) = address(vm).call(abi.encodeWithSignature("zkVm(bool)", true)); + require(success, "zkVm() call failed"); + vm.startBroadcast(); + + greeter = new Greeter(); + + greeter.setAge(123); + uint256 age = greeter.getAge(); + + greeter.greeting("john"); + + vm.stopBroadcast(); + + assert(age == 123); + } +} diff --git a/crates/forge/tests/it/zk/deploy.rs b/crates/forge/tests/it/zk/deploy.rs new file mode 100644 index 000000000..4af3bb71e --- /dev/null +++ b/crates/forge/tests/it/zk/deploy.rs @@ -0,0 +1,31 @@ +use foundry_test_utils::{forgetest_async, util, TestProject}; + +use crate::test_helpers::run_zk_script_test; + +forgetest_async!(multiple_deployments_of_the_same_contract, |prj, cmd| { + setup_deploy_prj(&mut prj); + run_zk_script_test( + prj.root(), + &mut cmd, + "./script/Deploy.s.sol", + "DeployScript", + None, + 3, + Some(&["-vvvvv"]), + ); + run_zk_script_test( + prj.root(), + &mut cmd, + "./script/Deploy.s.sol", + "DeployScript", + None, + 3, + Some(&["-vvvvv"]), + ); +}); + +fn setup_deploy_prj(prj: &mut TestProject) { + util::initialize(prj.root()); + prj.add_script("Deploy.s.sol", include_str!("../../fixtures/zk/Deploy.s.sol")).unwrap(); + prj.add_source("Greeter.sol", include_str!("../../../../../testdata/zk/Greeter.sol")).unwrap(); +} diff --git a/crates/forge/tests/it/zk/mod.rs b/crates/forge/tests/it/zk/mod.rs index 084d6b085..c9bf37f79 100644 --- a/crates/forge/tests/it/zk/mod.rs +++ b/crates/forge/tests/it/zk/mod.rs @@ -3,6 +3,7 @@ mod basic; mod cheats; mod contracts; mod create; +mod deploy; mod factory; mod factory_deps; mod fork;