Replace chai.should with chai.expect (#1780)

* changed exxpect to expect wherever applicable

* Merged with latest branch

* Updated merkleTree helper to latest master branch

* Made linting fixes

* Fix for test build

* updated for Coverage

* Updated Address.test.js

* Undo package-lock changes.
This commit is contained in:
Yohann Pereira
2019-06-24 16:40:05 -04:00
committed by Francisco Giordano
parent 852e11c2db
commit 489d2e85f1
57 changed files with 564 additions and 453 deletions

View File

@ -1,5 +1,7 @@
const { expectRevert } = require('openzeppelin-test-helpers');
const { expect } = require('chai');
const CountersImpl = artifacts.require('CountersImpl');
contract('Counters', function () {
@ -8,13 +10,13 @@ contract('Counters', function () {
});
it('starts at zero', async function () {
(await this.counter.current()).should.be.bignumber.equal('0');
expect(await this.counter.current()).to.be.bignumber.equal('0');
});
describe('increment', function () {
it('increments the current value by one', async function () {
await this.counter.increment();
(await this.counter.current()).should.be.bignumber.equal('1');
expect(await this.counter.current()).to.be.bignumber.equal('1');
});
it('can be called multiple times', async function () {
@ -22,19 +24,19 @@ contract('Counters', function () {
await this.counter.increment();
await this.counter.increment();
(await this.counter.current()).should.be.bignumber.equal('3');
expect(await this.counter.current()).to.be.bignumber.equal('3');
});
});
describe('decrement', function () {
beforeEach(async function () {
await this.counter.increment();
(await this.counter.current()).should.be.bignumber.equal('1');
expect(await this.counter.current()).to.be.bignumber.equal('1');
});
it('decrements the current value by one', async function () {
await this.counter.decrement();
(await this.counter.current()).should.be.bignumber.equal('0');
expect(await this.counter.current()).to.be.bignumber.equal('0');
});
it('reverts if the current value is 0', async function () {
@ -46,13 +48,13 @@ contract('Counters', function () {
await this.counter.increment();
await this.counter.increment();
(await this.counter.current()).should.be.bignumber.equal('3');
expect(await this.counter.current()).to.be.bignumber.equal('3');
await this.counter.decrement();
await this.counter.decrement();
await this.counter.decrement();
(await this.counter.current()).should.be.bignumber.equal('0');
expect(await this.counter.current()).to.be.bignumber.equal('0');
});
});
});

View File

@ -2,6 +2,8 @@ require('openzeppelin-test-helpers');
const ERC20MetadataMock = artifacts.require('ERC20MetadataMock');
const { expect } = require('chai');
const metadataURI = 'https://example.com';
describe('ERC20Metadata', function () {
@ -10,14 +12,14 @@ describe('ERC20Metadata', function () {
});
it('responds with the metadata', async function () {
(await this.token.tokenURI()).should.equal(metadataURI);
expect(await this.token.tokenURI()).to.equal(metadataURI);
});
describe('setTokenURI', function () {
it('changes the original URI', async function () {
const newMetadataURI = 'https://betterexample.com';
await this.token.setTokenURI(newMetadataURI);
(await this.token.tokenURI()).should.equal(newMetadataURI);
expect(await this.token.tokenURI()).to.equal(newMetadataURI);
});
});
});

View File

@ -1,6 +1,8 @@
const { BN, constants, expectRevert } = require('openzeppelin-test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const ERC20Mock = artifacts.require('ERC20Mock');
const ERC20Mintable = artifacts.require('ERC20Mintable');
const ERC20Migrator = artifacts.require('ERC20Migrator');
@ -22,7 +24,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
});
it('returns legacy token', async function () {
(await this.migrator.legacyToken()).should.be.equal(this.legacyToken.address);
expect(await this.migrator.legacyToken()).to.equal(this.legacyToken.address);
});
describe('beginMigration', function () {
@ -54,7 +56,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
context('before starting the migration', function () {
it('returns the zero address for the new token', async function () {
(await this.migrator.newToken()).should.be.equal(ZERO_ADDRESS);
expect(await this.migrator.newToken()).to.equal(ZERO_ADDRESS);
});
describe('migrateAll', function () {
@ -97,7 +99,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
});
it('returns new token', async function () {
(await this.migrator.newToken()).should.be.equal(this.newToken.address);
expect(await this.migrator.newToken()).to.equal(this.newToken.address);
});
describe('migrateAll', function () {
@ -117,20 +119,20 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
it('mints the same balance of the new token', async function () {
const currentBalance = await this.newToken.balanceOf(owner);
currentBalance.should.be.bignumber.equal(amount);
expect(currentBalance).to.be.bignumber.equal(amount);
});
it('burns a given amount of old tokens', async function () {
const currentBurnedBalance = await this.legacyToken.balanceOf(this.migrator.address);
currentBurnedBalance.should.be.bignumber.equal(amount);
expect(currentBurnedBalance).to.be.bignumber.equal(amount);
const currentLegacyTokenBalance = await this.legacyToken.balanceOf(owner);
currentLegacyTokenBalance.should.be.bignumber.equal('0');
expect(currentLegacyTokenBalance).to.be.bignumber.equal('0');
});
it('updates the total supply', async function () {
const currentSupply = await this.newToken.totalSupply();
currentSupply.should.be.bignumber.equal(amount);
expect(currentSupply).to.be.bignumber.equal(amount);
});
});
@ -144,7 +146,7 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
it('migrates only approved amount', async function () {
const currentBalance = await this.newToken.balanceOf(owner);
currentBalance.should.be.bignumber.equal(amount);
expect(currentBalance).to.be.bignumber.equal(amount);
});
});
});
@ -165,20 +167,20 @@ contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
it('mints that amount of the new token', async function () {
const currentBalance = await this.newToken.balanceOf(owner);
currentBalance.should.be.bignumber.equal(amount);
expect(currentBalance).to.be.bignumber.equal(amount);
});
it('burns a given amount of old tokens', async function () {
const currentBurnedBalance = await this.legacyToken.balanceOf(this.migrator.address);
currentBurnedBalance.should.be.bignumber.equal(amount);
expect(currentBurnedBalance).to.be.bignumber.equal(amount);
const currentLegacyTokenBalance = await this.legacyToken.balanceOf(owner);
currentLegacyTokenBalance.should.be.bignumber.equal(totalSupply.sub(amount));
expect(currentLegacyTokenBalance).to.be.bignumber.equal(totalSupply.sub(amount));
});
it('updates the total supply', async function () {
const currentSupply = await this.newToken.totalSupply();
currentSupply.should.be.bignumber.equal(amount);
expect(currentSupply).to.be.bignumber.equal(amount);
});
});

View File

@ -1,6 +1,8 @@
const { BN, expectEvent, expectRevert } = require('openzeppelin-test-helpers');
const ERC20SnapshotMock = artifacts.require('ERC20SnapshotMock');
const { expect } = require('chai');
contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) {
const initialSupply = new BN(100);
@ -41,7 +43,7 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) {
context('with no supply changes after the snapshot', function () {
it('returns the current total supply', async function () {
(await this.token.totalSupplyAt(this.initialSnapshotId)).should.be.bignumber.equal(initialSupply);
expect(await this.token.totalSupplyAt(this.initialSnapshotId)).to.be.bignumber.equal(initialSupply);
});
});
@ -52,7 +54,7 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) {
});
it('returns the total supply before the changes', async function () {
(await this.token.totalSupplyAt(this.initialSnapshotId)).should.be.bignumber.equal(initialSupply);
expect(await this.token.totalSupplyAt(this.initialSnapshotId)).to.be.bignumber.equal(initialSupply);
});
context('with a second snapshot after supply changes', function () {
@ -64,9 +66,9 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) {
});
it('snapshots return the supply before and after the changes', async function () {
(await this.token.totalSupplyAt(this.initialSnapshotId)).should.be.bignumber.equal(initialSupply);
expect(await this.token.totalSupplyAt(this.initialSnapshotId)).to.be.bignumber.equal(initialSupply);
(await this.token.totalSupplyAt(this.secondSnapshotId)).should.be.bignumber.equal(
expect(await this.token.totalSupplyAt(this.secondSnapshotId)).to.be.bignumber.equal(
await this.token.totalSupply()
);
});
@ -83,12 +85,12 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) {
});
it('all posterior snapshots return the supply after the changes', async function () {
(await this.token.totalSupplyAt(this.initialSnapshotId)).should.be.bignumber.equal(initialSupply);
expect(await this.token.totalSupplyAt(this.initialSnapshotId)).to.be.bignumber.equal(initialSupply);
const currentSupply = await this.token.totalSupply();
for (const id of this.secondSnapshotIds) {
(await this.token.totalSupplyAt(id)).should.be.bignumber.equal(currentSupply);
expect(await this.token.totalSupplyAt(id)).to.be.bignumber.equal(currentSupply);
}
});
});
@ -115,10 +117,10 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) {
context('with no balance changes after the snapshot', function () {
it('returns the current balance for all accounts', async function () {
(await this.token.balanceOfAt(initialHolder, this.initialSnapshotId))
.should.be.bignumber.equal(initialSupply);
(await this.token.balanceOfAt(recipient, this.initialSnapshotId)).should.be.bignumber.equal('0');
(await this.token.balanceOfAt(other, this.initialSnapshotId)).should.be.bignumber.equal('0');
expect(await this.token.balanceOfAt(initialHolder, this.initialSnapshotId))
.to.be.bignumber.equal(initialSupply);
expect(await this.token.balanceOfAt(recipient, this.initialSnapshotId)).to.be.bignumber.equal('0');
expect(await this.token.balanceOfAt(other, this.initialSnapshotId)).to.be.bignumber.equal('0');
});
});
@ -130,10 +132,10 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) {
});
it('returns the balances before the changes', async function () {
(await this.token.balanceOfAt(initialHolder, this.initialSnapshotId))
.should.be.bignumber.equal(initialSupply);
(await this.token.balanceOfAt(recipient, this.initialSnapshotId)).should.be.bignumber.equal('0');
(await this.token.balanceOfAt(other, this.initialSnapshotId)).should.be.bignumber.equal('0');
expect(await this.token.balanceOfAt(initialHolder, this.initialSnapshotId))
.to.be.bignumber.equal(initialSupply);
expect(await this.token.balanceOfAt(recipient, this.initialSnapshotId)).to.be.bignumber.equal('0');
expect(await this.token.balanceOfAt(other, this.initialSnapshotId)).to.be.bignumber.equal('0');
});
context('with a second snapshot after supply changes', function () {
@ -145,18 +147,18 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) {
});
it('snapshots return the balances before and after the changes', async function () {
(await this.token.balanceOfAt(initialHolder, this.initialSnapshotId))
.should.be.bignumber.equal(initialSupply);
(await this.token.balanceOfAt(recipient, this.initialSnapshotId)).should.be.bignumber.equal('0');
(await this.token.balanceOfAt(other, this.initialSnapshotId)).should.be.bignumber.equal('0');
expect(await this.token.balanceOfAt(initialHolder, this.initialSnapshotId))
.to.be.bignumber.equal(initialSupply);
expect(await this.token.balanceOfAt(recipient, this.initialSnapshotId)).to.be.bignumber.equal('0');
expect(await this.token.balanceOfAt(other, this.initialSnapshotId)).to.be.bignumber.equal('0');
(await this.token.balanceOfAt(initialHolder, this.secondSnapshotId)).should.be.bignumber.equal(
expect(await this.token.balanceOfAt(initialHolder, this.secondSnapshotId)).to.be.bignumber.equal(
await this.token.balanceOf(initialHolder)
);
(await this.token.balanceOfAt(recipient, this.secondSnapshotId)).should.be.bignumber.equal(
expect(await this.token.balanceOfAt(recipient, this.secondSnapshotId)).to.be.bignumber.equal(
await this.token.balanceOf(recipient)
);
(await this.token.balanceOfAt(other, this.secondSnapshotId)).should.be.bignumber.equal(
expect(await this.token.balanceOfAt(other, this.secondSnapshotId)).to.be.bignumber.equal(
await this.token.balanceOf(other)
);
});
@ -173,19 +175,19 @@ contract('ERC20Snapshot', function ([_, initialHolder, recipient, other]) {
});
it('all posterior snapshots return the supply after the changes', async function () {
(await this.token.balanceOfAt(initialHolder, this.initialSnapshotId))
.should.be.bignumber.equal(initialSupply);
(await this.token.balanceOfAt(recipient, this.initialSnapshotId)).should.be.bignumber.equal('0');
(await this.token.balanceOfAt(other, this.initialSnapshotId)).should.be.bignumber.equal('0');
expect(await this.token.balanceOfAt(initialHolder, this.initialSnapshotId))
.to.be.bignumber.equal(initialSupply);
expect(await this.token.balanceOfAt(recipient, this.initialSnapshotId)).to.be.bignumber.equal('0');
expect(await this.token.balanceOfAt(other, this.initialSnapshotId)).to.be.bignumber.equal('0');
for (const id of this.secondSnapshotIds) {
(await this.token.balanceOfAt(initialHolder, id)).should.be.bignumber.equal(
expect(await this.token.balanceOfAt(initialHolder, id)).to.be.bignumber.equal(
await this.token.balanceOf(initialHolder)
);
(await this.token.balanceOfAt(recipient, id)).should.be.bignumber.equal(
expect(await this.token.balanceOfAt(recipient, id)).to.be.bignumber.equal(
await this.token.balanceOf(recipient)
);
(await this.token.balanceOfAt(other, id)).should.be.bignumber.equal(
expect(await this.token.balanceOfAt(other, id)).to.be.bignumber.equal(
await this.token.balanceOf(other)
);
}

View File

@ -2,6 +2,8 @@ const { expectRevert } = require('openzeppelin-test-helpers');
const { getSignFor } = require('../helpers/sign');
const { shouldBehaveLikePublicRole } = require('../behaviors/access/roles/PublicRole.behavior');
const { expect } = require('chai');
const SignatureBouncerMock = artifacts.require('SignatureBouncerMock');
const UINT_VALUE = 23;
@ -140,79 +142,80 @@ contract('SignatureBouncer', function ([_, signer, otherSigner, other, authorize
context('signature validation', function () {
context('plain signature', function () {
it('validates valid signature for valid user', async function () {
(await this.sigBouncer.checkValidSignature(authorizedUser, await this.signFor(authorizedUser)))
.should.equal(true);
expect(await this.sigBouncer.checkValidSignature(authorizedUser, await this.signFor(authorizedUser)))
.to.equal(true);
});
it('does not validate invalid signature for valid user', async function () {
(await this.sigBouncer.checkValidSignature(authorizedUser, INVALID_SIGNATURE)).should.equal(false);
expect(await this.sigBouncer.checkValidSignature(authorizedUser, INVALID_SIGNATURE)).to.equal(false);
});
it('does not validate valid signature for anyone', async function () {
(await this.sigBouncer.checkValidSignature(other, await this.signFor(authorizedUser))).should.equal(false);
expect(await this.sigBouncer.checkValidSignature(other, await this.signFor(authorizedUser))).to.equal(false);
});
it('does not validate valid signature for method for valid user', async function () {
(await this.sigBouncer.checkValidSignature(
expect(await this.sigBouncer.checkValidSignature(
authorizedUser, await this.signFor(authorizedUser, 'checkValidSignature'))
).should.equal(false);
).to.equal(false);
});
});
context('method signature', function () {
it('validates valid signature with correct method for valid user', async function () {
(await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser,
expect(await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser,
await this.signFor(authorizedUser, 'checkValidSignatureAndMethod'))
).should.equal(true);
).to.equal(true);
});
it('does not validate invalid signature with correct method for valid user', async function () {
(await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser, INVALID_SIGNATURE)).should.equal(false);
expect(await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser, INVALID_SIGNATURE)).to.equal(false);
});
it('does not validate valid signature with correct method for anyone', async function () {
(await this.sigBouncer.checkValidSignatureAndMethod(other,
expect(await this.sigBouncer.checkValidSignatureAndMethod(other,
await this.signFor(authorizedUser, 'checkValidSignatureAndMethod'))
).should.equal(false);
).to.equal(false);
});
it('does not validate valid non-method signature with correct method for valid user', async function () {
(await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser, await this.signFor(authorizedUser))
).should.equal(false);
expect(await this.sigBouncer.checkValidSignatureAndMethod(authorizedUser, await this.signFor(authorizedUser))
).to.equal(false);
});
});
context('method and data signature', function () {
it('validates valid signature with correct method and data for valid user', async function () {
(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE,
expect(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE,
await this.signFor(authorizedUser, 'checkValidSignatureAndData', [authorizedUser, BYTES_VALUE, UINT_VALUE]))
).should.equal(true);
).to.equal(true);
});
it('does not validate invalid signature with correct method and data for valid user', async function () {
(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE, INVALID_SIGNATURE)
).should.equal(false);
expect(
await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE, INVALID_SIGNATURE)
).to.equal(false);
});
it('does not validate valid signature with correct method and incorrect data for valid user',
async function () {
(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE + 10,
expect(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE + 10,
await this.signFor(authorizedUser, 'checkValidSignatureAndData', [authorizedUser, BYTES_VALUE, UINT_VALUE]))
).should.equal(false);
).to.equal(false);
}
);
it('does not validate valid signature with correct method and data for anyone', async function () {
(await this.sigBouncer.checkValidSignatureAndData(other, BYTES_VALUE, UINT_VALUE,
expect(await this.sigBouncer.checkValidSignatureAndData(other, BYTES_VALUE, UINT_VALUE,
await this.signFor(authorizedUser, 'checkValidSignatureAndData', [authorizedUser, BYTES_VALUE, UINT_VALUE]))
).should.equal(false);
).that.equal(false);
});
it('does not validate valid non-method-data signature with correct method and data for valid user',
async function () {
(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE,
expect(await this.sigBouncer.checkValidSignatureAndData(authorizedUser, BYTES_VALUE, UINT_VALUE,
await this.signFor(authorizedUser, 'checkValidSignatureAndData'))
).should.equal(false);
).to.equal(false);
}
);
});

View File

@ -1,6 +1,8 @@
const { BN, constants, expectRevert } = require('openzeppelin-test-helpers');
const { MAX_INT256, MIN_INT256 } = constants;
const { expect } = require('chai');
const SignedSafeMathMock = artifacts.require('SignedSafeMathMock');
contract('SignedSafeMath', function () {
@ -9,8 +11,8 @@ contract('SignedSafeMath', function () {
});
async function testCommutative (fn, lhs, rhs, expected) {
(await fn(lhs, rhs)).should.be.bignumber.equal(expected);
(await fn(rhs, lhs)).should.be.bignumber.equal(expected);
expect(await fn(lhs, rhs)).to.be.bignumber.equal(expected);
expect(await fn(rhs, lhs)).to.be.bignumber.equal(expected);
}
async function testFailsCommutative (fn, lhs, rhs, reason) {
@ -54,7 +56,7 @@ contract('SignedSafeMath', function () {
const b = new BN('1234');
const result = await this.safeMath.sub(a, b);
result.should.be.bignumber.equal(a.sub(b));
expect(result).to.be.bignumber.equal(a.sub(b));
});
it('subtracts correctly if it does not overflow and the result is negative', async function () {
@ -62,7 +64,7 @@ contract('SignedSafeMath', function () {
const b = new BN('5678');
const result = await this.safeMath.sub(a, b);
result.should.be.bignumber.equal(a.sub(b));
expect(result).to.be.bignumber.equal(a.sub(b));
});
it('reverts on positive subtraction overflow', async function () {
@ -116,21 +118,21 @@ contract('SignedSafeMath', function () {
const b = new BN('5678');
const result = await this.safeMath.div(a, b);
result.should.be.bignumber.equal(a.div(b));
expect(result).to.be.bignumber.equal(a.div(b));
});
it('divides zero correctly', async function () {
const a = new BN('0');
const b = new BN('5678');
(await this.safeMath.div(a, b)).should.be.bignumber.equal('0');
expect(await this.safeMath.div(a, b)).to.be.bignumber.equal('0');
});
it('returns complete number result on non-even division', async function () {
const a = new BN('7000');
const b = new BN('5678');
(await this.safeMath.div(a, b)).should.be.bignumber.equal('1');
expect(await this.safeMath.div(a, b)).to.be.bignumber.equal('1');
});
it('reverts on division by zero', async function () {

View File

@ -1,5 +1,7 @@
const { constants } = require('openzeppelin-test-helpers');
const { expect } = require('chai');
const StringsMock = artifacts.require('StringsMock');
contract('Strings', function () {
@ -9,15 +11,15 @@ contract('Strings', function () {
describe('from uint256', function () {
it('converts 0', async function () {
(await this.strings.fromUint256(0)).should.equal('0');
expect(await this.strings.fromUint256(0)).to.equal('0');
});
it('converts a positive number', async function () {
(await this.strings.fromUint256(4132)).should.equal('4132');
expect(await this.strings.fromUint256(4132)).to.equal('4132');
});
it('converts MAX_UINT256', async function () {
(await this.strings.fromUint256(constants.MAX_UINT256)).should.equal(constants.MAX_UINT256.toString());
expect(await this.strings.fromUint256(constants.MAX_UINT256)).to.equal(constants.MAX_UINT256.toString());
});
});
});

View File

@ -1,6 +1,8 @@
const { BN, constants, expectEvent, expectRevert, time } = require('openzeppelin-test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const ERC20Mintable = artifacts.require('ERC20Mintable');
const TokenVesting = artifacts.require('TokenVesting');
@ -18,7 +20,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
const cliffDuration = this.duration;
const duration = this.cliffDuration;
cliffDuration.should.be.bignumber.that.is.at.least(duration);
expect(cliffDuration).to.be.bignumber.that.is.at.least(duration);
await expectRevert(
TokenVesting.new(beneficiary, this.start, cliffDuration, duration, true, { from: owner }),
@ -60,11 +62,11 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
});
it('can get state', async function () {
(await this.vesting.beneficiary()).should.be.equal(beneficiary);
(await this.vesting.cliff()).should.be.bignumber.equal(this.start.add(this.cliffDuration));
(await this.vesting.start()).should.be.bignumber.equal(this.start);
(await this.vesting.duration()).should.be.bignumber.equal(this.duration);
(await this.vesting.revocable()).should.be.equal(true);
expect(await this.vesting.beneficiary()).to.equal(beneficiary);
expect(await this.vesting.cliff()).to.be.bignumber.equal(this.start.add(this.cliffDuration));
expect(await this.vesting.start()).to.be.bignumber.equal(this.start);
expect(await this.vesting.duration()).to.be.bignumber.equal(this.duration);
expect(await this.vesting.revocable()).to.be.equal(true);
});
it('cannot be released before cliff', async function () {
@ -89,8 +91,8 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
const releaseTime = await time.latest();
const releasedAmount = amount.mul(releaseTime.sub(this.start)).div(this.duration);
(await this.token.balanceOf(beneficiary)).should.bignumber.equal(releasedAmount);
(await this.vesting.released(this.token.address)).should.bignumber.equal(releasedAmount);
expect(await this.token.balanceOf(beneficiary)).to.be.bignumber.equal(releasedAmount);
expect(await this.vesting.released(this.token.address)).to.be.bignumber.equal(releasedAmount);
});
it('should linearly release tokens during vesting period', async function () {
@ -103,22 +105,22 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
await this.vesting.release(this.token.address);
const expectedVesting = amount.mul(now.sub(this.start)).div(this.duration);
(await this.token.balanceOf(beneficiary)).should.bignumber.equal(expectedVesting);
(await this.vesting.released(this.token.address)).should.bignumber.equal(expectedVesting);
expect(await this.token.balanceOf(beneficiary)).to.be.bignumber.equal(expectedVesting);
expect(await this.vesting.released(this.token.address)).to.be.bignumber.equal(expectedVesting);
}
});
it('should have released all after end', async function () {
await time.increaseTo(this.start.add(this.duration));
await this.vesting.release(this.token.address);
(await this.token.balanceOf(beneficiary)).should.bignumber.equal(amount);
(await this.vesting.released(this.token.address)).should.bignumber.equal(amount);
expect(await this.token.balanceOf(beneficiary)).to.be.bignumber.equal(amount);
expect(await this.vesting.released(this.token.address)).to.be.bignumber.equal(amount);
});
it('should be revoked by owner if revocable is set', async function () {
const { logs } = await this.vesting.revoke(this.token.address, { from: owner });
expectEvent.inLogs(logs, 'TokenVestingRevoked', { token: this.token.address });
(await this.vesting.revoked(this.token.address)).should.equal(true);
expect(await this.vesting.revoked(this.token.address)).to.equal(true);
});
it('should fail to be revoked by owner if revocable not set', async function () {
@ -138,7 +140,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
await this.vesting.revoke(this.token.address, { from: owner });
(await this.token.balanceOf(owner)).should.bignumber.equal(amount.sub(vested));
expect(await this.token.balanceOf(owner)).to.be.bignumber.equal(amount.sub(vested));
});
it('should keep the vested tokens when revoked by owner', async function () {
@ -150,7 +152,7 @@ contract('TokenVesting', function ([_, owner, beneficiary]) {
const vestedPost = vestedAmount(amount, await time.latest(), this.start, this.cliffDuration, this.duration);
vestedPre.should.bignumber.equal(vestedPost);
expect(vestedPre).to.be.bignumber.equal(vestedPost);
});
it('should fail to be revoked a second time', async function () {