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 =
|
TornadoStakingRewards governanceStakingImplementation =
|
||||||
new TornadoStakingRewards(_governanceAddress, _tokenAddress, _relayerRegistryAddress);
|
new TornadoStakingRewards(_governanceAddress, _tokenAddress, _relayerRegistryAddress);
|
||||||
|
|
||||||
RestoreRewardsProposal proposal = new RestoreRewardsProposal(address(governanceStakingImplementation));
|
RestoreRewardsProposal proposal = new RestoreRewardsProposal(address(governanceStakingImplementation));
|
||||||
|
|
||||||
uint256 proposalId = proposeAndVote(address(proposal));
|
proposeAndExecute(address(proposal));
|
||||||
|
|
||||||
return proposalId;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createAndExecuteProposal() public {
|
|
||||||
uint256 proposalId = createAndVoteProposal();
|
|
||||||
|
|
||||||
waitUntilExecutable(proposalId);
|
|
||||||
IGovernance(_governanceAddress).execute(proposalId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,12 @@ contract TestProposal is MockProposal {
|
|||||||
|
|
||||||
function testOtherUsersRewardUnchanged() public {
|
function testOtherUsersRewardUnchanged() public {
|
||||||
uint256 rewardsBeforeProposal = staking.checkReward(TEST_REAL_ADDRESS_WITH_BALANCE);
|
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();
|
createAndExecuteProposal();
|
||||||
|
|
||||||
uint256 rewardsAfterProposal = staking.checkReward(TEST_REAL_ADDRESS_WITH_BALANCE);
|
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");
|
require(rewardsAfterProposal == rewardsBeforeProposal, "Other stakers rewards changed");
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ pragma experimental ABIEncoderV2;
|
|||||||
import { Utils } from "./Utils.sol";
|
import { Utils } from "./Utils.sol";
|
||||||
import { Proposal, IGovernance } from "./interfaces/IGovernance.sol";
|
import { Proposal, IGovernance } from "./interfaces/IGovernance.sol";
|
||||||
|
|
||||||
|
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||||
|
|
||||||
contract ProposalUtils is Utils {
|
contract ProposalUtils is Utils {
|
||||||
IGovernance internal governance = IGovernance(payable(_governanceAddress));
|
IGovernance internal governance = IGovernance(payable(_governanceAddress));
|
||||||
|
|
||||||
@ -29,8 +31,7 @@ contract ProposalUtils is Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function proposeAndVote(address proposalAddress) public returns (uint256) {
|
function proposeAndVote(address proposalAddress) public returns (uint256) {
|
||||||
retrieveAndLockBalance(TEST_PRIVATE_KEY_ONE, TEST_ADDRESS_ONE, PROPOSAL_THRESHOLD);
|
retrieveAndLockBalance(TEST_PRIVATE_KEY_ONE, TEST_ADDRESS_ONE, PROPOSAL_THRESHOLD + 1 ether);
|
||||||
retrieveAndLockBalance(TEST_PRIVATE_KEY_TWO, TEST_ADDRESS_TWO, 1 ether);
|
|
||||||
|
|
||||||
/* ----------PROPOSER------------ */
|
/* ----------PROPOSER------------ */
|
||||||
vm.startPrank(TEST_ADDRESS_ONE);
|
vm.startPrank(TEST_ADDRESS_ONE);
|
||||||
@ -45,12 +46,6 @@ contract ProposalUtils is Utils {
|
|||||||
vm.stopPrank();
|
vm.stopPrank();
|
||||||
/* ------------------------------ */
|
/* ------------------------------ */
|
||||||
|
|
||||||
/* -------------VOTER-------------*/
|
|
||||||
vm.startPrank(TEST_ADDRESS_TWO);
|
|
||||||
governance.castVote(proposalId, true);
|
|
||||||
vm.stopPrank();
|
|
||||||
/* ------------------------------ */
|
|
||||||
|
|
||||||
return proposalId;
|
return proposalId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,5 +54,23 @@ contract ProposalUtils is Utils {
|
|||||||
|
|
||||||
waitUntilExecutable(proposalId);
|
waitUntilExecutable(proposalId);
|
||||||
IGovernance(_governanceAddress).execute(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