-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Added testing of multiple deploy of same contract (#555)
* Added testing of multiple deploy of same contract * Change low level call to zkvm * use low level --------- Co-authored-by: Jrigada <[email protected]>
- Loading branch information
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters