-
Notifications
You must be signed in to change notification settings - Fork 6
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
9 changed files
with
121 additions
and
46 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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { accountGenerator } from "../helpers/accounts"; | ||
import { getContracts } from "../helpers/contracts"; | ||
import { expect } from "chai"; | ||
|
||
const { deployments, ethers } = require("hardhat"); | ||
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers"; | ||
|
||
describe("AdminFacet.transferDiamondOwner", () => { | ||
let deployer: SignerWithAddress; | ||
|
||
context("when caller is not the owner", async () => { | ||
beforeEach(async () => { | ||
await deployments.fixture(); | ||
const { adminFacet } = await getContracts(); | ||
deployer = await ethers.getNamedSigner("deployer"); | ||
const signers = await ethers.getSigners(); | ||
await adminFacet.connect(deployer).transferDiamondOwner(signers[1].address); | ||
}); | ||
|
||
it("reverts", async () => { | ||
const { adminFacet } = await getContracts(); | ||
const deployer = await ethers.getNamedSigner("deployer"); | ||
const setTx = adminFacet | ||
.connect(deployer) | ||
.transferDiamondOwner(deployer.address); | ||
await expect(setTx).to.be.reverted; | ||
}); | ||
}); | ||
|
||
beforeEach(async () => { | ||
deployer = await ethers.getNamedSigner("deployer"); | ||
await deployments.fixture(); | ||
accountGenerator.index = 0; | ||
}); | ||
|
||
it("transfers the owner successfully", async () => { | ||
const { viewStateFacet, adminFacet } = await getContracts(); | ||
const signers = await ethers.getSigners(); | ||
await adminFacet.connect(deployer).transferDiamondOwner(signers[1].address); | ||
|
||
const ownerAddress = await adminFacet.connect(deployer).getDiamondOwner(); | ||
expect(ownerAddress).to.eq(signers[1].address); | ||
}); | ||
|
||
it("does allow owner address to be the zero address", async () => { | ||
const { adminFacet } = await getContracts(); | ||
const deployer = await ethers.getNamedSigner("deployer"); | ||
const setTx = adminFacet | ||
.connect(deployer) | ||
.transferDiamondOwner(ethers.constants.AddressZero); | ||
await expect(setTx).not.to.be.reverted; | ||
}); | ||
}); |
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