|
@@ -5,10 +5,9 @@ require('chai')
|
|
|
.use(require('chai-bignumber')(BigNumber))
|
|
|
.should()
|
|
|
|
|
|
-import moment from 'moment'
|
|
|
|
|
|
import latestTime from './helpers/latestTime'
|
|
|
-import increaseTime from './helpers/increaseTime'
|
|
|
+import {increaseTimeTo, duration} from './helpers/increaseTime'
|
|
|
|
|
|
const MintableToken = artifacts.require('MintableToken')
|
|
|
const TokenTimelock = artifacts.require('TokenTimelock')
|
|
@@ -19,7 +18,7 @@ contract('TokenTimelock', function ([_, owner, beneficiary]) {
|
|
|
|
|
|
beforeEach(async function () {
|
|
|
this.token = await MintableToken.new({from: owner})
|
|
|
- this.releaseTime = latestTime().add(1, 'year').unix()
|
|
|
+ this.releaseTime = 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})
|
|
|
})
|
|
@@ -29,26 +28,26 @@ contract('TokenTimelock', function ([_, owner, beneficiary]) {
|
|
|
})
|
|
|
|
|
|
it('cannot be released just before time limit', async function () {
|
|
|
- await increaseTime(moment.duration(0.99, 'year').asSeconds())
|
|
|
+ await increaseTimeTo(this.releaseTime - duration.seconds(3))
|
|
|
await this.timelock.release().should.be.rejected
|
|
|
})
|
|
|
|
|
|
it('can be released just after limit', async function () {
|
|
|
- await increaseTime(moment.duration(1.01, 'year').asSeconds())
|
|
|
+ await increaseTimeTo(this.releaseTime + duration.seconds(1))
|
|
|
await this.timelock.release().should.be.fulfilled
|
|
|
const balance = await this.token.balanceOf(beneficiary)
|
|
|
balance.should.be.bignumber.equal(amount)
|
|
|
})
|
|
|
|
|
|
it('can be released after time limit', async function () {
|
|
|
- await increaseTime(moment.duration(2, 'year').asSeconds())
|
|
|
+ await increaseTimeTo(this.releaseTime + duration.years(1))
|
|
|
await this.timelock.release().should.be.fulfilled
|
|
|
const balance = await this.token.balanceOf(beneficiary)
|
|
|
balance.should.be.bignumber.equal(amount)
|
|
|
})
|
|
|
|
|
|
it('cannot be released twice', async function () {
|
|
|
- await increaseTime(moment.duration(2, 'year').asSeconds())
|
|
|
+ await increaseTimeTo(this.releaseTime + duration.years(1))
|
|
|
await this.timelock.release().should.be.fulfilled
|
|
|
await this.timelock.release().should.be.rejected
|
|
|
const balance = await this.token.balanceOf(beneficiary)
|