41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
const {
|
|
loadFixture,
|
|
} = require('@nomicfoundation/hardhat-toolbox/network-helpers');
|
|
const { expect } = require('chai');
|
|
const { ethers } = require('hardhat');
|
|
|
|
describe.only('DAO', () => {
|
|
// We define a fixture to reuse the same setup in every test.
|
|
// We use loadFixture to run this setup once, snapshot that state,
|
|
// and reset Hardhat Network to that snapshot in every test.
|
|
async function deployDAO() {
|
|
// Contracts are deployed using the first signer/account by default
|
|
const [account1, account2] = await ethers.getSigners();
|
|
|
|
const DAO = await ethers.getContractFactory('DAO');
|
|
const dao = await DAO.deploy();
|
|
|
|
return { dao, account1, account2 };
|
|
}
|
|
|
|
describe('Validation Pool', () => {
|
|
it('Should deploy', async () => {
|
|
const { dao } = await loadFixture(deployDAO);
|
|
expect(dao).to.exist;
|
|
expect(await dao.totalValue()).to.equal(0);
|
|
});
|
|
|
|
describe('Initiate validation pool', () => {
|
|
it('Should initiate', async () => {
|
|
const POOL_DURATION = 3600; // 1 hour
|
|
const { dao, account1 } = await loadFixture(deployDAO);
|
|
const init = () => dao.initiateValidationPool(account1, POOL_DURATION);
|
|
await expect(init()).to.emit(dao, 'ValidationPoolInitiated').withArgs(0);
|
|
const pool = await dao.validationPools(0);
|
|
expect(pool).to.exist;
|
|
expect(pool.duration).to.equal(POOL_DURATION);
|
|
});
|
|
});
|
|
});
|
|
});
|