Skip to content

Commit 0f7f26f

Browse files
committed
feat: baklava fork tests
1 parent 9b6425f commit 0f7f26f

File tree

8 files changed

+2766
-3410
lines changed

8 files changed

+2766
-3410
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ FRACTAL_CLIENT_ID=
22
MERKLE_PROOF=
33
AIRGRAB_TESTER=
44
AIRGRAB_TESTER_PK=
5-
RESTRICTED_COUNTRIES=
5+
RESTRICTED_COUNTRIES=
6+
DEPLOYER=

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ jobs:
3232
run: pnpm lint
3333

3434
- name: Start node & test
35-
run: pnpm test:alfajores
35+
run: pnpm test
3636
env:
3737
FRACTAL_CLIENT_ID: 'I28eze1-UTsP66nYyBDgiRrGCA7Oe6cRFkl7Gk0Gr1A'
3838
MERKLE_PROOF: ${{secrets.MERKLE_PROOF}}
3939
AIRGRAB_TESTER: ${{secrets.AIRGRAB_TESTER}}
4040
AIRGRAB_TESTER_PK: ${{secrets.AIRGRAB_TESTER_PK}}
4141
RESTRICTED_COUNTRIES: 'CD,CU,GB,IR,KP,ML,MM,SS,SY,US,YE'
42+
DEPLOYER: '0x56fd3f2bee130e9867942d0f463a16fbe49b8d81'

pnpm-lock.yaml

Lines changed: 2724 additions & 3375 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/Airgrab.test.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ describe('Airgrab', function () {
4040
// reset the fork state between tests to not pollute the state
4141
// @ts-expect-error - forking doesn't exist in hre for some reason
4242
await helpers.reset(hre.network.config.forking.url);
43-
44-
// if this chain id is mainnet skip the test.
45-
if (hre.network.config.chainId === networks.celo.chainId) {
46-
this.skip();
47-
}
4843
});
4944

