Compare commits
2 Commits
baf416acaf
...
bca8932686
Author | SHA1 | Date | |
---|---|---|---|
bca8932686 | |||
5fbeaa7a72 |
@ -5,7 +5,8 @@
|
|||||||
"author": "Theo",
|
"author": "Theo",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "forge test -vvv --fork-url https://rpc.mevblocker.io --fork-block-number 17336117 --no-match-contract TestRelayerBalance --gas-report",
|
"test": "forge test -vvv --fork-url https://rpc.mevblocker.io --fork-block-number 17336117 --no-match-contract TestRelayerBalance",
|
||||||
|
"testWithGas": "forge test -vvv --fork-url https://rpc.mevblocker.io --fork-block-number 17336117 --no-match-contract TestRelayerBalance --gas-report",
|
||||||
"relayerBalancesSum": "forge test -vvv --fork-url https://rpc.mevblocker.io --fork-block-number 17304722 --match-contract TestRelayerBalance --gas-report"
|
"relayerBalancesSum": "forge test -vvv --fork-url https://rpc.mevblocker.io --fork-block-number 17304722 --match-contract TestRelayerBalance --gas-report"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -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