forked from matter-labs/zksync
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
51 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,43 @@ | ||
const { expect } = require("chai") | ||
const { getCallRevertReason } = require("./common") | ||
const hardhat = require("hardhat"); | ||
const { expect } = require('chai'); | ||
const { getCallRevertReason } = require('./common'); | ||
const hardhat = require('hardhat'); | ||
|
||
|
||
describe("Ownable unit tests", function () { | ||
describe('Ownable unit tests', function () { | ||
this.timeout(50000); | ||
|
||
let testContract | ||
let testContract; | ||
let wallet1, wallet2; | ||
before(async () => { | ||
[wallet1, wallet2] = await hardhat.ethers.getSigners(); | ||
const contractFactory = await hardhat.ethers.getContractFactory("Ownable"); | ||
const contractFactory = await hardhat.ethers.getContractFactory('Ownable'); | ||
testContract = await contractFactory.deploy(wallet1.address); | ||
}); | ||
|
||
it("checking correctness of setting mastership in constructor", async () => { | ||
expect(await testContract.getMaster()).to.equal(wallet1.address) | ||
it('checking correctness of setting mastership in constructor', async () => { | ||
expect(await testContract.getMaster()).to.equal(wallet1.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 to zero address', async () => { | ||
let { revertReason } = await getCallRevertReason(() => | ||
testContract.transferMastership('0x0000000000000000000000000000000000000000', { gasLimit: '300000' }) | ||
); | ||
expect(revertReason).equal('1d'); | ||
}); | ||
|
||
it("checking correctness of transferring mastership", async () => { | ||
it('checking correctness of transferring mastership', async () => { | ||
/// transfer mastership to wallet2 | ||
await testContract.transferMastership(wallet2.address); | ||
expect(await testContract.getMaster()).to.equal(wallet2.address) | ||
expect(await testContract.getMaster()).to.equal(wallet2.address); | ||
|
||
/// try to transfer mastership to wallet1 by wallet1 call | ||
let {revertReason} = await getCallRevertReason( () => testContract.transferMastership(wallet1.address, {gasLimit: "300000"}) ); | ||
expect(revertReason).equal("1c") | ||
let { revertReason } = await getCallRevertReason(() => | ||
testContract.transferMastership(wallet1.address, { gasLimit: '300000' }) | ||
); | ||
expect(revertReason).equal('1c'); | ||
|
||
/// transfer mastership back to wallet1 | ||
let testContract_with_wallet2_signer = await testContract.connect(wallet2); | ||
await testContract_with_wallet2_signer.transferMastership(wallet1.address); | ||
expect(await testContract.getMaster()).to.equal(wallet1.address) | ||
expect(await testContract.getMaster()).to.equal(wallet1.address); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters