Increase testing coverage (#1195)
* Added non-target bounty test * Increased ERC721 testing coverage. * Addressed review comments. * fix linter error * Fixed linter error * Removed unnecessary bouncer require * Improved Crowdsale tests. * Added missing SuperUser test. * Improved payment tests. * Improved token tests. * Fixed ERC721 test. * Reviewed phrasing.
This commit is contained in:
@ -14,41 +14,55 @@ const TokenTimelock = artifacts.require('TokenTimelock');
|
||||
contract('TokenTimelock', function ([_, owner, beneficiary]) {
|
||||
const amount = new BigNumber(100);
|
||||
|
||||
beforeEach(async function () {
|
||||
this.token = await MintableToken.new({ from: owner });
|
||||
this.releaseTime = (await latestTime()) + duration.years(1);
|
||||
this.timelock = await TokenTimelock.new(this.token.address, beneficiary, this.releaseTime);
|
||||
await this.token.mint(this.timelock.address, amount, { from: owner });
|
||||
});
|
||||
context('with token', function () {
|
||||
beforeEach(async function () {
|
||||
this.token = await MintableToken.new({ from: owner });
|
||||
});
|
||||
|
||||
it('cannot be released before time limit', async function () {
|
||||
await expectThrow(this.timelock.release());
|
||||
});
|
||||
it('rejects a release time in the past', async function () {
|
||||
const pastReleaseTime = (await latestTime()) - duration.years(1);
|
||||
await expectThrow(
|
||||
TokenTimelock.new(this.token.address, beneficiary, pastReleaseTime)
|
||||
);
|
||||
});
|
||||
|
||||
it('cannot be released just before time limit', async function () {
|
||||
await increaseTimeTo(this.releaseTime - duration.seconds(3));
|
||||
await expectThrow(this.timelock.release());
|
||||
});
|
||||
context('once deployed', function () {
|
||||
beforeEach(async function () {
|
||||
this.releaseTime = (await latestTime()) + duration.years(1);
|
||||
this.timelock = await TokenTimelock.new(this.token.address, beneficiary, this.releaseTime);
|
||||
await this.token.mint(this.timelock.address, amount, { from: owner });
|
||||
});
|
||||
|
||||
it('can be released just after limit', async function () {
|
||||
await increaseTimeTo(this.releaseTime + duration.seconds(1));
|
||||
await this.timelock.release();
|
||||
const balance = await this.token.balanceOf(beneficiary);
|
||||
balance.should.be.bignumber.equal(amount);
|
||||
});
|
||||
it('cannot be released before time limit', async function () {
|
||||
await expectThrow(this.timelock.release());
|
||||
});
|
||||
|
||||
it('can be released after time limit', async function () {
|
||||
await increaseTimeTo(this.releaseTime + duration.years(1));
|
||||
await this.timelock.release();
|
||||
const balance = await this.token.balanceOf(beneficiary);
|
||||
balance.should.be.bignumber.equal(amount);
|
||||
});
|
||||
it('cannot be released just before time limit', async function () {
|
||||
await increaseTimeTo(this.releaseTime - duration.seconds(3));
|
||||
await expectThrow(this.timelock.release());
|
||||
});
|
||||
|
||||
it('cannot be released twice', async function () {
|
||||
await increaseTimeTo(this.releaseTime + duration.years(1));
|
||||
await this.timelock.release();
|
||||
await expectThrow(this.timelock.release());
|
||||
const balance = await this.token.balanceOf(beneficiary);
|
||||
balance.should.be.bignumber.equal(amount);
|
||||
it('can be released just after limit', async function () {
|
||||
await increaseTimeTo(this.releaseTime + duration.seconds(1));
|
||||
await this.timelock.release();
|
||||
const balance = await this.token.balanceOf(beneficiary);
|
||||
balance.should.be.bignumber.equal(amount);
|
||||
});
|
||||
|
||||
it('can be released after time limit', async function () {
|
||||
await increaseTimeTo(this.releaseTime + duration.years(1));
|
||||
await this.timelock.release();
|
||||
const balance = await this.token.balanceOf(beneficiary);
|
||||
balance.should.be.bignumber.equal(amount);
|
||||
});
|
||||
|
||||
it('cannot be released twice', async function () {
|
||||
await increaseTimeTo(this.releaseTime + duration.years(1));
|
||||
await this.timelock.release();
|
||||
await expectThrow(this.timelock.release());
|
||||
const balance = await this.token.balanceOf(beneficiary);
|
||||
balance.should.be.bignumber.equal(amount);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user