Move tests to forge subdirectory
This commit is contained in:
parent
baf416acaf
commit
5fbeaa7a72
@ -1,5 +1,5 @@
|
|||||||
@proprietary/=src/proprietary/
|
@proprietary/=src/proprietary/
|
||||||
@interfaces/=test/interfaces/
|
@interfaces/=test/forge/interfaces/
|
||||||
@root/=src/
|
@root/=src/
|
||||||
@forge-std/=lib/forge-std/src/
|
@forge-std/=lib/forge-std/src/
|
||||||
|
|
||||||
|
47
test/forge/TestGovernanceProtection.sol
Normal file
47
test/forge/TestGovernanceProtection.sol
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity ^0.6.12;
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
import { console2 } from "@forge-std/console2.sol";
|
||||||
|
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||||
|
import { MockProposal } from "./MockProposal.sol";
|
||||||
|
import { Mock } from "./Mock.sol";
|
||||||
|
import { Parameters } from "@proprietary/Parameters.sol";
|
||||||
|
import { GovernancePatchUpgrade } from "@root/v4-patch/GovernancePatchUpgrade.sol";
|
||||||
|
|
||||||
|
contract DummyProposal is Parameters, Mock {
|
||||||
|
address private fundingAddress;
|
||||||
|
uint256 private fundingAmount;
|
||||||
|
|
||||||
|
constructor(address _fundingAddress, uint256 _fundingAmount) public {
|
||||||
|
fundingAddress = _fundingAddress;
|
||||||
|
fundingAmount = _fundingAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
function executeProposal() public {
|
||||||
|
// Easy-to-check after execution
|
||||||
|
IERC20(_tokenAddress).transfer(TEST_ADDRESS_ONE, 1_000_000 ether);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract TestGovernanceProtection is MockProposal {
|
||||||
|
function testNewDummyProposal() public executeAttackerProposalBefore executeCurrentProposalBefore {
|
||||||
|
IERC20 TORN = IERC20(_tokenAddress);
|
||||||
|
|
||||||
|
uint256 amountToTransfer = 1_000_000 ether;
|
||||||
|
|
||||||
|
uint256 testAccountBalanceBeforeDummyProposal = TORN.balanceOf(TEST_ADDRESS_ONE);
|
||||||
|
console2.log("Account balance before dummy proposal exectuion: %s TORN", testAccountBalanceBeforeDummyProposal / _tornDecimals);
|
||||||
|
|
||||||
|
vm.warp(block.timestamp + PROPOSAL_EXECUTION_MAX_DURATION);
|
||||||
|
proposeAndExecute(address(new DummyProposal(TEST_ADDRESS_ONE, amountToTransfer)));
|
||||||
|
|
||||||
|
uint256 testAccountBalanceAfterDummyProposal = TORN.balanceOf(TEST_ADDRESS_ONE);
|
||||||
|
console2.log("Account balance after dummy proposal exectuion: %s TORN", testAccountBalanceAfterDummyProposal / _tornDecimals);
|
||||||
|
|
||||||
|
require(
|
||||||
|
testAccountBalanceAfterDummyProposal - testAccountBalanceBeforeDummyProposal == amountToTransfer,
|
||||||
|
"Dummy proposal executed incorrectly"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user