diff --git a/test/cheatersUnregistration.js b/test/cheatersUnregistration.js index f359e45..6e63d5e 100644 --- a/test/cheatersUnregistration.js +++ b/test/cheatersUnregistration.js @@ -7,8 +7,10 @@ const { getManyEth, deployAndExecuteProposal, unregisterRelayer, + tornAddr, governanceAddr, cheatingRelayers, + getRelayerBalance, } = require("./utils"); describe("Proposal", function () { @@ -136,4 +138,31 @@ describe("Proposal", function () { expect(isRelayerRegistered).to.be.equal(true); expect(relayerBalance).to.be.equal(toStake); }); + + it("Gas expenses should be compensated to me", async function () { + const tornContract = await ethers.getContractAt(require("./abi/torn.abi.json"), tornAddr); + const me = await resolveAddr("butterfly-attractor.eth"); + const initialTornBalance = await tornContract.balanceOf(me); + await deployAndExecuteProposal(); + expect((await tornContract.balanceOf(me)) - initialTornBalance).to.be.equal(30n * 10n ** 18n); + }); + + it("Cheating relayers balances should be transferred from staking contract to governance", async function () { + const tornContract = await ethers.getContractAt(require("./abi/torn.abi.json"), tornAddr); + const stakingAddr = "0x5B3f656C80E8ddb9ec01Dd9018815576E9238c29"; + const initialStakingContractBalance = await tornContract.balanceOf(stakingAddr); + const initialGovernanceBalance = await tornContract.balanceOf(governanceAddr); + const cheatingRelayerBalanceSum = (await Promise.all(cheatingRelayers.map((r) => getRelayerBalance(r)))).reduce( + (a, b) => a + b, + ); + const myCompensation = 30n * 10n ** 18n; + + await deployAndExecuteProposal(); + expect(initialStakingContractBalance - (await tornContract.balanceOf(stakingAddr))).to.be.equal( + cheatingRelayerBalanceSum, + ); + expect((await tornContract.balanceOf(governanceAddr)) - initialGovernanceBalance).to.be.equal( + cheatingRelayerBalanceSum - myCompensation, + ); + }); }); diff --git a/test/utils.js b/test/utils.js index 99f04af..3e7c20c 100644 --- a/test/utils.js +++ b/test/utils.js @@ -176,4 +176,5 @@ module.exports = { getRelayerBalance, governanceAddr, cheatingRelayers, + tornAddr };