Skip to content

Commit

Permalink
fix: broken fork tests (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
bayological authored Jul 19, 2024
1 parent 4d50c5d commit 9b6425f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
19 changes: 4 additions & 15 deletions test/Emission.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,14 @@ describe('Emission Contract', function () {
this.skip();
}

await helpers.time.increase(BigInt(timeToTravel) - elapsed - BigInt(1));
await helpers.time.increase(BigInt(timeToTravel) - elapsed);
const emissionTotalEmitteed = await emission.totalEmittedAmount();
const calculatedEmission = await emission.calculateEmission();

// Subtract the total emission already emitted from the expected emission
const totalExpectedEmission = expectedEmission - emissionTotalEmitteed;

// Add a small tolerance of 0.1%
const tolerance = (totalExpectedEmission * 1n) / 1000n;

expect(calculatedEmission).to.be.closeTo(
totalExpectedEmission,
tolerance,
);
expect(calculatedEmission).to.be.eq(totalExpectedEmission);
});
}
});
Expand Down Expand Up @@ -131,16 +125,11 @@ describe('Emission Contract', function () {
const totalExpectedEmission =
expectedEmission - emissionTotalEmittedAmount;

// Add a small tolerance of 0.1%
const tolerance = (totalExpectedEmission * 1n) / 1000n;

expect(newEmissionTotalEmittedAmount).to.be.closeTo(
expect(newEmissionTotalEmittedAmount).to.be.eq(
emissionTotalEmittedAmount + totalExpectedEmission,
tolerance,
);
expect(newMentoTokenEmittedAmount).to.be.closeTo(
expect(newMentoTokenEmittedAmount).to.be.eq(
emissionTotalEmittedAmount + totalExpectedEmission,
tolerance,
);
});
}
Expand Down
7 changes: 6 additions & 1 deletion test/Governance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ describe('Governance', function () {
// @ts-expect-error - forking doesn't exist in hre for some reason
await helpers.reset(hre.network.config.forking.url);

await setUpTestAccounts([alice, bob, charlie], true, governanceAddresses);
await setUpTestAccounts(
[alice, bob, charlie],
true,
governanceAddresses,
'100000000',
);
});

it('should transfer tokens from treasury', async function () {
Expand Down
3 changes: 2 additions & 1 deletion test/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const setUpTestAccounts = async (
accounts: HardhatEthersSigner[],
giveVotingPower: boolean,
mentoAddresses: mento.ContractAddresses,
mintAmount: string = '10000000',
): Promise<void> => {
const emissionSigner = await ethers.getImpersonatedSigner(
mentoAddresses.Emission,
Expand All @@ -54,7 +55,7 @@ export const setUpTestAccounts = async (
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ethers.provider as any,
);
const amount = ethers.parseEther('1000000');
const amount = ethers.parseEther(mintAmount);

for (const account of accounts) {
await mentoToken.connect(emissionSigner!).mint(account.address, amount);
Expand Down

0 comments on commit 9b6425f

Please sign in to comment.