aboutsummaryrefslogtreecommitdiffstats
path: root/packages/order-watcher/test
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2018-08-13 10:23:29 +0800
committerJacob Evans <jacob@dekz.net>2018-08-15 11:06:32 +0800
commit622509c508272790e3e69c09cf1a1f9696815147 (patch)
tree0a86370cc0e02a2ede06e48baa5ad123d0617276 /packages/order-watcher/test
parentf9f232f5d9527926cd64027f69491b0bc6e58894 (diff)
downloaddexon-sol-tools-622509c508272790e3e69c09cf1a1f9696815147.tar
dexon-sol-tools-622509c508272790e3e69c09cf1a1f9696815147.tar.gz
dexon-sol-tools-622509c508272790e3e69c09cf1a1f9696815147.tar.bz2
dexon-sol-tools-622509c508272790e3e69c09cf1a1f9696815147.tar.lz
dexon-sol-tools-622509c508272790e3e69c09cf1a1f9696815147.tar.xz
dexon-sol-tools-622509c508272790e3e69c09cf1a1f9696815147.tar.zst
dexon-sol-tools-622509c508272790e3e69c09cf1a1f9696815147.zip
[Order-utils] Order is valid when maker amount is very small
Previously our min fillable calculation would throw a rounding error when encountering a valid order (with a small maker amount). This was inconsistent with the on-chain logic which allowed this order to be filled.
Diffstat (limited to 'packages/order-watcher/test')
-rw-r--r--packages/order-watcher/test/order_watcher_test.ts20
1 files changed, 9 insertions, 11 deletions
diff --git a/packages/order-watcher/test/order_watcher_test.ts b/packages/order-watcher/test/order_watcher_test.ts
index 00962bed0..0f4caeb63 100644
--- a/packages/order-watcher/test/order_watcher_test.ts
+++ b/packages/order-watcher/test/order_watcher_test.ts
@@ -501,25 +501,27 @@ describe('OrderWatcher', () => {
expect(orderState.isValid).to.be.false();
const invalidOrderState = orderState as OrderStateInvalid;
expect(invalidOrderState.orderHash).to.be.equal(orderHash);
- expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.OrderFillRoundingError);
+ expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.OrderAlreadyCancelledOrFilled);
});
orderWatcher.subscribe(callback);
await contractWrappers.exchange.cancelOrderAsync(signedOrder);
})().catch(done);
});
- it('should emit orderStateInvalid when within rounding error range', (done: DoneCallback) => {
+ it('should emit orderStateInvalid when within rounding error range after a partial fill', (done: DoneCallback) => {
(async () => {
- const remainingFillableAmountInBaseUnits = new BigNumber(100);
- signedOrder = await fillScenarios.createFillableSignedOrderAsync(
+ const fillAmountInBaseUnits = new BigNumber(2);
+ const makerAssetAmount = new BigNumber(1001);
+ const takerAssetAmount = new BigNumber(3);
+ signedOrder = await fillScenarios.createAsymmetricFillableSignedOrderAsync(
makerAssetData,
takerAssetData,
makerAddress,
takerAddress,
- fillableAmount,
+ makerAssetAmount,
+ takerAssetAmount,
);
const orderHash = orderHashUtils.getOrderHashHex(signedOrder);
await orderWatcher.addOrderAsync(signedOrder);
-
const callback = callbackErrorReporter.reportNodeCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.false();
const invalidOrderState = orderState as OrderStateInvalid;
@@ -527,11 +529,7 @@ describe('OrderWatcher', () => {
expect(invalidOrderState.error).to.be.equal(ExchangeContractErrs.OrderFillRoundingError);
});
orderWatcher.subscribe(callback);
- await contractWrappers.exchange.fillOrderAsync(
- signedOrder,
- fillableAmount.minus(remainingFillableAmountInBaseUnits),
- takerAddress,
- );
+ await contractWrappers.exchange.fillOrderAsync(signedOrder, fillAmountInBaseUnits, takerAddress);
})().catch(done);
});
describe('erc721', () => {