Add autoreturn locked tokens to Governance from test voter
This commit is contained in:
parent
ea9b28457c
commit
808420b0d6
@ -16,21 +16,12 @@ contract MockProposal is Test, ProposalUtils {
|
||||
_;
|
||||
}
|
||||
|
||||
function createAndVoteProposal() public returns (uint256) {
|
||||
function createAndExecuteProposal() public {
|
||||
TornadoStakingRewards governanceStakingImplementation =
|
||||
new TornadoStakingRewards(_governanceAddress, _tokenAddress, _relayerRegistryAddress);
|
||||
|
||||
RestoreRewardsProposal proposal = new RestoreRewardsProposal(address(governanceStakingImplementation));
|
||||
|
||||
uint256 proposalId = proposeAndVote(address(proposal));
|
||||
|
||||
return proposalId;
|
||||
}
|
||||
|
||||
function createAndExecuteProposal() public {
|
||||
uint256 proposalId = createAndVoteProposal();
|
||||
|
||||
waitUntilExecutable(proposalId);
|
||||
IGovernance(_governanceAddress).execute(proposalId);
|
||||
proposeAndExecute(address(proposal));
|
||||
}
|
||||
}
|
||||
|
@ -27,12 +27,12 @@ contract TestProposal is MockProposal {
|
||||
|
||||
function testOtherUsersRewardUnchanged() public {
|
||||
uint256 rewardsBeforeProposal = staking.checkReward(TEST_REAL_ADDRESS_WITH_BALANCE);
|
||||
console2.log("Developer rewards before proposal execution: %s TORN", rewardsBeforeProposal);
|
||||
console2.log("Developer rewards before proposal execution: %s TORN", rewardsBeforeProposal / _tornDecimals);
|
||||
|
||||
createAndExecuteProposal();
|
||||
|
||||
uint256 rewardsAfterProposal = staking.checkReward(TEST_REAL_ADDRESS_WITH_BALANCE);
|
||||
console2.log("Developer rewards after proposal execution: %s TORN", rewardsBeforeProposal);
|
||||
console2.log("Developer rewards after proposal execution: %s TORN", rewardsBeforeProposal / _tornDecimals);
|
||||
|
||||
require(rewardsAfterProposal == rewardsBeforeProposal, "Other stakers rewards changed");
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ pragma experimental ABIEncoderV2;
|
||||
import { Utils } from "./Utils.sol";
|
||||
import { Proposal, IGovernance } from "./interfaces/IGovernance.sol";
|
||||
|
||||
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
|
||||
contract ProposalUtils is Utils {
|
||||
IGovernance internal governance = IGovernance(payable(_governanceAddress));
|
||||
|
||||
@ -29,8 +31,7 @@ contract ProposalUtils is Utils {
|
||||
}
|
||||
|
||||
function proposeAndVote(address proposalAddress) public returns (uint256) {
|
||||
retrieveAndLockBalance(TEST_PRIVATE_KEY_ONE, TEST_ADDRESS_ONE, PROPOSAL_THRESHOLD);
|
||||
retrieveAndLockBalance(TEST_PRIVATE_KEY_TWO, TEST_ADDRESS_TWO, 1 ether);
|
||||
retrieveAndLockBalance(TEST_PRIVATE_KEY_ONE, TEST_ADDRESS_ONE, PROPOSAL_THRESHOLD + 1 ether);
|
||||
|
||||
/* ----------PROPOSER------------ */
|
||||
vm.startPrank(TEST_ADDRESS_ONE);
|
||||
@ -45,12 +46,6 @@ contract ProposalUtils is Utils {
|
||||
vm.stopPrank();
|
||||
/* ------------------------------ */
|
||||
|
||||
/* -------------VOTER-------------*/
|
||||
vm.startPrank(TEST_ADDRESS_TWO);
|
||||
governance.castVote(proposalId, true);
|
||||
vm.stopPrank();
|
||||
/* ------------------------------ */
|
||||
|
||||
return proposalId;
|
||||
}
|
||||
|
||||
@ -59,5 +54,23 @@ contract ProposalUtils is Utils {
|
||||
|
||||
waitUntilExecutable(proposalId);
|
||||
IGovernance(_governanceAddress).execute(proposalId);
|
||||
|
||||
returnTokensToGovernanceAfterVoting(proposalId);
|
||||
}
|
||||
|
||||
function returnTokensToGovernanceAfterVoting(uint256 proposalId) public {
|
||||
uint256 retrievedAmount = PROPOSAL_THRESHOLD + 1 ether;
|
||||
|
||||
uint256 proposalExecutableTime = getProposalExecutableTime(proposalId);
|
||||
uint256 tokensUnlockTime = proposalExecutableTime + 4 days + 1 seconds;
|
||||
|
||||
if(block.timestamp < tokensUnlockTime) vm.warp(tokensUnlockTime);
|
||||
|
||||
vm.startPrank(TEST_ADDRESS_ONE);
|
||||
|
||||
governance.unlock(retrievedAmount);
|
||||
IERC20(_tokenAddress).transfer(_governanceAddress, retrievedAmount);
|
||||
|
||||
vm.stopPrank();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user