Skip to content

Commit 67978c6

Browse files
committed
chore: lint
1 parent f24ca21 commit 67978c6

File tree

1 file changed

+110
-94
lines changed

1 file changed

+110
-94
lines changed

test/006_emergency_brake.ts

Lines changed: 110 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/dist/src/signer-with-address';
1+
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
22

3-
import { id } from '../src/index';
3+
import { id } from "../src/index";
44

5-
import RestrictedERC20MockArtifact from '../artifacts/contracts/mocks/RestrictedERC20Mock.sol/RestrictedERC20Mock.json';
6-
import EmergencyBrakeArtifact from '../artifacts/contracts/utils/EmergencyBrake.sol/EmergencyBrake.json';
7-
import { RestrictedERC20Mock as ERC20 } from '../typechain/RestrictedERC20Mock';
8-
import { EmergencyBrake } from '../typechain/EmergencyBrake';
5+
import RestrictedERC20MockArtifact from "../artifacts/contracts/mocks/RestrictedERC20Mock.sol/RestrictedERC20Mock.json";
6+
import EmergencyBrakeArtifact from "../artifacts/contracts/utils/EmergencyBrake.sol/EmergencyBrake.json";
7+
import { RestrictedERC20Mock as ERC20 } from "../typechain/RestrictedERC20Mock";
8+
import { EmergencyBrake } from "../typechain/EmergencyBrake";
99

10-
import { BigNumber } from 'ethers';
10+
import { BigNumber } from "ethers";
1111

12-
import { ethers, waffle } from 'hardhat';
13-
import { expect } from 'chai';
12+
import { ethers, waffle } from "hardhat";
13+
import { expect } from "chai";
1414
const { deployContract, loadFixture } = waffle;
1515

