Merge 3.4 master into solc-0.8 (#2499)

* 3.4.0-rc.0

* Allow manual dispatch of Test CI job

* Update lockfile (#2481)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

* Add "available since" comments in documentation

* Add "available since" comments in documentation

(cherry picked from commit 63a0343dda)

* Remove SafeMathMock compilation warnings (#2497)

* Remove SafeMathMock compilation warnings (#2497)

(cherry picked from commit f4e57fd529)

* 3.4.0

* fix safemath test to use renamed function from the mock

Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
This commit is contained in:
Hadrien Croubois
2021-02-02 22:07:56 +01:00
committed by GitHub
parent 5db7413827
commit 93438eca0b
16 changed files with 55 additions and 27 deletions

View File

@ -172,14 +172,14 @@ contract('SafeMath', function (accounts) {
const a = new BN('5678');
const b = new BN('1234');
await testCommutative(this.safeMath.add, a, b, a.add(b));
await testCommutative(this.safeMath.doAdd, a, b, a.add(b));
});
it('reverts on addition overflow', async function () {
const a = MAX_UINT256;
const b = new BN('1');
await testFailsCommutative(this.safeMath.add, a, b, undefined);
await testFailsCommutative(this.safeMath.doAdd, a, b, undefined);
});
});
@ -188,14 +188,14 @@ contract('SafeMath', function (accounts) {
const a = new BN('5678');
const b = new BN('1234');
expect(await this.safeMath.sub(a, b)).to.be.bignumber.equal(a.sub(b));
expect(await this.safeMath.doSub(a, b)).to.be.bignumber.equal(a.sub(b));
});
it('reverts if subtraction result would be negative', async function () {
const a = new BN('1234');
const b = new BN('5678');
await expectRevert.unspecified(this.safeMath.sub(a, b));
await expectRevert.unspecified(this.safeMath.doSub(a, b));
});
});
@ -204,21 +204,21 @@ contract('SafeMath', function (accounts) {
const a = new BN('1234');
const b = new BN('5678');
await testCommutative(this.safeMath.mul, a, b, a.mul(b));
await testCommutative(this.safeMath.doMul, a, b, a.mul(b));
});
it('multiplies by zero correctly', async function () {
const a = new BN('0');
const b = new BN('5678');
await testCommutative(this.safeMath.mul, a, b, '0');
await testCommutative(this.safeMath.doMul, a, b, '0');
});
it('reverts on multiplication overflow', async function () {
const a = MAX_UINT256;
const b = new BN('2');
await testFailsCommutative(this.safeMath.mul, a, b, undefined);
await testFailsCommutative(this.safeMath.doMul, a, b, undefined);
});
});
@ -227,28 +227,28 @@ contract('SafeMath', function (accounts) {
const a = new BN('5678');
const b = new BN('5678');
expect(await this.safeMath.div(a, b)).to.be.bignumber.equal(a.div(b));
expect(await this.safeMath.doDiv(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');
expect(await this.safeMath.div(a, b)).to.be.bignumber.equal('0');
expect(await this.safeMath.doDiv(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');
expect(await this.safeMath.div(a, b)).to.be.bignumber.equal('1');
expect(await this.safeMath.doDiv(a, b)).to.be.bignumber.equal('1');
});
it('reverts on division by zero', async function () {
const a = new BN('5678');
const b = new BN('0');
await expectRevert.unspecified(this.safeMath.div(a, b));
await expectRevert.unspecified(this.safeMath.doDiv(a, b));
});
});
@ -258,28 +258,28 @@ contract('SafeMath', function (accounts) {
const a = new BN('284');
const b = new BN('5678');
expect(await this.safeMath.mod(a, b)).to.be.bignumber.equal(a.mod(b));
expect(await this.safeMath.doMod(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');
expect(await this.safeMath.mod(a, b)).to.be.bignumber.equal(a.mod(b));
expect(await this.safeMath.doMod(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');
expect(await this.safeMath.mod(a, b)).to.be.bignumber.equal(a.mod(b));
expect(await this.safeMath.doMod(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');
expect(await this.safeMath.mod(a, b)).to.be.bignumber.equal(a.mod(b));
expect(await this.safeMath.doMod(a, b)).to.be.bignumber.equal(a.mod(b));
});
});
@ -287,7 +287,7 @@ contract('SafeMath', function (accounts) {
const a = new BN('5678');
const b = new BN('0');
await expectRevert.unspecified(this.safeMath.mod(a, b));
await expectRevert.unspecified(this.safeMath.doMod(a, b));
});
});
});