diff --git a/addresses/Addresses.json b/addresses/Addresses.json index b5cea30..a7445ea 100644 --- a/addresses/Addresses.json +++ b/addresses/Addresses.json @@ -81,31 +81,31 @@ "addr": "0xF1608e08314B546CA2dDC1E4c247ed2ac753a82b", "chainId": 11155111, "isContract": true, - "name": "GOVERNOR_OZ" + "name": "OZ_GOVERNOR" }, { "addr": "0xD21a3b1b572F7C38b5e3ff841d1D2903e1B03695", "chainId": 11155111, "isContract": true, - "name": "GOVERNOR_OZ_TIMELOCK" + "name": "OZ_GOVERNOR_TIMELOCK" }, { "addr": "0xDefA8533981bb799bb2bC42a6078d5fE8327a822", "chainId": 11155111, "isContract": true, - "name": "GOVERNOR_OZ_GOVERNANCE_TOKEN" + "name": "OZ_GOVERNOR_GOVERNANCE_TOKEN" }, { "addr": "0x6fFA4aDB1df78f0Cc127d9BdA946C9E4eBF07C90", "chainId": 11155111, "isContract": true, - "name": "GOVERNOR_OZ_VAULT" + "name": "OZ_GOVERNOR_VAULT" }, { "addr": "0x948B7026411CBB9Ef39dB330B31C735b3D06359b", "chainId": 11155111, "isContract": true, - "name": "GOVERNOR_OZ_VAULT_TOKEN" + "name": "OZ_GOVERNOR_VAULT_TOKEN" }, { "addr": "0xE6841D92B0C345144506576eC13ECf5103aC7f49", diff --git a/lib/forge-proposal-simulator b/lib/forge-proposal-simulator index 29ec928..8cf6b30 160000 --- a/lib/forge-proposal-simulator +++ b/lib/forge-proposal-simulator @@ -1 +1 @@ -Subproject commit 29ec9281fe5bd8625e08faa1754b48695cc2ed23 +Subproject commit 8cf6b306ff3c8d21716c581285873301bc5b7422 diff --git a/script/DeployGovernorOz.s.sol b/script/DeployOZGovernor.s.sol similarity index 61% rename from script/DeployGovernorOz.s.sol rename to script/DeployOZGovernor.s.sol index b36f32f..905356b 100644 --- a/script/DeployGovernorOz.s.sol +++ b/script/DeployOZGovernor.s.sol @@ -6,24 +6,24 @@ import {MultisigProposal} from "@forge-proposal-simulator/src/proposals/Multisig import {TimelockController} from "@openzeppelin/governance/TimelockController.sol"; import {MockERC20Votes} from "src/mocks/governor-oz/MockERC20Votes.sol"; -import {MockGovernorOz} from "src/mocks/governor-oz/MockGovernorOz.sol"; +import {MockOZGovernor} from "src/mocks/governor-oz/MockOZGovernor.sol"; -/// @notice Governor OZ deployment contract -/// DO_PRINT=false DO_BUILD=false DO_DEPLOY=true DO_VALIDATE=true forge script script/DeployGovernorOZ.s.sol:DeployGovernorOZ --fork-url sepolia -vvvvv -contract DeployGovernorOZ is MultisigProposal { +/// @notice OZ Governor deployment contract +/// DO_PRINT=false DO_BUILD=false DO_DEPLOY=true DO_VALIDATE=true forge script script/DeployOZGovernor.s.sol:DeployOZGovernor --fork-url sepolia -vvvvv +contract DeployOZGovernor is MultisigProposal { function name() public pure override returns (string memory) { - return "GOVERNOR_OZ_DEPLOY"; + return "OZ_GOVERNOR_DEPLOY"; } function description() public pure override returns (string memory) { - return "Deploy Governor OZ contract"; + return "Deploy OZ Governor contract"; } function deploy() public override { // Get proposer and executor addresses address dev = addresses.getAddress("DEPLOYER_EOA"); - if (!addresses.isAddressSet("GOVERNOR_OZ_TIMELOCK")) { + if (!addresses.isAddressSet("OZ_GOVERNOR_TIMELOCK")) { // Create arrays of addresses to pass to the TimelockController constructor address[] memory proposers = new address[](1); proposers[0] = dev; @@ -33,33 +33,33 @@ contract DeployGovernorOZ is MultisigProposal { // Deploy a new TimelockController TimelockController timelock = new TimelockController(60, proposers, executors, dev); - // Add GOVERNOR_OZ_TIMELOCK address - addresses.addAddress("GOVERNOR_OZ_TIMELOCK", address(timelock), true); + // Add OZ_GOVERNOR_TIMELOCK address + addresses.addAddress("OZ_GOVERNOR_TIMELOCK", address(timelock), true); } - if (!addresses.isAddressSet("GOVERNOR_OZ_GOVERNANCE_TOKEN")) { + if (!addresses.isAddressSet("OZ_GOVERNOR_GOVERNANCE_TOKEN")) { // Deploy the governance token MockERC20Votes govToken = new MockERC20Votes("Governance Token", "GOV"); govToken.mint(dev, 1e21); - // Add GOVERNOR_OZ_GOVERNANCE_TOKEN address - addresses.addAddress("GOVERNOR_OZ_GOVERNANCE_TOKEN", address(govToken), true); + // Add OZ_GOVERNOR_GOVERNANCE_TOKEN address + addresses.addAddress("OZ_GOVERNOR_GOVERNANCE_TOKEN", address(govToken), true); } - if (!addresses.isAddressSet("GOVERNOR_OZ")) { - // Deploy MockGovernorOz - MockGovernorOz governor = new MockGovernorOz( - MockERC20Votes(addresses.getAddress("GOVERNOR_OZ_GOVERNANCE_TOKEN")), // governance token - TimelockController(payable(addresses.getAddress("GOVERNOR_OZ_TIMELOCK"))) // timelock + if (!addresses.isAddressSet("OZ_GOVERNOR")) { + // Deploy MockOZGovernor + MockOZGovernor governor = new MockOZGovernor( + MockERC20Votes(addresses.getAddress("OZ_GOVERNOR_GOVERNANCE_TOKEN")), // governance token + TimelockController(payable(addresses.getAddress("OZ_GOVERNOR_TIMELOCK"))) // timelock ); - // Add GOVERNOR_OZ address - addresses.addAddress("GOVERNOR_OZ", address(governor), true); + // Add OZ_GOVERNOR address + addresses.addAddress("OZ_GOVERNOR", address(governor), true); } // add propose and execute role for governor - TimelockController(payable(addresses.getAddress("GOVERNOR_OZ_TIMELOCK"))).grantRole(keccak256("PROPOSER_ROLE"), addresses.getAddress("GOVERNOR_OZ")); + TimelockController(payable(addresses.getAddress("OZ_GOVERNOR_TIMELOCK"))).grantRole(keccak256("PROPOSER_ROLE"), addresses.getAddress("OZ_GOVERNOR")); addresses.printJSONChanges(); } @@ -71,14 +71,14 @@ contract DeployGovernorOZ is MultisigProposal { } function validate() public view override { - MockERC20Votes govToken = MockERC20Votes(addresses.getAddress("GOVERNOR_OZ_GOVERNANCE_TOKEN")); + MockERC20Votes govToken = MockERC20Votes(addresses.getAddress("OZ_GOVERNOR_GOVERNANCE_TOKEN")); // ensure governance token is minted to deployer address assertEq(govToken.balanceOf(addresses.getAddress("DEPLOYER_EOA")), 1e21); - TimelockController timelock = TimelockController(payable(addresses.getAddress("GOVERNOR_OZ_TIMELOCK"))); + TimelockController timelock = TimelockController(payable(addresses.getAddress("OZ_GOVERNOR_TIMELOCK"))); - // ensure governor oz has been granted proposer role on timelock - assertTrue(timelock.hasRole(keccak256("PROPOSER_ROLE"), addresses.getAddress("GOVERNOR_OZ"))); + // ensure OZ Governor has been granted proposer role on timelock + assertTrue(timelock.hasRole(keccak256("PROPOSER_ROLE"), addresses.getAddress("OZ_GOVERNOR"))); } } diff --git a/script/DeployTimelock.s.sol b/script/DeployTimelock.s.sol index dd1d739..04251e5 100644 --- a/script/DeployTimelock.s.sol +++ b/script/DeployTimelock.s.sol @@ -20,7 +20,7 @@ contract DeployTimelock is MultisigProposal { // Get proposer and executor addresses address dev = addresses.getAddress("DEPLOYER_EOA"); - if (!addresses.isAddressSet("GOVERNOR_OZ_GOVERNANCE_TOKEN")) { + if (!addresses.isAddressSet("OZ_GOVERNOR_GOVERNANCE_TOKEN")) { // Create arrays of addresses to pass to the TimelockController constructor address[] memory proposers = new address[](1); proposers[0] = dev; diff --git a/src/mocks/governor-oz/MockGovernorOz.sol b/src/mocks/governor-oz/MockOZGovernor.sol similarity index 98% rename from src/mocks/governor-oz/MockGovernorOz.sol rename to src/mocks/governor-oz/MockOZGovernor.sol index 3e3ba09..5855501 100644 --- a/src/mocks/governor-oz/MockGovernorOz.sol +++ b/src/mocks/governor-oz/MockOZGovernor.sol @@ -7,7 +7,7 @@ import {GovernorCountingSimple} from "@openzeppelin/governance/extensions/Govern import {GovernorVotesQuorumFraction} from "@openzeppelin/governance/extensions/GovernorVotesQuorumFraction.sol"; import {GovernorTimelockControl, TimelockController} from "@openzeppelin/governance/extensions/GovernorTimelockControl.sol"; -contract MockGovernorOz is +contract MockOZGovernor is Governor, GovernorCountingSimple, GovernorVotes, diff --git a/src/proposals/arbitrum/ArbitrumProposal.sol b/src/proposals/arbitrum/ArbitrumProposal.sol index c5d835b..4fcd6e4 100644 --- a/src/proposals/arbitrum/ArbitrumProposal.sol +++ b/src/proposals/arbitrum/ArbitrumProposal.sol @@ -4,14 +4,14 @@ pragma solidity ^0.8.0; import {Vm} from "@forge-std/Vm.sol"; import {console} from "@forge-std/console.sol"; -import {GovernorOZProposal} from "@forge-proposal-simulator/src/proposals/GovernorOZProposal.sol"; +import {OZGovernorProposal} from "@forge-proposal-simulator/src/proposals/OZGovernorProposal.sol"; import {ITimelockController} from "@forge-proposal-simulator/src/interface/ITimelockController.sol"; import {Address} from "@forge-proposal-simulator/utils/Address.sol"; import {MockArbSys} from "src/mocks/arbitrum/MockArbSys.sol"; import {MockArbOutbox} from "src/mocks/arbitrum/MockArbOutbox.sol"; -abstract contract ArbitrumProposal is GovernorOZProposal { +abstract contract ArbitrumProposal is OZGovernorProposal { using Address for address; /// @notice the target address on L1 Timelock when it's a L2 proposal @@ -166,7 +166,7 @@ abstract contract ArbitrumProposal is GovernorOZProposal { arguments[0] = callData; } - /// @notice override the GovernorOZProposal simulate function to handle + /// @notice override the OZGovernorProposal simulate function to handle /// the proposal L1 settlement function simulate() public override { // First part of Arbitrum Governance proposal path follows the OZ diff --git a/src/proposals/arbitrum/README.md b/src/proposals/arbitrum/README.md index 6933434..4b66dc9 100644 --- a/src/proposals/arbitrum/README.md +++ b/src/proposals/arbitrum/README.md @@ -45,7 +45,7 @@ Based on the Arbitrum governance documentation, the proposal creation process is ## Proposal Creation Examples Using FPS We have developed an [ArbitrumProposal.sol](./ArbitrumProposal.sol) contract -that extends the FPS GovernorOZProposal to showcase the this tool capabilities. FPS +that extends the FPS OZGovernorProposal to showcase the this tool capabilities. FPS allows the creation of declarative proposals that undergo not only code review but also integration tests simulating the entire proposal lifecycle. This includes L2 submission, L1 settlement, and execution on L1 if is the case, or on @@ -73,7 +73,7 @@ L2 if the target is an L2 contract. - `getProposalActions`: function used to generate the actions for the proposal. In this case, it generates a single action to call the ArbSys precompiled contract. This is a utility function that is used by other - functions like `simulate` and GovernorOzProposal `getCalldata`. + functions like `simulate` and OZGovernorProposal `getCalldata`. - `simulate`: this function is used to simulate the proposal lifecycle from scheduling to execution. The first part of the simulation follows the standard OZ Governor proposal path by calling `super.simulate()`. FPS leverages Foundry to simulate proposing, voting, queuing on the L2 timelock, and finally executing. Once the proposal is executed by the L2 Timelock, ArbitrumProposal simulates the L1 settlement by calling the L1 Timelock using the Bridge as the sender to schedule the proposal. Finally, the proposal is executed on L1 and if the target is an L2 contract, the calldata is retrievable from the logs and it's executed on L2, which can be either Arbitrum One or Arbitrum Nova. @@ -96,7 +96,7 @@ We have developed two examples to illustrate how an Arbitrum proposal can be cre changes. - `getCalldata`: function used to generate the calldata for submitting the proposal. It's not necessary to override this function, as it's already - implemented in the GovernorOzProposal contract. + implemented in the OZGovernorProposal contract. When running a proposal through the `forge script`, FPS calls all the functions described above in the following order: `deploy`, `build`, `simulate`, `validate`, and `getCalldata` to ensure the proposal is valid and can be submitted to the Governor. The calldata is printed to the console, and the contracts deployed in the `deploy` function can be broadcasted to the network if needed. diff --git a/src/proposals/simple-vault-governor-oz/GovernorOZProposal_01.sol b/src/proposals/simple-vault-governor-oz/OZGovernorProposal_01.sol similarity index 51% rename from src/proposals/simple-vault-governor-oz/GovernorOZProposal_01.sol rename to src/proposals/simple-vault-governor-oz/OZGovernorProposal_01.sol index 55147a3..88ed0ff 100644 --- a/src/proposals/simple-vault-governor-oz/GovernorOZProposal_01.sol +++ b/src/proposals/simple-vault-governor-oz/OZGovernorProposal_01.sol @@ -1,19 +1,19 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; -import {GovernorOZProposal} from "@forge-proposal-simulator/src/proposals/GovernorOZProposal.sol"; +import {OZGovernorProposal} from "@forge-proposal-simulator/src/proposals/OZGovernorProposal.sol"; import {Addresses} from "@forge-proposal-simulator/addresses/Addresses.sol"; import {Vault} from "src/mocks/vault/Vault.sol"; import {Token} from "src/mocks/vault/Token.sol"; -contract GovernorOZProposal_01 is GovernorOZProposal { +contract OZGovernorProposal_01 is OZGovernorProposal { function name() public pure override returns (string memory) { - return "GOVERNOR_OZ_PROPOSAL"; + return "OZ_GOVERNOR_PROPOSAL"; } function description() public pure override returns (string memory) { - return "Governor oz proposal mock 1"; + return "OZ Governor proposal mock 1"; } function run() public override { @@ -25,23 +25,23 @@ contract GovernorOZProposal_01 is GovernorOZProposal { ) ); - setGovernor(addresses.getAddress("GOVERNOR_OZ")); + setGovernor(addresses.getAddress("OZ_GOVERNOR")); super.run(); } function deploy() public override { - address owner = addresses.getAddress("GOVERNOR_OZ_TIMELOCK"); - if (!addresses.isAddressSet("GOVERNOR_OZ_VAULT")) { - Vault governorOZVault = new Vault(); + address owner = addresses.getAddress("OZ_GOVERNOR_TIMELOCK"); + if (!addresses.isAddressSet("OZ_GOVERNOR_VAULT")) { + Vault ozGovernorVault = new Vault(); - addresses.addAddress("GOVERNOR_OZ_VAULT", address(governorOZVault), true); - governorOZVault.transferOwnership(owner); + addresses.addAddress("OZ_GOVERNOR_VAULT", address(ozGovernorVault), true); + ozGovernorVault.transferOwnership(owner); } - if (!addresses.isAddressSet("GOVERNOR_OZ_VAULT_TOKEN")) { + if (!addresses.isAddressSet("OZ_GOVERNOR_VAULT_TOKEN")) { Token token = new Token(); - addresses.addAddress("GOVERNOR_OZ_VAULT_TOKEN", address(token), true); + addresses.addAddress("OZ_GOVERNOR_VAULT_TOKEN", address(token), true); token.transferOwnership(owner); // During forge script execution, the deployer of the contracts is @@ -57,44 +57,44 @@ contract GovernorOZProposal_01 is GovernorOZProposal { function build() public override - buildModifier(addresses.getAddress("GOVERNOR_OZ_TIMELOCK")) + buildModifier(addresses.getAddress("OZ_GOVERNOR_TIMELOCK")) { /// STATICCALL -- not recorded for the run stage - address governorOZVault = addresses.getAddress("GOVERNOR_OZ_VAULT"); - address token = addresses.getAddress("GOVERNOR_OZ_VAULT_TOKEN"); + address ozGovernorVault = addresses.getAddress("OZ_GOVERNOR_VAULT"); + address token = addresses.getAddress("OZ_GOVERNOR_VAULT_TOKEN"); uint256 balance = Token(token).balanceOf( - addresses.getAddress("GOVERNOR_OZ_TIMELOCK") + addresses.getAddress("OZ_GOVERNOR_TIMELOCK") ); /// CALLS -- mutative and recorded - Vault(governorOZVault).whitelistToken(token, true); - Token(token).approve(governorOZVault, balance); - Vault(governorOZVault).deposit(token, balance); + Vault(ozGovernorVault).whitelistToken(token, true); + Token(token).approve(ozGovernorVault, balance); + Vault(ozGovernorVault).deposit(token, balance); } function validate() public view override { - Vault governorOZVault = Vault(addresses.getAddress("GOVERNOR_OZ_VAULT")); - Token token = Token(addresses.getAddress("GOVERNOR_OZ_VAULT_TOKEN")); + Vault ozGovernorVault = Vault(addresses.getAddress("OZ_GOVERNOR_VAULT")); + Token token = Token(addresses.getAddress("OZ_GOVERNOR_VAULT_TOKEN")); - address timelock = addresses.getAddress("GOVERNOR_OZ_TIMELOCK"); + address timelock = addresses.getAddress("OZ_GOVERNOR_TIMELOCK"); - uint256 balance = token.balanceOf(address(governorOZVault)); - (uint256 amount, ) = governorOZVault.deposits( + uint256 balance = token.balanceOf(address(ozGovernorVault)); + (uint256 amount, ) = ozGovernorVault.deposits( address(token), address(timelock) ); assertEq(amount, balance); - assertTrue(governorOZVault.tokenWhitelist(address(token))); + assertTrue(ozGovernorVault.tokenWhitelist(address(token))); - assertEq(token.balanceOf(address(governorOZVault)), token.totalSupply()); + assertEq(token.balanceOf(address(ozGovernorVault)), token.totalSupply()); assertEq(token.totalSupply(), 10_000_000e18); assertEq(token.owner(), address(timelock)); - assertEq(governorOZVault.owner(), address(timelock)); + assertEq(ozGovernorVault.owner(), address(timelock)); - assertFalse(governorOZVault.paused()); + assertFalse(ozGovernorVault.paused()); } } diff --git a/src/proposals/simple-vault-governor-oz/GovernorOZProposal_02.sol b/src/proposals/simple-vault-governor-oz/OZGovernorProposal_02.sol similarity index 53% rename from src/proposals/simple-vault-governor-oz/GovernorOZProposal_02.sol rename to src/proposals/simple-vault-governor-oz/OZGovernorProposal_02.sol index 799bf17..3a1434f 100644 --- a/src/proposals/simple-vault-governor-oz/GovernorOZProposal_02.sol +++ b/src/proposals/simple-vault-governor-oz/OZGovernorProposal_02.sol @@ -1,19 +1,19 @@ // SPDX-License-Identifier: GPL-3.0-or-later pragma solidity ^0.8.0; -import {GovernorOZProposal} from "@forge-proposal-simulator/src/proposals/GovernorOZProposal.sol"; +import {OZGovernorProposal} from "@forge-proposal-simulator/src/proposals/OZGovernorProposal.sol"; import {Addresses} from "@forge-proposal-simulator/addresses/Addresses.sol"; import {Vault} from "src/mocks/vault/Vault.sol"; import {Token} from "src/mocks/vault/Token.sol"; -contract GovernorOZProposal_02 is GovernorOZProposal { +contract OZGovernorProposal_02 is OZGovernorProposal { function name() public pure override returns (string memory) { - return "GOVERNOR_OZ_PROPOSAL_02"; + return "OZ_GOVERNOR_PROPOSAL_02"; } function description() public pure override returns (string memory) { - return "Governor oz proposal mock 2"; + return "OZ Governor proposal mock 2"; } function run() public override { @@ -25,7 +25,7 @@ contract GovernorOZProposal_02 is GovernorOZProposal { ) ); - setGovernor(addresses.getAddress("GOVERNOR_OZ")); + setGovernor(addresses.getAddress("OZ_GOVERNOR")); super.run(); } @@ -33,28 +33,28 @@ contract GovernorOZProposal_02 is GovernorOZProposal { function build() public override - buildModifier(addresses.getAddress("GOVERNOR_OZ_TIMELOCK")) + buildModifier(addresses.getAddress("OZ_GOVERNOR_TIMELOCK")) { /// STATICCALL -- not recorded for the run stage - address timelock = addresses.getAddress("GOVERNOR_OZ_TIMELOCK"); - Vault governorOZVault = Vault(addresses.getAddress("GOVERNOR_OZ_VAULT")); - address token = addresses.getAddress("GOVERNOR_OZ_VAULT_TOKEN"); - (uint256 amount, ) = governorOZVault.deposits(address(token), timelock); + address timelock = addresses.getAddress("OZ_GOVERNOR_TIMELOCK"); + Vault ozGovernorVault = Vault(addresses.getAddress("OZ_GOVERNOR_VAULT")); + address token = addresses.getAddress("OZ_GOVERNOR_VAULT_TOKEN"); + (uint256 amount, ) = ozGovernorVault.deposits(address(token), timelock); /// CALLS -- mutative and recorded - governorOZVault.withdraw(token, payable(timelock), amount); + ozGovernorVault.withdraw(token, payable(timelock), amount); } function validate() public view override { - Vault governorOZVault = Vault(addresses.getAddress("GOVERNOR_OZ_VAULT")); - Token token = Token(addresses.getAddress("GOVERNOR_OZ_VAULT_TOKEN")); + Vault ozGovernorVault = Vault(addresses.getAddress("OZ_GOVERNOR_VAULT")); + Token token = Token(addresses.getAddress("OZ_GOVERNOR_VAULT_TOKEN")); - address timelock = addresses.getAddress("GOVERNOR_OZ_TIMELOCK"); + address timelock = addresses.getAddress("OZ_GOVERNOR_TIMELOCK"); - uint256 balance = token.balanceOf(address(governorOZVault)); + uint256 balance = token.balanceOf(address(ozGovernorVault)); assertEq(balance, 0); - (uint256 amount, ) = governorOZVault.deposits( + (uint256 amount, ) = ozGovernorVault.deposits( address(token), address(timelock) ); diff --git a/test/governor-oz/GovernorOZVaultIntegrationTestSepolia.sol b/test/governor-oz/GovernorOZVaultIntegrationTestSepolia.sol deleted file mode 100644 index 1fa1d65..0000000 --- a/test/governor-oz/GovernorOZVaultIntegrationTestSepolia.sol +++ /dev/null @@ -1,44 +0,0 @@ -pragma solidity ^0.8.0; - -import {Vault} from "src/mocks/vault/Vault.sol"; -import {Token} from "src/mocks/vault/Token.sol"; -import {GovernorOZPostProposalCheck} from "./GovernorOZPostProposalCheck.sol"; - -// @dev This test contract extends GovernorOZPostProposalCheck, granting it -// the ability to interact with state modifications effected by proposals -// and to work with newly deployed contracts, if applicable. -contract GovernorOZVaultIntegrationTestSepolia is GovernorOZPostProposalCheck { - function test_addTokenToWhitelist() public { - Vault governorOZVault = Vault(addresses.getAddress("GOVERNOR_OZ_VAULT")); - address governorOZTimelock = addresses.getAddress("GOVERNOR_OZ_TIMELOCK"); - Token token = new Token(); - - vm.prank(governorOZTimelock); - - governorOZVault.whitelistToken(address(token), true); - - assertTrue( - governorOZVault.tokenWhitelist(address(token)), - "Token should be whitelisted" - ); - } - - function test_depositToVault() public { - Vault governorOZVault = Vault(addresses.getAddress("GOVERNOR_OZ_VAULT")); - address governorOZTimelock = addresses.getAddress("GOVERNOR_OZ_TIMELOCK"); - address governanceToken = addresses.getAddress("GOVERNOR_OZ_VAULT_TOKEN"); - (uint256 prevDeposit, ) = governorOZVault.deposits(governanceToken, governorOZTimelock); - uint256 depositAmount = 100; - - vm.startPrank(governorOZTimelock); - Token(governanceToken).mint(governorOZTimelock, depositAmount); - Token(governanceToken).approve(address(governorOZVault), depositAmount); - governorOZVault.deposit(address(governanceToken), depositAmount); - - (uint256 amount, ) = governorOZVault.deposits(governanceToken, governorOZTimelock); - assertTrue( - amount == (prevDeposit + depositAmount), - "Token should be deposited" - ); - } -} diff --git a/test/governor-oz/GovernorOZPostProposalCheck.sol b/test/governor-oz/OZGovernorPostProposalCheck.sol similarity index 61% rename from test/governor-oz/GovernorOZPostProposalCheck.sol rename to test/governor-oz/OZGovernorPostProposalCheck.sol index 2f34052..6973b47 100644 --- a/test/governor-oz/GovernorOZPostProposalCheck.sol +++ b/test/governor-oz/OZGovernorPostProposalCheck.sol @@ -3,29 +3,29 @@ pragma solidity ^0.8.0; import "@forge-std/Test.sol"; import {Addresses} from "@forge-proposal-simulator/addresses/Addresses.sol"; -import {GovernorOZProposal} from "@forge-proposal-simulator/src/proposals/GovernorOZProposal.sol"; +import {OZGovernorProposal} from "@forge-proposal-simulator/src/proposals/OZGovernorProposal.sol"; // @notice this is a helper contract to execute proposals before running integration tests. // @dev should be inherited by integration test contracts. -contract GovernorOZPostProposalCheck is Test { +contract OZGovernorPostProposalCheck is Test { Addresses public addresses; function setUp() public { string[] memory inputs = new string[](2); inputs[0] = "./get-latest-proposal.sh"; - inputs[1] = "GovernorOZProposal"; + inputs[1] = "OZGovernorProposal"; string memory output = string(vm.ffi(inputs)); - GovernorOZProposal governorOZproposal = GovernorOZProposal( + OZGovernorProposal ozGovernorproposal = OZGovernorProposal( deployCode(output) ); - vm.makePersistent(address(governorOZproposal)); + vm.makePersistent(address(ozGovernorproposal)); // Execute proposals - governorOZproposal.run(); + ozGovernorproposal.run(); // Get the addresses contract - addresses = governorOZproposal.addresses(); + addresses = ozGovernorproposal.addresses(); } } diff --git a/test/governor-oz/OZGovernorVaultIntegrationTestSepolia.sol b/test/governor-oz/OZGovernorVaultIntegrationTestSepolia.sol new file mode 100644 index 0000000..8420d17 --- /dev/null +++ b/test/governor-oz/OZGovernorVaultIntegrationTestSepolia.sol @@ -0,0 +1,44 @@ +pragma solidity ^0.8.0; + +import {Vault} from "src/mocks/vault/Vault.sol"; +import {Token} from "src/mocks/vault/Token.sol"; +import {OZGovernorPostProposalCheck} from "./OZGovernorPostProposalCheck.sol"; + +// @dev This test contract extends OZGovernorPostProposalCheck, granting it +// the ability to interact with state modifications effected by proposals +// and to work with newly deployed contracts, if applicable. +contract OZGovernorVaultIntegrationTestSepolia is OZGovernorPostProposalCheck { + function test_addTokenToWhitelist() public { + Vault ozGovernorVault = Vault(addresses.getAddress("OZ_GOVERNOR_VAULT")); + address ozGovernorTimelock = addresses.getAddress("OZ_GOVERNOR_TIMELOCK"); + Token token = new Token(); + + vm.prank(ozGovernorTimelock); + + ozGovernorVault.whitelistToken(address(token), true); + + assertTrue( + ozGovernorVault.tokenWhitelist(address(token)), + "Token should be whitelisted" + ); + } + + function test_depositToVault() public { + Vault ozGovernorVault = Vault(addresses.getAddress("OZ_GOVERNOR_VAULT")); + address ozGovernorTimelock = addresses.getAddress("OZ_GOVERNOR_TIMELOCK"); + address governanceToken = addresses.getAddress("OZ_GOVERNOR_VAULT_TOKEN"); + (uint256 prevDeposit, ) = ozGovernorVault.deposits(governanceToken, ozGovernorTimelock); + uint256 depositAmount = 100; + + vm.startPrank(ozGovernorTimelock); + Token(governanceToken).mint(ozGovernorTimelock, depositAmount); + Token(governanceToken).approve(address(ozGovernorVault), depositAmount); + ozGovernorVault.deposit(address(governanceToken), depositAmount); + + (uint256 amount, ) = ozGovernorVault.deposits(governanceToken, ozGovernorTimelock); + assertTrue( + amount == (prevDeposit + depositAmount), + "Token should be deposited" + ); + } +}