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 { BN } = require('openzeppelin-test-helpers');
const { expect } = require('chai');
const MathMock = artifacts.require('MathMock');
contract('Math', function () {
@ -12,21 +14,21 @@ contract('Math', function () {
describe('max', function () {
it('is correctly detected in first argument position', async function () {
(await this.math.max(max, min)).should.be.bignumber.equal(max);
expect(await this.math.max(max, min)).to.be.bignumber.equal(max);
});
it('is correctly detected in second argument position', async function () {
(await this.math.max(min, max)).should.be.bignumber.equal(max);
expect(await this.math.max(min, max)).to.be.bignumber.equal(max);
});
});
describe('min', function () {
it('is correctly detected in first argument position', async function () {
(await this.math.min(min, max)).should.be.bignumber.equal(min);
expect(await this.math.min(min, max)).to.be.bignumber.equal(min);
});
it('is correctly detected in second argument position', async function () {
(await this.math.min(max, min)).should.be.bignumber.equal(min);
expect(await this.math.min(max, min)).to.be.bignumber.equal(min);
});
});
@ -38,19 +40,19 @@ contract('Math', function () {
it('is correctly calculated with two odd numbers', async function () {
const a = new BN('57417');
const b = new BN('95431');
(await this.math.average(a, b)).should.be.bignumber.equal(bnAverage(a, b));
expect(await this.math.average(a, b)).to.be.bignumber.equal(bnAverage(a, b));
});
it('is correctly calculated with two even numbers', async function () {
const a = new BN('42304');
const b = new BN('84346');
(await this.math.average(a, b)).should.be.bignumber.equal(bnAverage(a, b));
expect(await this.math.average(a, b)).to.be.bignumber.equal(bnAverage(a, b));
});
it('is correctly calculated with one even and one odd number', async function () {
const a = new BN('57417');
const b = new BN('84346');
(await this.math.average(a, b)).should.be.bignumber.equal(bnAverage(a, b));
expect(await this.math.average(a, b)).to.be.bignumber.equal(bnAverage(a, b));
});
});
});

View File

@ -1,6 +1,8 @@
const { BN, constants, expectRevert } = require('openzeppelin-test-helpers');
const { MAX_UINT256 } = constants;
const { expect } = require('chai');
const SafeMathMock = artifacts.require('SafeMathMock');
contract('SafeMath', function () {
@ -9,8 +11,8 @@ contract('SafeMath', 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) {
@ -39,7 +41,7 @@ contract('SafeMath', function () {
const a = new BN('5678');
const b = new BN('1234');
(await this.safeMath.sub(a, b)).should.be.bignumber.equal(a.sub(b));
expect(await this.safeMath.sub(a, b)).to.be.bignumber.equal(a.sub(b));
});
it('reverts if subtraction result would be negative', async function () {
@ -78,21 +80,21 @@ contract('SafeMath', function () {
const a = new BN('5678');
const b = new BN('5678');
(await this.safeMath.div(a, b)).should.be.bignumber.equal(a.div(b));
expect(await this.safeMath.div(a, b)).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 divison by zero', async function () {
@ -109,28 +111,28 @@ contract('SafeMath', function () {
const a = new BN('284');
const b = new BN('5678');
(await this.safeMath.mod(a, b)).should.be.bignumber.equal(a.mod(b));
expect(await this.safeMath.mod(a, b)).to.be.bignumber.equal(a.mod(b));
});
it('when the dividend is equal to the divisor', async function () {
const a = new BN('5678');
const b = new BN('5678');
(await this.safeMath.mod(a, b)).should.be.bignumber.equal(a.mod(b));
expect(await this.safeMath.mod(a, b)).to.be.bignumber.equal(a.mod(b));
});
it('when the dividend is larger than the divisor', async function () {
const a = new BN('7000');
const b = new BN('5678');
(await this.safeMath.mod(a, b)).should.be.bignumber.equal(a.mod(b));
expect(await this.safeMath.mod(a, b)).to.be.bignumber.equal(a.mod(b));
});
it('when the dividend is a multiple of the divisor', async function () {
const a = new BN('17034'); // 17034 == 5678 * 3
const b = new BN('5678');
(await this.safeMath.mod(a, b)).should.be.bignumber.equal(a.mod(b));
expect(await this.safeMath.mod(a, b)).to.be.bignumber.equal(a.mod(b));
});
});