16-
describe('EmergencyBrake', async function () {
16+
describe("EmergencyBrake", async function () {
1717
this.timeout(0);
1818

1919
let plannerAcc: SignerWithAddress;
@@ -34,14 +34,14 @@ describe('EmergencyBrake', async function () {
3434
TERMINATED: 3,
3535
};
3636

37-
const MINT = id('mint(address,uint256)')
38-
const BURN = id('burn(address,uint256)')
39-
const APPROVE = id('approve(address,uint256)')
40-
const TRANSFER = id('transfer(address,uint256)')
41-
const ROOT = '0x00000000'
42-
43-
let contacts: string[]
44-
let signatures: string[][]
37+
const MINT = id("mint(address,uint256)");
38+
const BURN = id("burn(address,uint256)");
39+
const APPROVE = id("approve(address,uint256)");
40+
const TRANSFER = id("transfer(address,uint256)");
41+
const ROOT = "0x00000000";
42+
43+
let contacts: string[];
44+
let signatures: string[][];
4545

4646
beforeEach(async () => {
4747
const signers = await ethers.getSigners();
@@ -53,186 +53,202 @@ describe('EmergencyBrake', async function () {
5353
target = targetAcc.address;
5454

5555
contact1 = (await deployContract(plannerAcc, RestrictedERC20MockArtifact, [
56-
'Contact1',
57-
'CT1',
56+
"Contact1",
57+
"CT1",
5858
])) as ERC20;
5959
contact2 = (await deployContract(plannerAcc, RestrictedERC20MockArtifact, [
60-
'Contact2',
61-
'CT2',
60+
"Contact2",
61+
"CT2",
6262
])) as ERC20;
6363
brake = (await deployContract(plannerAcc, EmergencyBrakeArtifact, [
6464
planner,
6565
executor,
6666
])) as EmergencyBrake;
6767

68-
await contact1.grantRoles([MINT, BURN], target)
69-
await contact2.grantRoles([TRANSFER, APPROVE], target)
68+
await contact1.grantRoles([MINT, BURN], target);
69+
await contact2.grantRoles([TRANSFER, APPROVE], target);
7070

71-
await contact1.grantRole(ROOT, brake.address)
72-
await contact2.grantRole(ROOT, brake.address)
71+
await contact1.grantRole(ROOT, brake.address);
72+
await contact2.grantRole(ROOT, brake.address);
7373

7474
contacts = [contact1.address, contact2.address];
75-
signatures = [[MINT, BURN], [TRANSFER, APPROVE]];
75+
signatures = [
76+
[MINT, BURN],
77+
[TRANSFER, APPROVE],
78+
];
7679
});
7780

78-
it('doesn\'t allow mismatched inputs', async () => {
81+
it("doesn't allow mismatched inputs", async () => {
7982
const mismatch = [[MINT, BURN]];
8083

8184
await expect(
8285
brake.connect(plannerAcc).plan(target, contacts, mismatch)
83-
).to.be.revertedWith('Mismatched inputs');
86+
).to.be.revertedWith("Mismatched inputs");
8487
await expect(
8588
brake.connect(plannerAcc).cancel(target, contacts, mismatch)
86-
).to.be.revertedWith('Mismatched inputs');
89+
).to.be.revertedWith("Mismatched inputs");
8790
await expect(
8891
brake.connect(executorAcc).execute(target, contacts, mismatch)
89-
).to.be.revertedWith('Mismatched inputs');
92+
).to.be.revertedWith("Mismatched inputs");
9093
await expect(
9194
brake.connect(plannerAcc).restore(target, contacts, mismatch)
92-
).to.be.revertedWith('Mismatched inputs');
95+
).to.be.revertedWith("Mismatched inputs");
9396
await expect(
9497
brake.connect(plannerAcc).terminate(target, contacts, mismatch)
95-
).to.be.revertedWith('Mismatched inputs');
98+
).to.be.revertedWith("Mismatched inputs");
9699
});
97100

98-
it('doesn\'t allow to cancel, execute, restore or terminate an unknown plan', async () => {
101+
it("doesn't allow to cancel, execute, restore or terminate an unknown plan", async () => {
99102
await expect(
100103
brake.connect(plannerAcc).cancel(target, contacts, signatures)
101-
).to.be.revertedWith('Emergency not planned for.');
104+
).to.be.revertedWith("Emergency not planned for.");
102105
await expect(
103106
brake.connect(executorAcc).execute(target, contacts, signatures)
104-
).to.be.revertedWith('Emergency not planned for.');
107+
).to.be.revertedWith("Emergency not planned for.");
105108
await expect(
106109
brake.connect(plannerAcc).restore(target, contacts, signatures)
107-
).to.be.revertedWith('Emergency plan not executed.');
110+
).to.be.revertedWith("Emergency plan not executed.");
108111
await expect(
109112
brake.connect(plannerAcc).terminate(target, contacts, signatures)
110-
).to.be.revertedWith('Emergency plan not executed.');
113+
).to.be.revertedWith("Emergency plan not executed.");
111114
});
112115

113-
it('only the planner can plan', async () => {
116+
it("only the planner can plan", async () => {
114117
await expect(
115118
brake.connect(executorAcc).plan(target, contacts, signatures)
116-
).to.be.revertedWith('Access denied');
119+
).to.be.revertedWith("Access denied");
117120
});
118121

119-
it('ROOT is out of bounds', async () => {
122+
it("ROOT is out of bounds", async () => {
120123
const tryRoot = [[ROOT], [TRANSFER, APPROVE]];
121124
await expect(
122125
brake.connect(plannerAcc).plan(target, contacts, tryRoot)
123-
).to.be.revertedWith('Can\'t remove ROOT');
126+
).to.be.revertedWith("Can't remove ROOT");
124127
});
125128

126-
it('emergencies can be planned', async () => {
127-
const txHash = await brake.connect(plannerAcc).callStatic.plan(target, contacts, signatures);
129+
it("emergencies can be planned", async () => {
130+
const txHash = await brake
131+
.connect(plannerAcc)
132+
.callStatic.plan(target, contacts, signatures);
128133

129-
expect(await brake.connect(plannerAcc).plan(target, contacts, signatures))
130-
.to.emit(brake, 'Planned');
134+
expect(
135+
await brake.connect(plannerAcc).plan(target, contacts, signatures)
136+
).to.emit(brake, "Planned");
131137

132-
expect(await brake.plans(txHash)).to.equal(state.PLANNED)
138+
expect(await brake.plans(txHash)).to.equal(state.PLANNED);
133139
});
134140

135-
describe('with a planned emergency', async () => {
141+
describe("with a planned emergency", async () => {
136142
let txHash: string;
137143

138144
beforeEach(async () => {
139-
txHash = await brake.connect(plannerAcc).callStatic.plan(target, contacts, signatures);
140-
141-
await brake.connect(plannerAcc).plan(target, contacts, signatures)
145+
txHash = await brake
146+
.connect(plannerAcc)
147+
.callStatic.plan(target, contacts, signatures);
148+
149+
await brake.connect(plannerAcc).plan(target, contacts, signatures);
142150
});
143151

144-
it('the same emergency plan cant\'t registered twice', async () => {
152+
it("the same emergency plan cant't registered twice", async () => {
145153
await expect(
146154
brake.connect(plannerAcc).plan(target, contacts, signatures)
147-
).to.be.revertedWith('Emergency already planned for.');
155+
).to.be.revertedWith("Emergency already planned for.");
148156
});
149157

150-
it('only the planner can cancel', async () => {
158+
it("only the planner can cancel", async () => {
151159
await expect(
152160
brake.connect(executorAcc).cancel(target, contacts, signatures)
153-
).to.be.revertedWith('Access denied');
161+
).to.be.revertedWith("Access denied");
154162
});
155163

156-
it('cancels a plan', async () => {
164+
it("cancels a plan", async () => {
157165
await expect(
158166
await brake.connect(plannerAcc).cancel(target, contacts, signatures)
159-
).to.emit(brake, 'Cancelled');
167+
).to.emit(brake, "Cancelled");
160168
// .withArgs(txHash, target, contacts, signatures)
161169
expect(await brake.plans(txHash)).to.equal(state.UNKNOWN);
162170
});
163171

164-
it('cant\'t restore or terminate a plan that hasn\'t been executed', async () => {
172+
it("cant't restore or terminate a plan that hasn't been executed", async () => {
165173
await expect(
166174
brake.connect(plannerAcc).restore(target, contacts, signatures)
167-
).to.be.revertedWith('Emergency plan not executed.');
175+
).to.be.revertedWith("Emergency plan not executed.");
168176
await expect(
169177
brake.connect(plannerAcc).terminate(target, contacts, signatures)
170-
).to.be.revertedWith('Emergency plan not executed.');
178+
).to.be.revertedWith("Emergency plan not executed.");
171179
});
172-
173-
it('only the executor can execute', async () => {
180+
181+
it("only the executor can execute", async () => {
174182
await expect(
175183
brake.connect(plannerAcc).execute(target, contacts, signatures)
176-
).to.be.revertedWith('Access denied');
184+
).to.be.revertedWith("Access denied");
177185
});
178186

179-
it('can\'t revoke non-existing permissions', async () => {
180-
const nonExisting = [[MINT, BURN], [MINT, BURN]];
181-
await brake.connect(plannerAcc).plan(target, contacts, nonExisting) // It can be planned, because permissions could be different at execution time
187+
it("can't revoke non-existing permissions", async () => {
188+
const nonExisting = [
189+
[MINT, BURN],
190+
[MINT, BURN],
191+
];
192+
await brake.connect(plannerAcc).plan(target, contacts, nonExisting); // It can be planned, because permissions could be different at execution time
182193
await expect(
183194
brake.connect(executorAcc).execute(target, contacts, nonExisting)
184-
).to.be.revertedWith('Permission not found');
195+
).to.be.revertedWith("Permission not found");
185196
});
186197

187-
it('plans can be executed', async () => {
188-
expect(await brake.connect(executorAcc).execute(target, contacts, signatures))
189-
.to.emit(brake, 'Executed');
198+
it("plans can be executed", async () => {
199+
expect(
200+
await brake.connect(executorAcc).execute(target, contacts, signatures)
201+
).to.emit(brake, "Executed");
190202

191-
expect(await contact1.hasRole(MINT, target)).to.be.false
192-
expect(await contact1.hasRole(BURN, target)).to.be.false
193-
expect(await contact2.hasRole(APPROVE, target)).to.be.false
194-
expect(await contact2.hasRole(TRANSFER, target)).to.be.false
203+
expect(await contact1.hasRole(MINT, target)).to.be.false;
204+
expect(await contact1.hasRole(BURN, target)).to.be.false;
205+
expect(await contact2.hasRole(APPROVE, target)).to.be.false;
206+
expect(await contact2.hasRole(TRANSFER, target)).to.be.false;
195207

196-
expect(await brake.plans(txHash)).to.equal(state.EXECUTED)
208+
expect(await brake.plans(txHash)).to.equal(state.EXECUTED);
197209
});
198210

199-
describe('with an executed emergency plan', async () => {
211+
describe("with an executed emergency plan", async () => {
200212
beforeEach(async () => {
201213
await brake.connect(executorAcc).execute(target, contacts, signatures);
202214
});
203215

204-
it('the same emergency plan cant\'t executed twice', async () => {
216+
it("the same emergency plan cant't executed twice", async () => {
205217
await expect(
206218
brake.connect(executorAcc).execute(target, contacts, signatures)
207-
).to.be.revertedWith('Emergency not planned for.');
219+
).to.be.revertedWith("Emergency not planned for.");
208220
});
209-
210-
it('only the planner can restore or terminate', async () => {
221+
222+
it("only the planner can restore or terminate", async () => {
211223
await expect(
212224
brake.connect(executorAcc).restore(target, contacts, signatures)
213-
).to.be.revertedWith('Access denied');
225+
).to.be.revertedWith("Access denied");
214226
await expect(
215227
brake.connect(executorAcc).terminate(target, contacts, signatures)
216-
).to.be.revertedWith('Access denied');
228+
).to.be.revertedWith("Access denied");
217229
});
218230

219-
it('state can be restored', async () => {
220-
expect(await brake.connect(plannerAcc).restore(target, contacts, signatures))
221-
.to.emit(brake, 'Restored');
231+
it("state can be restored", async () => {
232+
expect(
233+
await brake.connect(plannerAcc).restore(target, contacts, signatures)
234+
).to.emit(brake, "Restored");
222235

223-
expect(await contact1.hasRole(MINT, target)).to.be.true
224-
expect(await contact1.hasRole(BURN, target)).to.be.true
225-
expect(await contact2.hasRole(APPROVE, target)).to.be.true
226-
expect(await contact2.hasRole(TRANSFER, target)).to.be.true
236+
expect(await contact1.hasRole(MINT, target)).to.be.true;
237+
expect(await contact1.hasRole(BURN, target)).to.be.true;
238+
expect(await contact2.hasRole(APPROVE, target)).to.be.true;
239+
expect(await contact2.hasRole(TRANSFER, target)).to.be.true;
227240

228-
expect(await brake.plans(txHash)).to.equal(state.PLANNED)
241+
expect(await brake.plans(txHash)).to.equal(state.PLANNED);
229242
});
230243

231-
it('target can be terminated', async () => {
232-
expect(await brake.connect(plannerAcc).terminate(target, contacts, signatures))
233-
.to.emit(brake, 'Terminated');
244+
it("target can be terminated", async () => {
245+
expect(
246+
await brake
247+
.connect(plannerAcc)
248+
.terminate(target, contacts, signatures)
249+
).to.emit(brake, "Terminated");
234250

235-
expect(await brake.plans(txHash)).to.equal(state.TERMINATED)
251+
expect(await brake.plans(txHash)).to.equal(state.TERMINATED);
236252
});
237253
});
238254
});

0 commit comments

Comments
 (0)