Merge tag 'v2.1.1' of github.com:OpenZeppelin/openzeppelin-solidity
v2.1.1
This commit is contained in:
@ -1,12 +1,7 @@
|
||||
const { latestTime } = require('../../helpers/latestTime');
|
||||
const { increaseTimeTo, duration } = require('../../helpers/increaseTime');
|
||||
const { expectThrow } = require('../../helpers/expectThrow');
|
||||
const shouldFail = require('../../helpers/shouldFail');
|
||||
const time = require('../../helpers/time');
|
||||
|
||||
const BigNumber = web3.BigNumber;
|
||||
|
||||
require('chai')
|
||||
.use(require('chai-bignumber')(BigNumber))
|
||||
.should();
|
||||
const { BigNumber } = require('../../helpers/setup');
|
||||
|
||||
const ERC20Mintable = artifacts.require('ERC20MintableMock');
|
||||
const TokenTimelock = artifacts.require('TokenTimelockMock');
|
||||
@ -20,15 +15,15 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) {
|
||||
});
|
||||
|
||||
it('rejects a release time in the past', async function () {
|
||||
const pastReleaseTime = (await latestTime()) - duration.years(1);
|
||||
await expectThrow(
|
||||
const pastReleaseTime = (await time.latest()) - time.duration.years(1);
|
||||
await shouldFail.reverting(
|
||||
TokenTimelock.new(this.token.address, beneficiary, pastReleaseTime)
|
||||
);
|
||||
});
|
||||
|
||||
context('once deployed', function () {
|
||||
beforeEach(async function () {
|
||||
this.releaseTime = (await latestTime()) + duration.years(1);
|
||||
this.releaseTime = (await time.latest()) + time.duration.years(1);
|
||||
this.timelock = await TokenTimelock.new(this.token.address, beneficiary, this.releaseTime);
|
||||
await this.token.mint(this.timelock.address, amount, { from: minter });
|
||||
});
|
||||
@ -40,30 +35,30 @@ contract('TokenTimelock', function ([_, minter, beneficiary]) {
|
||||
});
|
||||
|
||||
it('cannot be released before time limit', async function () {
|
||||
await expectThrow(this.timelock.release());
|
||||
await shouldFail.reverting(this.timelock.release());
|
||||
});
|
||||
|
||||
it('cannot be released just before time limit', async function () {
|
||||
await increaseTimeTo(this.releaseTime - duration.seconds(3));
|
||||
await expectThrow(this.timelock.release());
|
||||
await time.increaseTo(this.releaseTime - time.duration.seconds(3));
|
||||
await shouldFail.reverting(this.timelock.release());
|
||||
});
|
||||
|
||||
it('can be released just after limit', async function () {
|
||||
await increaseTimeTo(this.releaseTime + duration.seconds(1));
|
||||
await time.increaseTo(this.releaseTime + time.duration.seconds(1));
|
||||
await this.timelock.release();
|
||||
(await this.token.balanceOf(beneficiary)).should.be.bignumber.equal(amount);
|
||||
});
|
||||
|
||||
it('can be released after time limit', async function () {
|
||||
await increaseTimeTo(this.releaseTime + duration.years(1));
|
||||
await time.increaseTo(this.releaseTime + time.duration.years(1));
|
||||
await this.timelock.release();
|
||||
(await this.token.balanceOf(beneficiary)).should.be.bignumber.equal(amount);
|
||||
});
|
||||
|
||||
it('cannot be released twice', async function () {
|
||||
await increaseTimeTo(this.releaseTime + duration.years(1));
|
||||
await time.increaseTo(this.releaseTime + time.duration.years(1));
|
||||
await this.timelock.release();
|
||||
await expectThrow(this.timelock.release());
|
||||
await shouldFail.reverting(this.timelock.release());
|
||||
(await this.token.balanceOf(beneficiary)).should.be.bignumber.equal(amount);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user