-
-
Notifications
You must be signed in to change notification settings - Fork 233
/
lockmsiths.js
51 lines (41 loc) · 1.72 KB
/
lockmsiths.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const { expect } = require('chai')
const { setup } = require('./setup')
const { ethers } = require('hardhat')
const { reverts } = require('../helpers')
let keyManager, someAccount
describe('KeyManager / locksmiths', () => {
beforeEach(async () => {
;[, , , { address: someAccount }] = await ethers.getSigners()
;[keyManager] = await setup()
})
it('should let the owner add signer', async () => {
expect(await keyManager.locksmiths(someAccount)).to.equal(false)
await keyManager.addLocksmith(someAccount)
expect(await keyManager.locksmiths(someAccount)).to.equal(true)
})
it('should not let someone who is not owner add a signer', async () => {
const [, newOwner] = await ethers.getSigners()
expect(await keyManager.locksmiths(someAccount)).to.equal(false)
await reverts(
keyManager.connect(newOwner).addLocksmith(newOwner.address),
`Ownable: caller is not the owner`
)
expect(await keyManager.locksmiths(someAccount)).to.equal(false)
})
it('should let the owner remove signer', async () => {
await keyManager.addLocksmith(someAccount)
expect(await keyManager.locksmiths(someAccount)).to.equal(true)
await keyManager.removeLocksmith(someAccount)
expect(await keyManager.locksmiths(someAccount)).to.equal(false)
})
it('should not let someone who is not owner remove a signer', async () => {
await keyManager.addLocksmith(someAccount)
expect(await keyManager.locksmiths(someAccount)).to.equal(true)
const [, newOwner] = await ethers.getSigners()
await reverts(
keyManager.connect(newOwner).removeLocksmith(newOwner.address),
`Ownable: caller is not the owner`
)
expect(await keyManager.locksmiths(someAccount)).to.equal(true)
})
})