diff --git a/tests/bounties/src/adder/script/Test.s.sol b/tests/bounties/src/adder/script/Assertion.s.sol similarity index 69% rename from tests/bounties/src/adder/script/Test.s.sol rename to tests/bounties/src/adder/script/Assertion.s.sol index 2298785..2729a74 100644 --- a/tests/bounties/src/adder/script/Test.s.sol +++ b/tests/bounties/src/adder/script/Assertion.s.sol @@ -4,14 +4,16 @@ pragma solidity ^0.8.27; import {Script} from "forge-std/Script.sol"; import {Vm} from "forge-std/Vm.sol"; +import {IAdder} from "src/IAdder.sol"; import {Deployments, LibDeployments} from "script/LibDeployments.sol"; -contract TestScript is Script { +contract AssertionScript is Script { using LibDeployments for Vm; function run() external { Deployments memory deployments = vm.loadDeployments(); - if (deployments.adder.number() >= 1) return; + IAdder adder = IAdder(deployments.contracts[0]); + if (adder.number() >= 1) return; vm.writeFile("./exploited", ""); } } diff --git a/tests/bounties/src/adder/script/LibDeployments.sol b/tests/bounties/src/adder/script/LibDeployments.sol index 8aaf8f1..0ea2053 100644 --- a/tests/bounties/src/adder/script/LibDeployments.sol +++ b/tests/bounties/src/adder/script/LibDeployments.sol @@ -3,10 +3,9 @@ pragma solidity ^0.8.27; import {Vm} from "forge-std/Vm.sol"; -import {IAdder} from "src/IAdder.sol"; struct Deployments { - IAdder adder; + address[] contracts; } library LibDeployments { @@ -16,8 +15,8 @@ library LibDeployments { return path; } - function storeDeployments(Vm vm, Deployments memory deployment) internal { - string memory json = vm.serializeAddress("deployments", "adder", address(deployment.adder)); + function storeDeployments(Vm vm, Deployments memory deployments) internal { + string memory json = vm.serializeAddress("deployments", "contracts", deployments.contracts); vm.writeJson(json, getDeploymentsPath(vm)); } diff --git a/tests/bounties/src/adder/script/safe/Deploy.s.sol b/tests/bounties/src/adder/script/safe/Setup.s.sol similarity index 78% rename from tests/bounties/src/adder/script/safe/Deploy.s.sol rename to tests/bounties/src/adder/script/safe/Setup.s.sol index 0745364..6490244 100644 --- a/tests/bounties/src/adder/script/safe/Deploy.s.sol +++ b/tests/bounties/src/adder/script/safe/Setup.s.sol @@ -7,14 +7,15 @@ import {Vm} from "forge-std/Vm.sol"; import {SafeAdder} from "src/safe/Adder.sol"; import {Deployments, LibDeployments} from "script/LibDeployments.sol"; -contract DeployScript is Script { +contract SetupScript is Script { using LibDeployments for Vm; function run() external { Deployments memory deployments; + deployments.contracts = new address[](1); vm.startBroadcast(); - deployments.adder = new SafeAdder(); + deployments.contracts[0] = new SafeAdder(); vm.stopBroadcast(); vm.storeDeployments(deployments); diff --git a/tests/bounties/src/adder/script/unsafe/Exploit.s.sol b/tests/bounties/src/adder/script/unsafe/Exploit.s.sol index 5ba1764..a645dd6 100644 --- a/tests/bounties/src/adder/script/unsafe/Exploit.s.sol +++ b/tests/bounties/src/adder/script/unsafe/Exploit.s.sol @@ -12,7 +12,7 @@ contract ExploitScript is Script { function run() external { Deployments memory deployments = vm.loadDeployments(); - IAdder adder = deployments.adder; + IAdder adder = Iadder(deployments.contracts[0]); uint256 number = adder.number(); uint256 increment; unchecked { diff --git a/tests/bounties/src/adder/script/unsafe/Deploy.s.sol b/tests/bounties/src/adder/script/unsafe/Setup.s.sol similarity index 77% rename from tests/bounties/src/adder/script/unsafe/Deploy.s.sol rename to tests/bounties/src/adder/script/unsafe/Setup.s.sol index 637a582..df3fdc0 100644 --- a/tests/bounties/src/adder/script/unsafe/Deploy.s.sol +++ b/tests/bounties/src/adder/script/unsafe/Setup.s.sol @@ -7,14 +7,15 @@ import {Vm} from "forge-std/Vm.sol"; import {UnsafeAdder} from "src/unsafe/Adder.sol"; import {Deployments, LibDeployments} from "script/LibDeployments.sol"; -contract DeployScript is Script { +contract SetupScript is Script { using LibDeployments for Vm; function run() external { Deployments memory deployments; + deployments.contracts = new address[](1); vm.startBroadcast(); - deployments.adder = new UnsafeAdder(); + deployments.contracts[0] = new UnsafeAdder(); vm.stopBroadcast(); vm.storeDeployments(deployments);