aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-11-10 23:07:29 +0800
committerFabio Berger <me@fabioberger.com>2017-11-10 23:07:29 +0800
commitd90756e8ef2634737d41633f5427446b47223e98 (patch)
treebadf4498ca47081cdf28e35afbb42326fdc46db4
parent9b9ab983d618fd5857955a2d816e85060e80e82d (diff)
downloaddexon-sol-tools-d90756e8ef2634737d41633f5427446b47223e98.tar
dexon-sol-tools-d90756e8ef2634737d41633f5427446b47223e98.tar.gz
dexon-sol-tools-d90756e8ef2634737d41633f5427446b47223e98.tar.bz2
dexon-sol-tools-d90756e8ef2634737d41633f5427446b47223e98.tar.lz
dexon-sol-tools-d90756e8ef2634737d41633f5427446b47223e98.tar.xz
dexon-sol-tools-d90756e8ef2634737d41633f5427446b47223e98.tar.zst
dexon-sol-tools-d90756e8ef2634737d41633f5427446b47223e98.zip
Test that the orderStateWatcher doesn't emit an event when an irrelevant blockchain event is received.
-rw-r--r--test/order_state_watcher_test.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/order_state_watcher_test.ts b/test/order_state_watcher_test.ts
index 10ed6bd77..1231d7e16 100644
--- a/test/order_state_watcher_test.ts
+++ b/test/order_state_watcher_test.ts
@@ -121,6 +121,28 @@ describe('OrderStateWatcher', () => {
await zeroEx.token.setProxyAllowanceAsync(makerToken.address, maker, new BigNumber(0));
})().catch(done);
});
+ it('should not emit an orderState event when irrelevant Transfer event received', (done: DoneCallback) => {
+ (async () => {
+ signedOrder = await fillScenarios.createFillableSignedOrderAsync(
+ makerToken.address, takerToken.address, maker, taker, fillableAmount,
+ );
+ const orderHash = ZeroEx.getOrderHashHex(signedOrder);
+ zeroEx.orderStateWatcher.addOrder(signedOrder);
+ const callback = reportCallbackErrors(done)((orderState: OrderState) => {
+ throw new Error('OrderState callback fired for irrelevant order');
+ });
+ zeroEx.orderStateWatcher.subscribe(callback);
+ const notTheMaker = userAddresses[0];
+ const anyRecipient = taker;
+ const transferAmount = new BigNumber(2);
+ const notTheMakerBalance = await zeroEx.token.getBalanceAsync(makerToken.address, notTheMaker);
+ await zeroEx.token.transferAsync(makerToken.address, notTheMaker, anyRecipient, transferAmount);
+ const timeoutInMs = 150;
+ setTimeout(() => {
+ done();
+ }, timeoutInMs);
+ })().catch(done);
+ });
it('should emit orderStateInvalid when maker moves balance backing watched order', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(