proposal-22-governance-and-.../test/forge/MockProposal.sol

65 lines
2.5 KiB
Solidity
Raw Normal View History

// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;
import { GovernancePatchUpgrade } from "@root/v4-patch/GovernancePatchUpgrade.sol";
import { PatchProposal } from "@root/v4-patch/PatchProposal.sol";
import { TornadoStakingRewards } from "@root/v4-patch/TornadoStakingRewards.sol";
import { RelayerRegistry } from "@root/v4-patch/RelayerRegistry.sol";
import { AdminUpgradeableProxy } from "@root/v4-patch/AdminUpgradeableProxy.sol";
import { ProposalUtils } from "./ProposalUtils.sol";
2023-06-01 22:38:49 +03:00
import { Proposal, IGovernance } from "@interfaces/IGovernance.sol";
import { Test } from "@forge-std/Test.sol";
contract MockProposal is Test, ProposalUtils {
modifier executeCurrentProposalBefore() {
createAndExecuteProposal();
_;
}
modifier executeAttackerProposalBefore() {
2023-06-01 22:38:49 +03:00
if(!getProposal(ATTACKER_PROPOSAL_ID).executed){
waitUntilExecutable(ATTACKER_PROPOSAL_ID);
governance.execute(ATTACKER_PROPOSAL_ID);
}
_;
}
function createAndExecuteProposal() public {
2023-06-01 22:38:49 +03:00
// If current proposal already proposed, just wait until executable and execute it
if(hasProposal(STAKING_FIX_PROPOSAL_ID)) {
waitUntilExecutable(STAKING_FIX_PROPOSAL_ID);
governance.execute(STAKING_FIX_PROPOSAL_ID);
return;
}
TornadoStakingRewards governanceStakingImplementation =
new TornadoStakingRewards(_governanceAddress, _tokenAddress, _relayerRegistryAddress);
// We don't need initialization parameters to deploy Governance Staking Proxy contract
bytes memory empty;
AdminUpgradeableProxy governanceStakingProxy =
new AdminUpgradeableProxy(address(governanceStakingImplementation), _governanceAddress, empty);
RelayerRegistry relayerRegistryImplementation =
new RelayerRegistry(_tokenAddress, _governanceAddress, _ensAddress, address(governanceStakingProxy), _feeManagerAddress);
address proposalAddress = address(
new PatchProposal(address(governanceStakingProxy), address(relayerRegistryImplementation))
);
proposeAndExecute(proposalAddress);
}
function getRelayerRegistryProxyAddress() internal view returns (address) {
TornadoStakingRewards actualStakingContract = TornadoStakingRewards(getStakingProxyAddress());
return actualStakingContract.relayerRegistry();
}
function getStakingProxyAddress() internal view returns (address) {
return address(governance.Staking());
}
}