From 696615d392fefdb16d60af5310d7675c9d910ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Triay?= Date: Thu, 28 Sep 2017 15:43:18 -0300 Subject: [PATCH] [TokenVesting] Add linear release test --- test/TokenVesting.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/TokenVesting.js b/test/TokenVesting.js index 001e0cfe4..9f7913bee 100644 --- a/test/TokenVesting.js +++ b/test/TokenVesting.js @@ -48,7 +48,20 @@ contract('TokenVesting', function ([_, owner, beneficiary]) { balance.should.bignumber.equal(amount.mul(releaseTime - this.start).div(this.end - this.start).floor()); }); - it('should linearly release tokens during vesting period'); + it('should linearly release tokens during vesting period', async function () { + const duration = this.end - this.cliff; + const checkpoints = 4; + + for (let i = 1; i <= checkpoints; i++) { + const now = this.cliff + i * (duration / checkpoints); + await increaseTimeTo(now); + + const vested = await this.vesting.vestedAmount(this.token.address); + const expectedVesting = amount.mul(now - this.start).div(this.end - this.start).floor(); + + vested.should.bignumber.equal(expectedVesting); + } + }); it('should have released all after end', async function () { await increaseTimeTo(this.end);