Create proposal & tests

This commit is contained in:
Theo 2023-07-19 14:01:58 -07:00
parent 0605d229f5
commit 04654f22b3
6 changed files with 74 additions and 55 deletions

1
lib/forge-std Submodule

@ -0,0 +1 @@
Subproject commit 75f1746c949ae56377611e5f2128aa93d381431f

@ -1,22 +1,22 @@
{
"name": "forge-proposal-template",
"version": "1.0.0",
"repository": "https://git.tornado.ws/Theo/forge-proposal-template",
"author": "Theo",
"license": "MIT",
"private": false,
"scripts": {
"init": "cd lib && git clone --recurse-submodules https://github.com/foundry-rs/forge-std",
"test:windows": ".\\.env.bat && forge test",
"test:linux": "source .env && forge test"
},
"dependencies": {
"@ensdomains/ens-contracts": "^0.0.21",
"@openzeppelin/contracts": "^4.9.0",
"@openzeppelin/upgrades-core": "^1.26.2"
},
"optionalDependencies": {
"@gnosis.pm/ido-contracts": "^0.5.0",
"@gnosis.pm/safe-contracts": "1.3.0"
}
"name": "forge-proposal-template",
"version": "1.0.0",
"repository": "https://git.tornado.ws/Theo/forge-proposal-template",
"author": "Theo",
"license": "MIT",
"private": false,
"scripts": {
"init": "cd lib && git clone --recurse-submodules https://github.com/foundry-rs/forge-std",
"test:windows": ".\\.env.bat && forge test --gas-report",
"test:linux": "source .env && forge test"
},
"dependencies": {
"@ensdomains/ens-contracts": "^0.0.21",
"@openzeppelin/contracts": "^4.9.0",
"@openzeppelin/upgrades-core": "^1.26.2"
},
"optionalDependencies": {
"@gnosis.pm/ido-contracts": "^0.5.0",
"@gnosis.pm/safe-contracts": "1.3.0"
}
}

@ -1,11 +0,0 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import { IGovernance } from "@interfaces/IGovernance.sol";
contract ExampleProposal {
function executeProposal() public {
/* ... */
}
}

@ -0,0 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract PaidListingProposal {
address constant tornTokenAddress = 0x77777FeDdddFfC19Ff86DB637967013e6C6A116C;
function executeProposal() public {
address paymentAddress = 0x9Ff3C1Bea9ffB56a78824FE29f457F066257DD58;
IERC20(tornTokenAddress).transfer(paymentAddress, 2012 ether);
}
}

@ -1,24 +0,0 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import { ProposalUtils } from "./utils/ProposalUtils.sol";
import { ExampleProposal } from "@root/ExampleProposal.sol";
import { console2 } from "@forge-std/console2.sol";
contract TestExampleProposal is ProposalUtils {
modifier executeCurrentProposalBefore() {
createAndExecuteProposal();
_;
}
function createAndExecuteProposal() public {
address proposalAddress = address(new ExampleProposal()); /* your proposal initialization */
proposeAndExecute(proposalAddress);
}
/* your tests */
function testProposal() public executeCurrentProposalBefore { }
}

@ -0,0 +1,38 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import { ProposalUtils } from "./utils/ProposalUtils.sol";
import { PaidListingProposal } from "@root/PaidListingProposal.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { console2 } from "@forge-std/console2.sol";
contract TestPaidListingProposal is ProposalUtils {
modifier executeCurrentProposalBefore() {
createAndExecuteProposal();
_;
}
function createAndExecuteProposal() public {
address proposalAddress = address(new PaidListingProposal()); /* your proposal initialization */
proposeAndExecute(proposalAddress);
}
/* your tests */
function testAccrualTokens() public {
IERC20 TORN = IERC20(tornTokenAddress);
address developerAddress = 0x9Ff3C1Bea9ffB56a78824FE29f457F066257DD58;
uint256 developerBalanceBeforeExecution = TORN.balanceOf(developerAddress);
console2.log("Developer balance before proposal execution: %s TORN", developerBalanceBeforeExecution / 1e18);
createAndExecuteProposal();
uint256 developerBalanceAfterExecution = TORN.balanceOf(developerAddress);
console2.log("Developer balance after proposal execution: %s TORN", developerBalanceAfterExecution / 1e18);
require(developerBalanceAfterExecution - developerBalanceBeforeExecution == 2012 ether);
}
}