Create proposal & tests
This commit is contained in:
parent
0605d229f5
commit
04654f22b3
1
lib/forge-std
Submodule
1
lib/forge-std
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 75f1746c949ae56377611e5f2128aa93d381431f
|
@ -7,7 +7,7 @@
|
|||||||
"private": false,
|
"private": false,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"init": "cd lib && git clone --recurse-submodules https://github.com/foundry-rs/forge-std",
|
"init": "cd lib && git clone --recurse-submodules https://github.com/foundry-rs/forge-std",
|
||||||
"test:windows": ".\\.env.bat && forge test",
|
"test:windows": ".\\.env.bat && forge test --gas-report",
|
||||||
"test:linux": "source .env && forge test"
|
"test:linux": "source .env && forge test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
pragma solidity ^0.8.19;
|
|
||||||
|
|
||||||
import { IGovernance } from "@interfaces/IGovernance.sol";
|
|
||||||
|
|
||||||
contract ExampleProposal {
|
|
||||||
function executeProposal() public {
|
|
||||||
/* ... */
|
|
||||||
}
|
|
||||||
}
|
|
15
src/PaidListingProposal.sol
Normal file
15
src/PaidListingProposal.sol
Normal file
@ -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 { }
|
|
||||||
}
|
|
38
test/PaidListingProposal.t.sol
Normal file
38
test/PaidListingProposal.t.sol
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user