Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: baklava fork tests #26

Merged
merged 4 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ FRACTAL_CLIENT_ID=
MERKLE_PROOF=
AIRGRAB_TESTER=
AIRGRAB_TESTER_PK=
RESTRICTED_COUNTRIES=
RESTRICTED_COUNTRIES=
DEPLOYER=
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ jobs:
run: pnpm lint

- name: Start node & test
run: pnpm test:alfajores
run: pnpm test
env:
FRACTAL_CLIENT_ID: 'I28eze1-UTsP66nYyBDgiRrGCA7Oe6cRFkl7Gk0Gr1A'
MERKLE_PROOF: ${{secrets.MERKLE_PROOF}}
AIRGRAB_TESTER: ${{secrets.AIRGRAB_TESTER}}
AIRGRAB_TESTER_PK: ${{secrets.AIRGRAB_TESTER_PK}}
RESTRICTED_COUNTRIES: 'CD,CU,GB,IR,KP,ML,MM,SS,SY,US,YE'
DEPLOYER: '0x56fd3f2bee130e9867942d0f463a16fbe49b8d81'
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Mento Governance Tests

This repo contains tests to verify the Mento Protocol governance setup.
This repo contains fork tests to verify the Mento Protocol governance setup.

## Getting Started

Expand All @@ -14,9 +14,12 @@ cd governance-tests
# Install dependencies with pnpm
pnpm install

# Build the contracts, generate ts types & run typescript compiler
pnpm build
# Run the tests against celo
pnpm test

# Run the tests against alfajores
pnpm test:alfajores

# Run the tests against baklava
pnpm test:baklava
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "NETWORK=celo pnpm exec hardhat test",
"test:alfajores": "NETWORK=alfajores pnpm exec hardhat test",
"test:baklava": "NETWORK=baklava pnpm exec hardhat test",
"build": "NETWORK=alfajores hardhat compile && pnpm tsc",
"build": "NETWORK=celo hardhat compile && pnpm tsc",
"lint": "pnpm run prettier:check && pnpm run eslint:check",
"prettier:check": "prettier --config \"./.prettierrc.json\" --check \"**/*.ts\"",
"prettier": "prettier --config \"./.prettierrc.json\" --write \"**/*.ts\"",
Expand Down
6,099 changes: 2,724 additions & 3,375 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

18 changes: 13 additions & 5 deletions test/Airgrab.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ describe('Airgrab', function () {
// reset the fork state between tests to not pollute the state
// @ts-expect-error - forking doesn't exist in hre for some reason
await helpers.reset(hre.network.config.forking.url);

// if this chain id is mainnet skip the test.
if (hre.network.config.chainId === networks.celo.chainId) {
this.skip();
}
});

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

// if chain is celo or baklava skip tests
baroooo marked this conversation as resolved.
Show resolved Hide resolved
if (
chainId === networks.celo.chainId ||
chainId === networks.baklava.chainId
) {
this.skip();
}

