Create proposal and tests

This commit is contained in:
Theo 2023-06-08 14:00:13 -07:00
parent d32346fba0
commit 461b1dd9f6
6 changed files with 3481 additions and 35 deletions

1
lib/forge-std Submodule

@ -0,0 +1 @@
Subproject commit b00f504daf0bdd8cf2e67973e2c86bd213cda400

3425
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

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

17
src/Proposal.sol Normal file

@ -0,0 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import { IGovernance } from "@interfaces/IGovernance.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract ReimbursementProposal {
address constant tornTokenAddress = 0x77777FeDdddFfC19Ff86DB637967013e6C6A116C;
address constant governanceAddress = 0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce;
function executeProposal() public {
address developerAddress = 0x9Ff3C1Bea9ffB56a78824FE29f457F066257DD58;
IERC20(tornTokenAddress).transfer(developerAddress, 1680 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 { }
}

38
test/Proposal.t.sol Normal file

@ -0,0 +1,38 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import { ProposalUtils } from "./utils/ProposalUtils.sol";
import { ReimbursementProposal } from "@root/Proposal.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { console2 } from "@forge-std/console2.sol";
contract TestReimbursementProposal is ProposalUtils {
modifier executeCurrentProposalBefore() {
createAndExecuteProposal();
_;
}
function createAndExecuteProposal() public {
address proposalAddress = address(new ReimbursementProposal()); /* 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 == 1680 ether);
}
}