`@0x/contracts-exchange-libs: Appease the linter and prettier gods.
This commit is contained in:
@@ -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