governanceAddresses = mento.addresses[chainId]!;
if (!governanceAddresses) {
throw new Error('Governance addresses not found for this chain');
Expand Down Expand Up @@ -82,6 +85,11 @@ describe('Airgrab', function () {
provider as any,
);

// if airdrop is finished skip tests
if ((await airgrab.endTimestamp()) < (await helpers.time.latest())) {
this.skip();
}
baroooo marked this conversation as resolved.
Show resolved Hide resolved

console.log('\r\n======================================================');
console.log('Running Airgrab tests on network with chain id:', chainId);
console.log(
Expand Down
6 changes: 6 additions & 0 deletions test/Emission.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
MentoToken,
MentoToken__factory,
} from '@mento-protocol/mento-core-ts';
import { networks } from '../config';

describe('Emission Contract', function () {
const { provider } = ethers;
Expand Down Expand Up @@ -45,6 +46,11 @@ describe('Emission Contract', function () {
throw new Error('Chain ID not found');
}

// if chain is baklava skip tests
baroooo marked this conversation as resolved.
Show resolved Hide resolved
if (chainId === networks.baklava.chainId) {
this.skip();
}

governanceAddresses = mento.addresses[chainId]!;
if (!governanceAddresses) {
throw new Error('Governance addresses not found for this chain');
Expand Down
25 changes: 2 additions & 23 deletions test/Governance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import {
TimelockController__factory,
GovernanceFactory,
GovernanceFactory__factory,
Emission,
Emission__factory,
} from '@mento-protocol/mento-core-ts';
import { ProxyAdmin } from '../typechain-types/@openzeppelin/contracts/proxy/transparent';
import { ProxyAdmin__factory } from '../typechain-types/factories/@openzeppelin/contracts/proxy/transparent';
Expand All @@ -36,7 +34,6 @@ describe('Governance', function () {
} = ethers;

let governanceAddresses: mento.ContractAddresses;
let emission: Emission;
let mentoToken: MentoToken;
let locking: Locking;
let governor: MentoGovernor;
Expand Down Expand Up @@ -410,10 +407,9 @@ describe('Governance', function () {
const newLocking = await deployContract('MockLocking');
const newTimelock = await deployContract('MockTimelock');
const newGovernor = await deployContract('MockGovernor');
const newEmission = await deployContract('MockEmission');

const targets = Array(4).fill(proxyAdmin.target);
const values = Array(4).fill(0);
const targets = Array(3).fill(proxyAdmin.target);
const values = Array(3).fill(0);
const calldatas = [];
const description = 'Upgrade upgradable contracts';

Expand All @@ -438,13 +434,6 @@ describe('Governance', function () {
]),
);

calldatas.push(
proxyAdmin.interface.encodeFunctionData('upgrade', [
emission.target,
newEmission.target,
]),
);

// Create a proposal to upgrade contracts
const proposalId = submitProposal(
governanceAddresses,
Expand Down Expand Up @@ -472,7 +461,6 @@ describe('Governance', function () {
await locking.getWeek();
await timelock.getMinDelay();
await governor.votingDelay();
await emission.calculateEmission();

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

Expand All @@ -486,9 +474,6 @@ describe('Governance', function () {
await expect(governor.votingDelay()).to.be.revertedWith(
'MockGovernor: votingDelay not implemented',
);
await expect(emission.calculateEmission()).to.be.revertedWith(
'MockEmission: calculateEmission not implemented',
);
});

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

emission = Emission__factory.connect(
governanceAddresses.Emission,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
provider as any,
);

mentoToken = MentoToken__factory.connect(
governanceAddresses.MentoToken,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
16 changes: 12 additions & 4 deletions test/MentoToken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ describe('Mento Token', function () {

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

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

it('should allow for tokens to be transferred by owner,locking and emission when paused', async function () {
const addresses = [
mentoAddresses.Emission,
mentoAddresses.Emission === '0xNotDeployed'
? process.env.DEPLOYER!
: mentoAddresses.Emission,
mentoAddresses.Locking,
mentoAddresses.TimelockController,
];
Expand Down Expand Up @@ -201,7 +207,9 @@ describe('Mento Token', function () {

it('should allow for tokens to be burned by anyone when unpaused', async function () {
const emissionSigner = await ethers.getImpersonatedSigner(
mentoAddresses.Emission,
mentoAddresses.Emission === '0xNotDeployed'
? process.env.DEPLOYER!
: mentoAddresses.Emission,
);
const [bob] = await ethers.getSigners();
const supplyBefore = await mentoToken.totalSupply();
Expand Down
6 changes: 5 additions & 1 deletion test/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ export const setUpTestAccounts = async (
mentoAddresses: mento.ContractAddresses,
mintAmount: string = '10000000',
): Promise<void> => {
// if the Emission contract is not deployed on a chain, emitter is deployer
const emissionSigner = await ethers.getImpersonatedSigner(
mentoAddresses.Emission,
mentoAddresses.Emission === '0xNotDeployed'
? process.env.DEPLOYER!
: mentoAddresses.Emission,
);

const mentoToken = MentoToken__factory.connect(
mentoAddresses.MentoToken,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
Loading