Add transactionHash to OrderState and emit it from OrderWatcher subscription

This commit is contained in:
Fabio Berger
2018-09-25 16:10:13 +01:00
parent 7570f3db51
commit 9eecf3683b
5 changed files with 64 additions and 13 deletions

View File

@@ -250,6 +250,32 @@ describe('OrderWatcher', () => {
await contractWrappers.exchange.fillOrderAsync(signedOrder, fillableAmount, takerAddress);
})().catch(done);
});
it('should include transactionHash in emitted orderStateInvalid when watched order fully filled', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerAssetData,
takerAssetData,
makerAddress,
takerAddress,
fillableAmount,
);
await orderWatcher.addOrderAsync(signedOrder);
let transactionHash: string;
const callback = callbackErrorReporter.reportNodeCallbackErrors(done)((orderState: OrderState) => {
expect(orderState.isValid).to.be.false();
const invalidOrderState = orderState as OrderStateInvalid;
expect(invalidOrderState.transactionHash).to.be.equal(transactionHash);
});
orderWatcher.subscribe(callback);
transactionHash = await contractWrappers.exchange.fillOrderAsync(
signedOrder,
fillableAmount,
takerAddress,
);
})().catch(done);
});
it('should emit orderStateValid when watched order partially filled', (done: DoneCallback) => {
(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(