diff options
author | Remco Bloemen <remco@wicked.ventures> | 2018-08-24 05:22:59 +0800 |
---|---|---|
committer | Remco Bloemen <remco@wicked.ventures> | 2018-08-25 05:09:51 +0800 |
commit | 4219af1430f1cfc105d3521616941b7947fde4e3 (patch) | |
tree | 73b7a64c9eb459bc779e556e9c7133aa6c0a7148 /packages/contracts/test/exchange/internal.ts | |
parent | c109d1f5451c43afd92dd0fb4bebb48cba65c661 (diff) | |
download | dexon-sol-tools-4219af1430f1cfc105d3521616941b7947fde4e3.tar dexon-sol-tools-4219af1430f1cfc105d3521616941b7947fde4e3.tar.gz dexon-sol-tools-4219af1430f1cfc105d3521616941b7947fde4e3.tar.bz2 dexon-sol-tools-4219af1430f1cfc105d3521616941b7947fde4e3.tar.lz dexon-sol-tools-4219af1430f1cfc105d3521616941b7947fde4e3.tar.xz dexon-sol-tools-4219af1430f1cfc105d3521616941b7947fde4e3.tar.zst dexon-sol-tools-4219af1430f1cfc105d3521616941b7947fde4e3.zip |
Add DIVISION_BY_ZERO to getPartialAmount for consistency
Diffstat (limited to 'packages/contracts/test/exchange/internal.ts')
-rw-r--r-- | packages/contracts/test/exchange/internal.ts | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/packages/contracts/test/exchange/internal.ts b/packages/contracts/test/exchange/internal.ts index 2f25b1708..48e1e620c 100644 --- a/packages/contracts/test/exchange/internal.ts +++ b/packages/contracts/test/exchange/internal.ts @@ -46,22 +46,6 @@ const emptySignedOrder: SignedOrder = { const overflowErrorForCall = new Error(RevertReason.Uint256Overflow); -async function referenceGetPartialAmountAsync( - numerator: BigNumber, - denominator: BigNumber, - target: BigNumber, -): Promise<BigNumber> { - const invalidOpcodeErrorForCall = new Error(await getInvalidOpcodeErrorMessageForCallAsync()); - const product = numerator.mul(target); - if (product.greaterThan(MAX_UINT256)) { - throw overflowErrorForCall; - } - if (denominator.eq(0)) { - throw invalidOpcodeErrorForCall; - } - return product.dividedToIntegerBy(denominator); -} - describe('Exchange core internal functions', () => { let testExchange: TestExchangeInternalsContract; let invalidOpcodeErrorForCall: Error | undefined; @@ -91,6 +75,21 @@ describe('Exchange core internal functions', () => { // Note(albrow): Don't forget to add beforeEach and afterEach calls to reset // the blockchain state for any tests which modify it! + async function referenceGetPartialAmountAsync( + numerator: BigNumber, + denominator: BigNumber, + target: BigNumber, + ): Promise<BigNumber> { + if (denominator.eq(0)) { + throw divisionByZeroErrorForCall; + } + const product = numerator.mul(target); + if (product.greaterThan(MAX_UINT256)) { + throw overflowErrorForCall; + } + return product.dividedToIntegerBy(denominator); + } + describe('addFillResults', async () => { function makeFillResults(value: BigNumber): FillResults { return { |