From 6f185d59430ae89b8bf155431b821aefeb2a67fe Mon Sep 17 00:00:00 2001 From: Joey Santoro Date: Tue, 5 Oct 2021 16:06:01 -0700 Subject: [PATCH] lint --- test/unit/dao/FeiDAOTimelock.test.ts | 140 ++++++++++++++------------- 1 file changed, 74 insertions(+), 66 deletions(-) diff --git a/test/unit/dao/FeiDAOTimelock.test.ts b/test/unit/dao/FeiDAOTimelock.test.ts index b9cff9627..78a7fae0b 100644 --- a/test/unit/dao/FeiDAOTimelock.test.ts +++ b/test/unit/dao/FeiDAOTimelock.test.ts @@ -3,75 +3,83 @@ import { expect } from 'chai'; import { ethers } from 'hardhat'; import { Core, FeiDAOTimelock } from '@custom-types/contracts'; import { Signer } from '@ethersproject/abstract-signer'; - - describe.only('FeiDAOTimelock', function () { - let userAddress: string; - let guardianAddress: string; - let governorAddress: string; - let timelock: FeiDAOTimelock; - let userSigner: Signer; - let core: Core; - let delay: number; - + +describe.only('FeiDAOTimelock', function () { + let userAddress: string; + let guardianAddress: string; + let governorAddress: string; + let timelock: FeiDAOTimelock; + let userSigner: Signer; + let core: Core; + let delay: number; + + beforeEach(async function () { + ({ userAddress, guardianAddress, governorAddress } = await getAddresses()); + core = await getCore(); + + delay = 1000; + timelock = await ( + await ethers.getContractFactory('FeiDAOTimelock') + ).deploy(core.address, userAddress, delay, delay); + + userSigner = await getImpersonatedSigner(userAddress); + }); + + describe('Pausable', function () { beforeEach(async function () { - ({ - userAddress, - guardianAddress, - governorAddress, - } = await getAddresses()); - core = await getCore(); - - delay = 1000; - timelock = await ( - await ethers.getContractFactory('FeiDAOTimelock') - ).deploy(core.address, userAddress, delay, delay); + await timelock.connect(await getImpersonatedSigner(governorAddress)).pause(); + }); - userSigner = await getImpersonatedSigner(userAddress); + it('queue reverts', async function () { + const eta = (await latestTime()) + delay; + await expectRevert( + timelock.connect(userSigner).queueTransaction(userAddress, 100, '', '0x', eta), + 'Pausable: paused' + ); + }); + it('execute reverts', async function () { + const eta = (await latestTime()) + delay; + await expectRevert( + timelock.connect(userSigner).executeTransaction(userAddress, 100, '', '0x', eta), + 'Pausable: paused' + ); }); - - describe('Pausable', function () { - beforeEach(async function () { - await timelock.connect(await getImpersonatedSigner(governorAddress)).pause(); - }); - - it('queue reverts', async function() { - const eta = (await latestTime()) + delay; - await expectRevert(timelock.connect(userSigner).queueTransaction(userAddress, 100, '', '0x', eta), 'Pausable: paused'); - }); - - it('execute reverts', async function() { - const eta = (await latestTime()) + delay; - await expectRevert(timelock.connect(userSigner).executeTransaction(userAddress, 100, '', '0x', eta), 'Pausable: paused'); - }); + }); + + describe('Veto', function () { + it('non-governor or guardian reverts', async function () { + const eta = (await latestTime()) + delay; + await expectRevert( + timelock.connect(userSigner).vetoTransactions([userAddress], [100], [''], ['0x'], [eta]), + 'CoreRef: Caller is not a guardian or governor' + ); }); - - describe('Veto', function () { - it('non-governor or guardian reverts', async function() { - const eta = (await latestTime()) + delay; - await expectRevert(timelock.connect(userSigner).vetoTransactions([userAddress], [100], [''], ['0x'], [eta]), 'CoreRef: Caller is not a guardian or governor'); - }); - - it('guardian succeeds', async function() { - const eta = (await latestTime()) + delay + delay; - await timelock.connect(userSigner).queueTransaction(userAddress, 100, '', '0x', eta); - - const txHash = await timelock.getTxHash(userAddress, 100, '', '0x', eta); - expect(await timelock.queuedTransactions(txHash)).to.be.equal(true); - - await timelock.connect(await getImpersonatedSigner(guardianAddress)).vetoTransactions([userAddress], [100], [''], ['0x'], [eta]); - expect(await timelock.queuedTransactions(txHash)).to.be.equal(false); - }); - - it('governor succeeds', async function() { - const eta = (await latestTime()) + delay + delay; - await timelock.connect(userSigner).queueTransaction(userAddress, 100, '', '0x', eta); - - const txHash = await timelock.getTxHash(userAddress, 100, '', '0x', eta); - expect(await timelock.queuedTransactions(txHash)).to.be.equal(true); - - await timelock.connect(await getImpersonatedSigner(governorAddress)).vetoTransactions([userAddress], [100], [''], ['0x'], [eta]); - expect(await timelock.queuedTransactions(txHash)).to.be.equal(false); - }); + + it('guardian succeeds', async function () { + const eta = (await latestTime()) + delay + delay; + await timelock.connect(userSigner).queueTransaction(userAddress, 100, '', '0x', eta); + + const txHash = await timelock.getTxHash(userAddress, 100, '', '0x', eta); + expect(await timelock.queuedTransactions(txHash)).to.be.equal(true); + + await timelock + .connect(await getImpersonatedSigner(guardianAddress)) + .vetoTransactions([userAddress], [100], [''], ['0x'], [eta]); + expect(await timelock.queuedTransactions(txHash)).to.be.equal(false); + }); + + it('governor succeeds', async function () { + const eta = (await latestTime()) + delay + delay; + await timelock.connect(userSigner).queueTransaction(userAddress, 100, '', '0x', eta); + + const txHash = await timelock.getTxHash(userAddress, 100, '', '0x', eta); + expect(await timelock.queuedTransactions(txHash)).to.be.equal(true); + + await timelock + .connect(await getImpersonatedSigner(governorAddress)) + .vetoTransactions([userAddress], [100], [''], ['0x'], [eta]); + expect(await timelock.queuedTransactions(txHash)).to.be.equal(false); }); - }); \ No newline at end of file + }); +});