57 lines
2.2 KiB
Solidity
57 lines
2.2 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.19;
|
|
|
|
import { ProposalUtils } from "./utils/ProposalUtils.sol";
|
|
import { RelayerCompensationProposal } from "@root/RelayerCompensationProposal.sol";
|
|
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
|
|
import { console2 } from "@forge-std/console2.sol";
|
|
|
|
contract TestExampleProposal is ProposalUtils, RelayerCompensationProposal {
|
|
modifier executeCurrentProposalBefore() {
|
|
createAndExecuteProposal();
|
|
_;
|
|
}
|
|
|
|
function createAndExecuteProposal() public {
|
|
address proposalAddress = address(new RelayerCompensationProposal());
|
|
|
|
proposeAndExecute(proposalAddress);
|
|
}
|
|
|
|
function getRelayerLosses() internal pure returns (RelayerLoss[4] memory) {
|
|
return [
|
|
RelayerLoss(0x864DF9CD806D58341f13602103Bf853066ff962a, 625_894_225_496_155_734_516),
|
|
RelayerLoss(0x5555555731006f71f121144534Ca7C8799F66AA3, 43_970_301_082_908_267_318),
|
|
RelayerLoss(0x2Ee39Ff05643bC7cc9ed31B71e142429044A425C, 189_640_345_451_160_934_437),
|
|
RelayerLoss(0x03392600086874456E08D2bAc104380BCdEBCfC0, 129_757_783_603_193_410_350)
|
|
];
|
|
}
|
|
|
|
function testRelayerGotCompensation() public {
|
|
RelayerLoss[4] memory relayerLosses = getRelayerLosses();
|
|
|
|
uint256[4] memory balancesBeforeProposal;
|
|
for (uint256 i = 0; i < relayerLosses.length; i++) {
|
|
balancesBeforeProposal[i] = TORN.balanceOf(relayerLosses[i].relayer);
|
|
}
|
|
|
|
createAndExecuteProposal();
|
|
|
|
for (uint256 i = 0; i < relayerLosses.length; i++) {
|
|
uint256 updatedBalance = TORN.balanceOf(relayerLosses[i].relayer);
|
|
require(balancesBeforeProposal[i] + relayerLosses[i].lostAmountInTorn == updatedBalance, "Compensation failed");
|
|
}
|
|
}
|
|
|
|
function testLossesDataIsValid() public pure {
|
|
RelayerLoss[4] memory relayerLosses = getRelayerLosses();
|
|
uint256 tornDecimals = 1e18;
|
|
|
|
require(relayerLosses[0].lostAmountInTorn / tornDecimals == 625);
|
|
require(relayerLosses[1].lostAmountInTorn / tornDecimals == 43);
|
|
require(relayerLosses[2].lostAmountInTorn / tornDecimals == 189);
|
|
require(relayerLosses[3].lostAmountInTorn / tornDecimals == 129);
|
|
}
|
|
}
|