forked from matter-labs/zksync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathownable.spec.js
44 lines (37 loc) · 1.78 KB
/
ownable.spec.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
const { expect } = require('chai');
const { getCallRevertReason } = require('./common');
const hardhat = require('hardhat');
describe('Ownable unit tests', function () {
this.timeout(50000);
let testContract;
let deployer;
let wallet;
before(async () => {
[deployer, wallet] = await hardhat.ethers.getSigners();
const contractFactory = await hardhat.ethers.getContractFactory('Ownable');
testContract = await contractFactory.deploy(deployer.address);
});
it('checking correctness of setting mastership in constructor', async () => {
expect(await testContract.getMaster()).to.equal(deployer.address);
});
it('checking correctness of transferring mastership to zero address', async () => {
let { revertReason } = await getCallRevertReason(() =>
testContract.transferMastership('0x0000000000000000000000000000000000000000', { gasLimit: '300000' })
);
expect(revertReason).equal('1d');
});
it('checking correctness of transferring mastership', async () => {
/// transfer mastership to wallet
await testContract.transferMastership(wallet.address);
expect(await testContract.getMaster()).to.equal(wallet.address);
/// try to transfer mastership to deployer by deployer call
let { revertReason } = await getCallRevertReason(() =>
testContract.transferMastership(deployer.address, { gasLimit: '300000' })
);
expect(revertReason).equal('1c');
/// transfer mastership back to deployer
let testContract_with_wallet2_signer = await testContract.connect(wallet);
await testContract_with_wallet2_signer.transferMastership(deployer.address);
expect(await testContract.getMaster()).to.equal(deployer.address);
});
});