5045
before(async function () {
@@ -53,6 +48,14 @@ describe('Airgrab', function () {
5348
throw new Error('Chain ID not found');
5449
}
5550

51+
// if chain is celo or baklava skip tests
52+
if (
53+
chainId === networks.celo.chainId ||
54+
chainId === networks.baklava.chainId
55+
) {
56+
this.skip();
57+
}
58+
5659
governanceAddresses = mento.addresses[chainId]!;
5760
if (!governanceAddresses) {
5861
throw new Error('Governance addresses not found for this chain');
@@ -82,6 +85,11 @@ describe('Airgrab', function () {
8285
provider as any,
8386
);
8487

88+
// if airdrop is finished skip tests
89+
if ((await airgrab.endTimestamp()) < (await helpers.time.latest())) {
90+
this.skip();
91+
}
92+
8593
console.log('\r\n======================================================');
8694
console.log('Running Airgrab tests on network with chain id:', chainId);
8795
console.log(

test/Emission.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
MentoToken,
1010
MentoToken__factory,
1111
} from '@mento-protocol/mento-core-ts';
12+
import { networks } from '../config';
1213

1314
describe('Emission Contract', function () {
1415
const { provider } = ethers;
@@ -45,6 +46,11 @@ describe('Emission Contract', function () {
4546
throw new Error('Chain ID not found');
4647
}
4748

49+
// if chain is baklava skip tests
50+
if (chainId === networks.baklava.chainId) {
51+
this.skip();
52+
}
53+
4854
governanceAddresses = mento.addresses[chainId]!;
4955
if (!governanceAddresses) {
5056
throw new Error('Governance addresses not found for this chain');

test/Governance.test.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import {
1515
TimelockController__factory,
1616
GovernanceFactory,
1717
GovernanceFactory__factory,
18-
Emission,
19-
Emission__factory,
2018
} from '@mento-protocol/mento-core-ts';
2119
import { ProxyAdmin } from '../typechain-types/@openzeppelin/contracts/proxy/transparent';
2220
import { ProxyAdmin__factory } from '../typechain-types/factories/@openzeppelin/contracts/proxy/transparent';
@@ -36,7 +34,6 @@ describe('Governance', function () {
3634
} = ethers;
3735

3836
let governanceAddresses: mento.ContractAddresses;
39-
let emission: Emission;
4037
let mentoToken: MentoToken;
4138
let locking: Locking;
4239
let governor: MentoGovernor;
@@ -410,10 +407,9 @@ describe('Governance', function () {
410407
const newLocking = await deployContract('MockLocking');
411408
const newTimelock = await deployContract('MockTimelock');
412409
const newGovernor = await deployContract('MockGovernor');
413-
const newEmission = await deployContract('MockEmission');
414410

415-
const targets = Array(4).fill(proxyAdmin.target);
416-
const values = Array(4).fill(0);
411+
const targets = Array(3).fill(proxyAdmin.target);
412+
const values = Array(3).fill(0);
417413
const calldatas = [];
418414
const description = 'Upgrade upgradable contracts';
419415

@@ -438,13 +434,6 @@ describe('Governance', function () {
438434
]),
439435
);
440436

441-
calldatas.push(
442-
proxyAdmin.interface.encodeFunctionData('upgrade', [
443-
emission.target,
444-
newEmission.target,
445-
]),
446-
);
447-
448437
// Create a proposal to upgrade contracts
449438
const proposalId = submitProposal(
450439
governanceAddresses,
@@ -472,7 +461,6 @@ describe('Governance', function () {
472461
await locking.getWeek();
473462
await timelock.getMinDelay();
474463
await governor.votingDelay();
475-
await emission.calculateEmission();
476464

477465
await governor.connect(alice)['execute(uint256)'](proposalId);
478466

@@ -486,9 +474,6 @@ describe('Governance', function () {
486474
await expect(governor.votingDelay()).to.be.revertedWith(
487475
'MockGovernor: votingDelay not implemented',
488476
);
489-
await expect(emission.calculateEmission()).to.be.revertedWith(
490-
'MockEmission: calculateEmission not implemented',
491-
);
492477
});
493478

494479
const setupEnvironment = async (): Promise<number> => {
@@ -507,12 +492,6 @@ describe('Governance', function () {
507492
throw new Error('Governance addresses not found for this chain');
508493
}
509494

510-
emission = Emission__factory.connect(
511-
governanceAddresses.Emission,
512-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
513-
provider as any,
514-
);
515-
516495
mentoToken = MentoToken__factory.connect(
517496
governanceAddresses.MentoToken,
518497
// eslint-disable-next-line @typescript-eslint/no-explicit-any

test/MentoToken.test.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ describe('Mento Token', function () {
124124

125125
it('should successfully mint when called by the Emission contract', async function () {
126126
const emissionSigner = await ethers.getImpersonatedSigner(
127-
mentoAddresses.Emission,
127+
mentoAddresses.Emission === '0xNotDeployed'
128+
? process.env.DEPLOYER!
129+
: mentoAddresses.Emission,
128130
);
129131
const [receiver] = await ethers.getSigners();
130132
const supplyBefore = await mentoToken.totalSupply();
@@ -139,7 +141,9 @@ describe('Mento Token', function () {
139141

140142
it('should allow for tokens to be transferred by anyone when unpaused', async function () {
141143
const emissionSigner = await ethers.getImpersonatedSigner(
142-
mentoAddresses.Emission,
144+
mentoAddresses.Emission === '0xNotDeployed'
145+
? process.env.DEPLOYER!
146+
: mentoAddresses.Emission,
143147
);
144148
const [bob, alice] = await ethers.getSigners();
145149
const supplyBefore = await mentoToken.totalSupply();
@@ -172,7 +176,9 @@ describe('Mento Token', function () {
172176

173177
it('should allow for tokens to be transferred by owner,locking and emission when paused', async function () {
174178
const addresses = [
175-
mentoAddresses.Emission,
179+
mentoAddresses.Emission === '0xNotDeployed'
180+
? process.env.DEPLOYER!
181+
: mentoAddresses.Emission,
176182
mentoAddresses.Locking,
177183
mentoAddresses.TimelockController,
178184
];
@@ -201,7 +207,9 @@ describe('Mento Token', function () {
201207

202208
it('should allow for tokens to be burned by anyone when unpaused', async function () {
203209
const emissionSigner = await ethers.getImpersonatedSigner(
204-
mentoAddresses.Emission,
210+
mentoAddresses.Emission === '0xNotDeployed'
211+
? process.env.DEPLOYER!
212+
: mentoAddresses.Emission,
205213
);
206214
const [bob] = await ethers.getSigners();
207215
const supplyBefore = await mentoToken.totalSupply();

test/utils/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ export const setUpTestAccounts = async (
4242
mentoAddresses: mento.ContractAddresses,
4343
mintAmount: string = '10000000',
4444
): Promise<void> => {
45+
// if the Emission contract is not deployed on a chain, emitter is deployer
4546
const emissionSigner = await ethers.getImpersonatedSigner(
46-
mentoAddresses.Emission,
47+
mentoAddresses.Emission === '0xNotDeployed'
48+
? process.env.DEPLOYER!
49+
: mentoAddresses.Emission,
4750
);
51+
4852
const mentoToken = MentoToken__factory.connect(
4953
mentoAddresses.MentoToken,
5054
// eslint-disable-next-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)