Use hardhat-exposed to reduce the need for mocks (#3666)

Co-authored-by: Francisco <fg@frang.io>
This commit is contained in:
Hadrien Croubois
2023-01-03 15:38:13 +01:00
committed by GitHub
parent a81b0d0b21
commit c1d9da4052
190 changed files with 2297 additions and 4311 deletions

View File

@ -2,33 +2,33 @@ const { BN, constants } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const { MIN_INT256, MAX_INT256 } = constants;
const SignedMathMock = artifacts.require('SignedMathMock');
const SignedMath = artifacts.require('$SignedMath');
contract('SignedMath', function () {
const min = new BN('-1234');
const max = new BN('5678');
beforeEach(async function () {
this.math = await SignedMathMock.new();
this.math = await SignedMath.new();
});
describe('max', function () {
it('is correctly detected in first argument position', async function () {
expect(await this.math.max(max, min)).to.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 () {
expect(await this.math.max(min, max)).to.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 () {
expect(await this.math.min(min, max)).to.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 () {
expect(await this.math.min(max, min)).to.be.bignumber.equal(min);
expect(await this.math.$min(max, min)).to.be.bignumber.equal(min);
});
});
@ -68,7 +68,7 @@ contract('SignedMath', function () {
for (const x of valuesX) {
for (const y of valuesY) {
expect(await this.math.average(x, y))
expect(await this.math.$average(x, y))
.to.be.bignumber.equal(bnAverage(x, y), `Bad result for average(${x}, ${y})`);
}
}
@ -86,7 +86,7 @@ contract('SignedMath', function () {
MAX_INT256,
]) {
it(`correctly computes the absolute value of ${n}`, async function () {
expect(await this.math.abs(n)).to.be.bignumber.equal(n.abs());
expect(await this.math.$abs(n)).to.be.bignumber.equal(n.abs());
});
}
});