-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #443 from NexusMutual/test/constructor-initialize-…
…assessment Test/ Add constructor and initialize assessment tests
- Loading branch information
Showing
5 changed files
with
63 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const { expect } = require('chai'); | ||
const { ethers } = require('hardhat'); | ||
|
||
describe('constructor', function () { | ||
it('should set nxm address correctly', async function () { | ||
const { nxm } = this.contracts; | ||
|
||
const Assessment = await ethers.getContractFactory('Assessment'); | ||
const assessment = await Assessment.deploy(nxm.address); | ||
const nxmAddress = await assessment.nxm(); | ||
|
||
expect(nxmAddress).to.be.equal(nxm.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
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,8 +1,51 @@ | ||
const { expect } = require('chai'); | ||
const { ethers } = require('hardhat'); | ||
const { hex } = require('../../utils').helpers; | ||
|
||
describe('initialize', function () { | ||
it('reverts if the contract was already initialized', async function () { | ||
const { assessment } = this.contracts; | ||
await expect(assessment.initialize()).to.be.revertedWith('Already initialized'); | ||
}); | ||
|
||
it('should set config parameters', async function () { | ||
const { nxm, master } = this.contracts; | ||
|
||
const Assessment = await ethers.getContractFactory('Assessment'); | ||
const assessment = await Assessment.deploy(nxm.address); | ||
|
||
await master.setLatestAddress(hex('AS'), assessment.address); | ||
await assessment.changeMasterAddress(master.address); | ||
await assessment.changeDependentContractAddress(); | ||
|
||
const preInitializeConfig = await assessment.config(); | ||
|
||
expect(preInitializeConfig.minVotingPeriodInDays).to.be.equal(0); | ||
expect(preInitializeConfig.stakeLockupPeriodInDays).to.be.equal(0); | ||
expect(preInitializeConfig.payoutCooldownInDays).to.be.equal(0); | ||
expect(preInitializeConfig.silentEndingPeriodInDays).to.be.equal(0); | ||
|
||
await assessment.initialize(); | ||
const afterInitializeConfig = await assessment.config(); | ||
|
||
expect(afterInitializeConfig.minVotingPeriodInDays).to.be.equal(3); | ||
expect(afterInitializeConfig.stakeLockupPeriodInDays).to.be.equal(14); | ||
expect(afterInitializeConfig.payoutCooldownInDays).to.be.equal(1); | ||
expect(afterInitializeConfig.silentEndingPeriodInDays).to.be.equal(1); | ||
}); | ||
|
||
it('should be whitelisted', async function () { | ||
const { tokenController, nxm, master } = this.contracts; | ||
|
||
const Assessment = await ethers.getContractFactory('Assessment'); | ||
const assessment = await Assessment.deploy(nxm.address); | ||
|
||
await master.setLatestAddress(hex('AS'), assessment.address); | ||
await assessment.changeMasterAddress(master.address); | ||
await assessment.changeDependentContractAddress(); | ||
|
||
expect(await tokenController.addToWhitelistLastCalledWith()).to.not.be.equal(assessment.address); | ||
await assessment.initialize(); | ||
expect(await tokenController.addToWhitelistLastCalledWith()).to.be.equal(assessment.address); | ||
}); | ||
}); |