proposal-22-governance-and-.../test/TestContractsState.sol

69 lines
3.8 KiB
Solidity
Raw Normal View History

// SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
pragma experimental ABIEncoderV2;
import { MockProposal } from "./MockProposal.sol";
import { console2 } from "@forge-std/console2.sol";
import { GovernancePatchUpgrade } from "@root/v4-patch/GovernancePatchUpgrade.sol";
import { RelayerRegistry } from "@root/v4-patch/RelayerRegistry.sol";
import { TornadoStakingRewards } from "@root/v4-patch/TornadoStakingRewards.sol";
contract TestContractsState is MockProposal {
function testLockedBalanceSaved() public {
uint256 lockedBalanceBeforeExecution = governance.lockedBalance(TEST_REAL_ADDRESS_WITH_BALANCE);
console2.log("User locked balance before execution: %s TORN", lockedBalanceBeforeExecution / 10 ** 18);
createAndExecuteProposal();
uint256 lockedBalanceAfterExecution = governance.lockedBalance(TEST_REAL_ADDRESS_WITH_BALANCE);
console2.log("User locked balance before execution: %s TORN", lockedBalanceAfterExecution / 10 ** 18);
require(lockedBalanceBeforeExecution == lockedBalanceAfterExecution, "Wrong locked balance after execution");
}
function testGovernanceStakingStateChanged() public {
TornadoStakingRewards oldStaking = TornadoStakingRewards(getStakingProxyAddress());
uint256 accumulatedRewardsBeforeExecution = oldStaking.checkReward(TEST_REAL_ADDRESS_WITH_BALANCE);
console2.log("User rewards balance (bugged) before execution: %s TORN", accumulatedRewardsBeforeExecution / 10 ** 18);
console2.log("Bugged value of accumulated rewards per TORN: %s", oldStaking.accumulatedRewardPerTorn());
createAndExecuteProposal();
TornadoStakingRewards newStaking = TornadoStakingRewards(getStakingProxyAddress());
uint256 accumulatedRewardsPerTORNAfterExecution = newStaking.accumulatedRewardPerTorn();
uint256 accumulatedRewardsAfterExecution = newStaking.checkReward(TEST_REAL_ADDRESS_WITH_BALANCE);
console2.log("User rewards balance before execution: %s TORN", accumulatedRewardsAfterExecution / 10 ** 18);
console2.log("Value of accumulated rewards per TORN after contract redeployment: %s", accumulatedRewardsPerTORNAfterExecution);
require(accumulatedRewardsBeforeExecution >= accumulatedRewardsAfterExecution, "Wtf");
require(accumulatedRewardsAfterExecution == 0, "Accumulated rewards isn't nullified");
require(accumulatedRewardsPerTORNAfterExecution == 0, "Accumulated rewards per TORN isn't nullified");
}
function testRelayerRegistryStateSaved() public {
RelayerRegistry registry = RelayerRegistry(getRelayerRegistryProxyAddress());
bool isRelayerRegisteredBeforeExecution = registry.isRelayer(TEST_RELAYER_ADDRESS);
uint256 relayerStakedBalanceBeforeExecution = registry.getRelayerBalance(TEST_RELAYER_ADDRESS);
console2.log(
"Relayer balance in relayer registry contract before proposal execution: %s TORN",
relayerStakedBalanceBeforeExecution / 10 ** 18
);
require(isRelayerRegisteredBeforeExecution, "Relayer not registered");
createAndExecuteProposal();
bool isRelayerRegisteredAfterExecution = registry.isRelayer(TEST_RELAYER_ADDRESS);
uint256 relayerStakedBalanceAfterExecution = registry.getRelayerBalance(TEST_RELAYER_ADDRESS);
console2.log(
"Relayer balance in relayer registry contract after proposal execution: %s TORN", relayerStakedBalanceAfterExecution / 10 ** 18
);
require(isRelayerRegisteredAfterExecution, "Relayer isn't registered after proposal execution");
require(relayerStakedBalanceBeforeExecution == relayerStakedBalanceAfterExecution, "Relayer stake balance differs after execution");
}
}