`@0x/contracts-exchange-libs: Appease the linter and prettier gods.
This commit is contained in:
@@ -1,9 +1,4 @@
|
||||
import {
|
||||
blockchainTests,
|
||||
constants,
|
||||
describe,
|
||||
expect,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { blockchainTests, constants, describe, expect } from '@0x/contracts-test-utils';
|
||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
@@ -41,58 +36,54 @@ blockchainTests('LibFillResults', env => {
|
||||
];
|
||||
|
||||
it('matches the output of the reference function', async () => {
|
||||
const [ a, b ] = DEFAULT_FILL_RESULTS;
|
||||
const [a, b] = DEFAULT_FILL_RESULTS;
|
||||
const expected = ReferenceFunctions.addFillResults(a, b);
|
||||
const actual = await libsContract.addFillResults.callAsync(a, b);
|
||||
expect(actual).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
it('reverts if computing `makerAssetFilledAmount` overflows', async () => {
|
||||
const [ a, b ] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
b.makerAssetFilledAmount = MAX_UINT256;
|
||||
const expectedError = new SafeMathRevertErrors.SafeMathError(
|
||||
SafeMathRevertErrors.SafeMathErrorCodes.Uint256AdditionOverflow,
|
||||
a.makerAssetFilledAmount,
|
||||
b.makerAssetFilledAmount,
|
||||
);
|
||||
return expect(libsContract.addFillResults.callAsync(a, b))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
it('reverts if computing `takerAssetFilledAmount` overflows', async () => {
|
||||
const [ a, b ] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
b.takerAssetFilledAmount = MAX_UINT256;
|
||||
const expectedError = new SafeMathRevertErrors.SafeMathError(
|
||||
SafeMathRevertErrors.SafeMathErrorCodes.Uint256AdditionOverflow,
|
||||
a.takerAssetFilledAmount,
|
||||
b.takerAssetFilledAmount,
|
||||
);
|
||||
return expect(libsContract.addFillResults.callAsync(a, b))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
it('reverts if computing `makerFeePaid` overflows', async () => {
|
||||
const [ a, b ] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
b.makerFeePaid = MAX_UINT256;
|
||||
const expectedError = new SafeMathRevertErrors.SafeMathError(
|
||||
SafeMathRevertErrors.SafeMathErrorCodes.Uint256AdditionOverflow,
|
||||
a.makerFeePaid,
|
||||
b.makerFeePaid,
|
||||
);
|
||||
return expect(libsContract.addFillResults.callAsync(a, b))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
it('reverts if computing `takerFeePaid` overflows', async () => {
|
||||
const [ a, b ] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
b.takerFeePaid = MAX_UINT256;
|
||||
const expectedError = new SafeMathRevertErrors.SafeMathError(
|
||||
SafeMathRevertErrors.SafeMathErrorCodes.Uint256AdditionOverflow,
|
||||
a.takerFeePaid,
|
||||
b.takerFeePaid,
|
||||
);
|
||||
return expect(libsContract.addFillResults.callAsync(a, b))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(libsContract.addFillResults.callAsync(a, b)).to.revertWith(expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,17 +26,13 @@ blockchainTests('LibMath', env => {
|
||||
});
|
||||
|
||||
// Wrap a reference function with identical arguments in a promise.
|
||||
function createAsyncReferenceFunction<T>(
|
||||
ref: (...args: any[]) => T,
|
||||
): (...args: any[]) => Promise<T> {
|
||||
function createAsyncReferenceFunction<T>(ref: (...args: any[]) => T): (...args: any[]) => Promise<T> {
|
||||
return async (...args: any[]): Promise<T> => {
|
||||
return ref(...args);
|
||||
};
|
||||
}
|
||||
|
||||
function createContractTestFunction<T>(
|
||||
name: string,
|
||||
): (...args: any[]) => Promise<T> {
|
||||
function createContractTestFunction<T>(name: string): (...args: any[]) => Promise<T> {
|
||||
return async (...args: any[]): Promise<T> => {
|
||||
const method = (libsContract as any)[name] as { callAsync: (...args: any[]) => Promise<T> };
|
||||
return method.callAsync(...args);
|
||||
@@ -72,8 +68,9 @@ blockchainTests('LibMath', env => {
|
||||
numerator.times(target),
|
||||
denominator,
|
||||
);
|
||||
return expect(libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(
|
||||
libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target),
|
||||
).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
it('reverts if `numerator * target` overflows', async () => {
|
||||
@@ -85,8 +82,9 @@ blockchainTests('LibMath', env => {
|
||||
numerator,
|
||||
target,
|
||||
);
|
||||
return expect(libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(
|
||||
libsContract.getPartialAmountFloor.callAsync(numerator, denominator, target),
|
||||
).to.revertWith(expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -121,8 +119,9 @@ blockchainTests('LibMath', env => {
|
||||
denominator,
|
||||
new BigNumber(1),
|
||||
);
|
||||
return expect(libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(
|
||||
libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target),
|
||||
).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
it('reverts if `numerator * target` overflows', async () => {
|
||||
@@ -134,8 +133,9 @@ blockchainTests('LibMath', env => {
|
||||
numerator,
|
||||
target,
|
||||
);
|
||||
return expect(libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(
|
||||
libsContract.getPartialAmountCeil.callAsync(numerator, denominator, target),
|
||||
).to.revertWith(expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -164,13 +164,10 @@ blockchainTests('LibMath', env => {
|
||||
const numerator = new BigNumber(1e3);
|
||||
const denominator = new BigNumber(1e4);
|
||||
const target = new BigNumber(333);
|
||||
const expectedError = new LibMathRevertErrors.RoundingError(
|
||||
numerator,
|
||||
denominator,
|
||||
target,
|
||||
);
|
||||
return expect(libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
const expectedError = new LibMathRevertErrors.RoundingError(numerator, denominator, target);
|
||||
return expect(
|
||||
libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target),
|
||||
).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
it('reverts if `denominator` is zero', async () => {
|
||||
@@ -178,8 +175,9 @@ blockchainTests('LibMath', env => {
|
||||
const denominator = ZERO_AMOUNT;
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
const expectedError = new LibMathRevertErrors.DivisionByZeroError();
|
||||
return expect(libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(
|
||||
libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target),
|
||||
).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
it('reverts if `numerator * target` overflows', async () => {
|
||||
@@ -191,8 +189,9 @@ blockchainTests('LibMath', env => {
|
||||
numerator,
|
||||
target,
|
||||
);
|
||||
return expect(libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(
|
||||
libsContract.safeGetPartialAmountFloor.callAsync(numerator, denominator, target),
|
||||
).to.revertWith(expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -221,13 +220,10 @@ blockchainTests('LibMath', env => {
|
||||
const numerator = new BigNumber(1e3);
|
||||
const denominator = new BigNumber(1e4);
|
||||
const target = new BigNumber(333);
|
||||
const expectedError = new LibMathRevertErrors.RoundingError(
|
||||
numerator,
|
||||
denominator,
|
||||
target,
|
||||
);
|
||||
return expect(libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
const expectedError = new LibMathRevertErrors.RoundingError(numerator, denominator, target);
|
||||
return expect(
|
||||
libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target),
|
||||
).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
it('reverts if `denominator` is zero', async () => {
|
||||
@@ -235,8 +231,9 @@ blockchainTests('LibMath', env => {
|
||||
const denominator = ZERO_AMOUNT;
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
const expectedError = new LibMathRevertErrors.DivisionByZeroError();
|
||||
return expect(libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(
|
||||
libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target),
|
||||
).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
it('reverts if `numerator * target` overflows', async () => {
|
||||
@@ -248,8 +245,9 @@ blockchainTests('LibMath', env => {
|
||||
numerator,
|
||||
target,
|
||||
);
|
||||
return expect(libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(
|
||||
libsContract.safeGetPartialAmountCeil.callAsync(numerator, denominator, target),
|
||||
).to.revertWith(expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -269,6 +267,7 @@ blockchainTests('LibMath', env => {
|
||||
const numerator = new BigNumber(1e3);
|
||||
const denominator = new BigNumber(1e4);
|
||||
const target = new BigNumber(333);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const actual = await libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target);
|
||||
expect(actual).to.eq(true);
|
||||
});
|
||||
@@ -277,6 +276,7 @@ blockchainTests('LibMath', env => {
|
||||
const numerator = new BigNumber(1e3);
|
||||
const denominator = new BigNumber(1e4);
|
||||
const target = new BigNumber(5e2);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const actual = await libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target);
|
||||
expect(actual).to.eq(false);
|
||||
});
|
||||
@@ -285,7 +285,9 @@ blockchainTests('LibMath', env => {
|
||||
const numerator = ONE_ETHER;
|
||||
const denominator = ONE_ETHER.dividedToIntegerBy(2);
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const expected = ReferenceFunctions.isRoundingErrorFloor(numerator, denominator, target);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const actual = await libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target);
|
||||
expect(actual).to.eq(expected);
|
||||
});
|
||||
@@ -295,8 +297,9 @@ blockchainTests('LibMath', env => {
|
||||
const denominator = ZERO_AMOUNT;
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
const expectedError = new LibMathRevertErrors.DivisionByZeroError();
|
||||
return expect(libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(
|
||||
libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target),
|
||||
).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
it('reverts if `numerator * target` overflows', async () => {
|
||||
@@ -308,8 +311,9 @@ blockchainTests('LibMath', env => {
|
||||
numerator,
|
||||
target,
|
||||
);
|
||||
return expect(libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(
|
||||
libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target),
|
||||
).to.revertWith(expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -329,7 +333,8 @@ blockchainTests('LibMath', env => {
|
||||
const numerator = new BigNumber(1e3);
|
||||
const denominator = new BigNumber(1e4);
|
||||
const target = new BigNumber(333);
|
||||
const actual = await libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const actual = await libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target);
|
||||
expect(actual).to.eq(true);
|
||||
});
|
||||
|
||||
@@ -337,7 +342,8 @@ blockchainTests('LibMath', env => {
|
||||
const numerator = new BigNumber(1e3);
|
||||
const denominator = new BigNumber(1e4);
|
||||
const target = new BigNumber(5e2);
|
||||
const actual = await libsContract.isRoundingErrorFloor.callAsync(numerator, denominator, target);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const actual = await libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target);
|
||||
expect(actual).to.eq(false);
|
||||
});
|
||||
|
||||
@@ -345,7 +351,9 @@ blockchainTests('LibMath', env => {
|
||||
const numerator = ONE_ETHER;
|
||||
const denominator = ONE_ETHER.dividedToIntegerBy(2);
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const expected = ReferenceFunctions.isRoundingErrorCeil(numerator, denominator, target);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const actual = await libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target);
|
||||
expect(actual).to.eq(expected);
|
||||
});
|
||||
@@ -355,8 +363,9 @@ blockchainTests('LibMath', env => {
|
||||
const denominator = ZERO_AMOUNT;
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
const expectedError = new LibMathRevertErrors.DivisionByZeroError();
|
||||
return expect(libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target)).to.revertWith(
|
||||
expectedError,
|
||||
);
|
||||
});
|
||||
|
||||
it('reverts if `numerator * target` overflows', async () => {
|
||||
@@ -368,8 +377,9 @@ blockchainTests('LibMath', env => {
|
||||
numerator,
|
||||
target,
|
||||
);
|
||||
return expect(libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target))
|
||||
.to.revertWith(expectedError);
|
||||
return expect(libsContract.isRoundingErrorCeil.callAsync(numerator, denominator, target)).to.revertWith(
|
||||
expectedError,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
constants,
|
||||
describe,
|
||||
expect,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { constants, describe, expect } from '@0x/contracts-test-utils';
|
||||
import { LibMathRevertErrors } from '@0x/order-utils';
|
||||
import { BigNumber, SafeMathRevertErrors } from '@0x/utils';
|
||||
import * as _ from 'lodash';
|
||||
@@ -20,7 +16,6 @@ import {
|
||||
describe('Reference Functions', () => {
|
||||
const { ONE_ETHER, MAX_UINT256, MAX_UINT256_ROOT, ZERO_AMOUNT } = constants;
|
||||
describe('LibFillResults', () => {
|
||||
|
||||
describe('addFillResults', () => {
|
||||
const DEFAULT_FILL_RESULTS = [
|
||||
{
|
||||
@@ -38,7 +33,7 @@ describe('Reference Functions', () => {
|
||||
];
|
||||
|
||||
it('reverts if computing `makerAssetFilledAmount` overflows', () => {
|
||||
const [ a, b ] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
b.makerAssetFilledAmount = MAX_UINT256;
|
||||
const expectedError = new SafeMathRevertErrors.SafeMathError(
|
||||
SafeMathRevertErrors.SafeMathErrorCodes.Uint256AdditionOverflow,
|
||||
@@ -49,7 +44,7 @@ describe('Reference Functions', () => {
|
||||
});
|
||||
|
||||
it('reverts if computing `takerAssetFilledAmount` overflows', () => {
|
||||
const [ a, b ] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
b.takerAssetFilledAmount = MAX_UINT256;
|
||||
const expectedError = new SafeMathRevertErrors.SafeMathError(
|
||||
SafeMathRevertErrors.SafeMathErrorCodes.Uint256AdditionOverflow,
|
||||
@@ -60,7 +55,7 @@ describe('Reference Functions', () => {
|
||||
});
|
||||
|
||||
it('reverts if computing `makerFeePaid` overflows', () => {
|
||||
const [ a, b ] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
b.makerFeePaid = MAX_UINT256;
|
||||
const expectedError = new SafeMathRevertErrors.SafeMathError(
|
||||
SafeMathRevertErrors.SafeMathErrorCodes.Uint256AdditionOverflow,
|
||||
@@ -71,7 +66,7 @@ describe('Reference Functions', () => {
|
||||
});
|
||||
|
||||
it('reverts if computing `takerFeePaid` overflows', () => {
|
||||
const [ a, b ] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
b.takerFeePaid = MAX_UINT256;
|
||||
const expectedError = new SafeMathRevertErrors.SafeMathError(
|
||||
SafeMathRevertErrors.SafeMathErrorCodes.Uint256AdditionOverflow,
|
||||
@@ -95,8 +90,9 @@ describe('Reference Functions', () => {
|
||||
numerator.times(target),
|
||||
denominator,
|
||||
);
|
||||
return expect(() => getPartialAmountFloor(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
return expect(() => getPartialAmountFloor(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
});
|
||||
|
||||
it('reverts if `numerator * target` overflows', () => {
|
||||
@@ -108,8 +104,9 @@ describe('Reference Functions', () => {
|
||||
numerator,
|
||||
target,
|
||||
);
|
||||
return expect(() => getPartialAmountFloor(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
return expect(() => getPartialAmountFloor(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -126,8 +123,9 @@ describe('Reference Functions', () => {
|
||||
denominator,
|
||||
new BigNumber(1),
|
||||
);
|
||||
return expect(() => getPartialAmountCeil(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
return expect(() => getPartialAmountCeil(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
});
|
||||
|
||||
it('reverts if `numerator * target` overflows', () => {
|
||||
@@ -139,8 +137,9 @@ describe('Reference Functions', () => {
|
||||
numerator,
|
||||
target,
|
||||
);
|
||||
return expect(() => getPartialAmountCeil(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
return expect(() => getPartialAmountCeil(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -151,13 +150,10 @@ describe('Reference Functions', () => {
|
||||
const numerator = new BigNumber(1e3);
|
||||
const denominator = new BigNumber(1e4);
|
||||
const target = new BigNumber(333);
|
||||
const expectedError = new LibMathRevertErrors.RoundingError(
|
||||
numerator,
|
||||
denominator,
|
||||
target,
|
||||
const expectedError = new LibMathRevertErrors.RoundingError(numerator, denominator, target);
|
||||
return expect(() => safeGetPartialAmountFloor(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
return expect(() => safeGetPartialAmountFloor(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
});
|
||||
|
||||
it('reverts if `denominator` is zero', () => {
|
||||
@@ -165,8 +161,9 @@ describe('Reference Functions', () => {
|
||||
const denominator = ZERO_AMOUNT;
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
const expectedError = new LibMathRevertErrors.DivisionByZeroError();
|
||||
return expect(() => safeGetPartialAmountFloor(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
return expect(() => safeGetPartialAmountFloor(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
});
|
||||
|
||||
it('reverts if `numerator * target` overflows', () => {
|
||||
@@ -178,8 +175,9 @@ describe('Reference Functions', () => {
|
||||
numerator,
|
||||
target,
|
||||
);
|
||||
return expect(() => safeGetPartialAmountFloor(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
return expect(() => safeGetPartialAmountFloor(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -190,13 +188,10 @@ describe('Reference Functions', () => {
|
||||
const numerator = new BigNumber(1e3);
|
||||
const denominator = new BigNumber(1e4);
|
||||
const target = new BigNumber(333);
|
||||
const expectedError = new LibMathRevertErrors.RoundingError(
|
||||
numerator,
|
||||
denominator,
|
||||
target,
|
||||
const expectedError = new LibMathRevertErrors.RoundingError(numerator, denominator, target);
|
||||
return expect(() => safeGetPartialAmountCeil(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
return expect(() => safeGetPartialAmountCeil(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
});
|
||||
|
||||
it('reverts if `denominator` is zero', () => {
|
||||
@@ -204,8 +199,9 @@ describe('Reference Functions', () => {
|
||||
const denominator = ZERO_AMOUNT;
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
const expectedError = new LibMathRevertErrors.DivisionByZeroError();
|
||||
return expect(() => safeGetPartialAmountCeil(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
return expect(() => safeGetPartialAmountCeil(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
});
|
||||
|
||||
it('reverts if `numerator * target` overflows', () => {
|
||||
@@ -217,8 +213,9 @@ describe('Reference Functions', () => {
|
||||
numerator,
|
||||
target,
|
||||
);
|
||||
return expect(() => safeGetPartialAmountCeil(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
return expect(() => safeGetPartialAmountCeil(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -229,6 +226,7 @@ describe('Reference Functions', () => {
|
||||
const numerator = new BigNumber(1e3);
|
||||
const denominator = new BigNumber(1e4);
|
||||
const target = new BigNumber(333);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const actual = isRoundingErrorFloor(numerator, denominator, target);
|
||||
expect(actual).to.eq(true);
|
||||
});
|
||||
@@ -237,6 +235,7 @@ describe('Reference Functions', () => {
|
||||
const numerator = new BigNumber(1e3);
|
||||
const denominator = new BigNumber(1e4);
|
||||
const target = new BigNumber(5e2);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const actual = isRoundingErrorFloor(numerator, denominator, target);
|
||||
expect(actual).to.eq(false);
|
||||
});
|
||||
@@ -246,8 +245,9 @@ describe('Reference Functions', () => {
|
||||
const denominator = ZERO_AMOUNT;
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
const expectedError = new LibMathRevertErrors.DivisionByZeroError();
|
||||
return expect(() => isRoundingErrorFloor(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
return expect(() => isRoundingErrorFloor(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
});
|
||||
|
||||
it('reverts if `numerator * target` overflows', () => {
|
||||
@@ -259,8 +259,9 @@ describe('Reference Functions', () => {
|
||||
numerator,
|
||||
target,
|
||||
);
|
||||
return expect(() => isRoundingErrorFloor(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
return expect(() => isRoundingErrorFloor(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -271,7 +272,8 @@ describe('Reference Functions', () => {
|
||||
const numerator = new BigNumber(1e3);
|
||||
const denominator = new BigNumber(1e4);
|
||||
const target = new BigNumber(333);
|
||||
const actual = isRoundingErrorFloor(numerator, denominator, target);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const actual = isRoundingErrorCeil(numerator, denominator, target);
|
||||
expect(actual).to.eq(true);
|
||||
});
|
||||
|
||||
@@ -279,7 +281,8 @@ describe('Reference Functions', () => {
|
||||
const numerator = new BigNumber(1e3);
|
||||
const denominator = new BigNumber(1e4);
|
||||
const target = new BigNumber(5e2);
|
||||
const actual = isRoundingErrorFloor(numerator, denominator, target);
|
||||
// tslint:disable-next-line: boolean-naming
|
||||
const actual = isRoundingErrorCeil(numerator, denominator, target);
|
||||
expect(actual).to.eq(false);
|
||||
});
|
||||
|
||||
@@ -288,8 +291,9 @@ describe('Reference Functions', () => {
|
||||
const denominator = ZERO_AMOUNT;
|
||||
const target = ONE_ETHER.times(0.01);
|
||||
const expectedError = new LibMathRevertErrors.DivisionByZeroError();
|
||||
return expect(() => isRoundingErrorCeil(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
return expect(() => isRoundingErrorCeil(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
});
|
||||
|
||||
it('reverts if `numerator * target` overflows', () => {
|
||||
@@ -301,8 +305,9 @@ describe('Reference Functions', () => {
|
||||
numerator,
|
||||
target,
|
||||
);
|
||||
return expect(() => isRoundingErrorCeil(numerator, denominator, target))
|
||||
.to.throw(expectedError.message);
|
||||
return expect(() => isRoundingErrorCeil(numerator, denominator, target)).to.throw(
|
||||
expectedError.message,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user