Skip to content

Commit 6f185d5

Browse files
author
Joey Santoro
committed
lint
1 parent 1768e36 commit 6f185d5

File tree

1 file changed

+74
-66
lines changed

1 file changed

+74
-66
lines changed

test/unit/dao/FeiDAOTimelock.test.ts

Lines changed: 74 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,75 +3,83 @@ import { expect } from 'chai';
33
import { ethers } from 'hardhat';
44
import { Core, FeiDAOTimelock } from '@custom-types/contracts';
55
import { Signer } from '@ethersproject/abstract-signer';
6-
7-
describe.only('FeiDAOTimelock', function () {
8-
let userAddress: string;
9-
let guardianAddress: string;
10-
let governorAddress: string;
11-
let timelock: FeiDAOTimelock;
12-
let userSigner: Signer;
13-
let core: Core;
14-
let delay: number;
15-
6+
7+
describe.only('FeiDAOTimelock', function () {
8+
let userAddress: string;
9+
let guardianAddress: string;
10+
let governorAddress: string;
11+
let timelock: FeiDAOTimelock;
12+
let userSigner: Signer;
13+
let core: Core;
14+
let delay: number;
15+
16+
beforeEach(async function () {
17+
({ userAddress, guardianAddress, governorAddress } = await getAddresses());
18+
core = await getCore();
19+
20+
delay = 1000;
21+
timelock = await (
22+
await ethers.getContractFactory('FeiDAOTimelock')
23+
).deploy(core.address, userAddress, delay, delay);
24+
25+
userSigner = await getImpersonatedSigner(userAddress);
26+
});
27+
28+
describe('Pausable', function () {
1629
beforeEach(async function () {
17-
({
18-
userAddress,
19-
guardianAddress,
20-
governorAddress,
21-
} = await getAddresses());
22-
core = await getCore();
23-
24-
delay = 1000;
25-
timelock = await (
26-
await ethers.getContractFactory('FeiDAOTimelock')
27-
).deploy(core.address, userAddress, delay, delay);
30+
await timelock.connect(await getImpersonatedSigner(governorAddress)).pause();
31+
});
2832

29-
userSigner = await getImpersonatedSigner(userAddress);
33+
it('queue reverts', async function () {
34+
const eta = (await latestTime()) + delay;
35+
await expectRevert(
36+
timelock.connect(userSigner).queueTransaction(userAddress, 100, '', '0x', eta),
37+
'Pausable: paused'
38+
);
39+
});
3040

41+
it('execute reverts', async function () {
42+
const eta = (await latestTime()) + delay;
43+
await expectRevert(
44+
timelock.connect(userSigner).executeTransaction(userAddress, 100, '', '0x', eta),
45+
'Pausable: paused'
46+
);
3147
});
32-
33-
describe('Pausable', function () {
34-
beforeEach(async function () {
35-
await timelock.connect(await getImpersonatedSigner(governorAddress)).pause();
36-
});
37-
38-
it('queue reverts', async function() {
39-
const eta = (await latestTime()) + delay;
40-
await expectRevert(timelock.connect(userSigner).queueTransaction(userAddress, 100, '', '0x', eta), 'Pausable: paused');
41-
});
42-
43-
it('execute reverts', async function() {
44-
const eta = (await latestTime()) + delay;
45-
await expectRevert(timelock.connect(userSigner).executeTransaction(userAddress, 100, '', '0x', eta), 'Pausable: paused');
46-
});
48+
});
49+
50+
describe('Veto', function () {
51+
it('non-governor or guardian reverts', async function () {
52+
const eta = (await latestTime()) + delay;
53+
await expectRevert(
54+
timelock.connect(userSigner).vetoTransactions([userAddress], [100], [''], ['0x'], [eta]),
55+
'CoreRef: Caller is not a guardian or governor'
56+
);
4757
});
48-
49-
describe('Veto', function () {
50-
it('non-governor or guardian reverts', async function() {
51-
const eta = (await latestTime()) + delay;
52-
await expectRevert(timelock.connect(userSigner).vetoTransactions([userAddress], [100], [''], ['0x'], [eta]), 'CoreRef: Caller is not a guardian or governor');
53-
});
54-
55-
it('guardian succeeds', async function() {
56-
const eta = (await latestTime()) + delay + delay;
57-
await timelock.connect(userSigner).queueTransaction(userAddress, 100, '', '0x', eta);
58-
59-
const txHash = await timelock.getTxHash(userAddress, 100, '', '0x', eta);
60-
expect(await timelock.queuedTransactions(txHash)).to.be.equal(true);
61-
62-
await timelock.connect(await getImpersonatedSigner(guardianAddress)).vetoTransactions([userAddress], [100], [''], ['0x'], [eta]);
63-
expect(await timelock.queuedTransactions(txHash)).to.be.equal(false);
64-
});
65-
66-
it('governor succeeds', async function() {
67-
const eta = (await latestTime()) + delay + delay;
68-
await timelock.connect(userSigner).queueTransaction(userAddress, 100, '', '0x', eta);
69-
70-
const txHash = await timelock.getTxHash(userAddress, 100, '', '0x', eta);
71-
expect(await timelock.queuedTransactions(txHash)).to.be.equal(true);
72-
73-
await timelock.connect(await getImpersonatedSigner(governorAddress)).vetoTransactions([userAddress], [100], [''], ['0x'], [eta]);
74-
expect(await timelock.queuedTransactions(txHash)).to.be.equal(false);
75-
});
58+
59+
it('guardian succeeds', async function () {
60+
const eta = (await latestTime()) + delay + delay;
61+
await timelock.connect(userSigner).queueTransaction(userAddress, 100, '', '0x', eta);
62+
63+
const txHash = await timelock.getTxHash(userAddress, 100, '', '0x', eta);
64+
expect(await timelock.queuedTransactions(txHash)).to.be.equal(true);
65+
66+
await timelock
67+
.connect(await getImpersonatedSigner(guardianAddress))
68+
.vetoTransactions([userAddress], [100], [''], ['0x'], [eta]);
69+
expect(await timelock.queuedTransactions(txHash)).to.be.equal(false);
70+
});
71+
72+
it('governor succeeds', async function () {
73+
const eta = (await latestTime()) + delay + delay;
74+
await timelock.connect(userSigner).queueTransaction(userAddress, 100, '', '0x', eta);
75+
76+
const txHash = await timelock.getTxHash(userAddress, 100, '', '0x', eta);
77+
expect(await timelock.queuedTransactions(txHash)).to.be.equal(true);
78+
79+
await timelock
80+
.connect(await getImpersonatedSigner(governorAddress))
81+
.vetoTransactions([userAddress], [100], [''], ['0x'], [eta]);
82+
expect(await timelock.queuedTransactions(txHash)).to.be.equal(false);
7683
});
77-
});
84+
});
85+
});

0 commit comments

Comments
 (0)