-
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.
- Loading branch information
1 parent
331bd9f
commit 35b93bb
Showing
1 changed file
with
61 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const { web3, accounts } = require('hardhat'); | ||
const { expectRevert } = require('@openzeppelin/test-helpers'); | ||
const { assert } = require('chai'); | ||
const { hex } = require('../utils').helpers; | ||
const { toBN } = web3.utils; | ||
|
||
const [, treasury, coverHolder, newTreasury, nonOwner] = accounts; | ||
|
||
describe('buyCover', function () { | ||
|
||
it('allows setting new treasury address by owner', async function () { | ||
const { distributor } = this.contracts; | ||
|
||
await distributor.setTreasury(newTreasury); | ||
|
||
const currentTreasury = await distributor.treasury(); | ||
assert.equal(newTreasury, currentTreasury); | ||
}); | ||
|
||
it('rejects setting new treasury to 0', async function () { | ||
const { distributor } = this.contracts; | ||
|
||
await expectRevert( | ||
distributor.setTreasury('0x0000000000000000000000000000000000000000'), | ||
'Distributor: treasury address is 0', | ||
); | ||
}); | ||
|
||
it('disallows setting the fee percentage by non-owner', async function () { | ||
const { distributor } = this.contracts; | ||
|
||
await expectRevert( | ||
distributor.setTreasury(newTreasury, { from: nonOwner }), | ||
'Ownable: caller is not the owner', | ||
); | ||
}); | ||
|
||
it('allows setting the fee percentage by owner', async function () { | ||
const { distributor } = this.contracts; | ||
|
||
const newFeePercentage = '20000'; | ||
|
||
await distributor.setFeePercentage(newFeePercentage); | ||
|
||
const storedFeePercentage = await distributor.feePercentage(); | ||
assert(storedFeePercentage.toString(), newFeePercentage); | ||
}); | ||
|
||
it('disallows setting the fee percentage by non-owner', async function () { | ||
const { distributor } = this.contracts; | ||
|
||
const newFeePercentage = '20000'; | ||
|
||
await expectRevert( | ||
distributor.setFeePercentage(newFeePercentage, { | ||
from: nonOwner, | ||
}), | ||
'Ownable: caller is not the owner', | ||
); | ||
}); | ||
}); |