more tests

This commit is contained in:
ButterflyEffect 2023-11-10 17:08:36 +00:00
parent 79944ff21e
commit 4054debf98
2 changed files with 30 additions and 0 deletions

@ -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,
);
});
});

@ -176,4 +176,5 @@ module.exports = {
getRelayerBalance,
governanceAddr,
cheatingRelayers,
tornAddr
};