diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-02-10 05:20:15 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-04-21 04:56:16 +0800 |
commit | 246eca91aa9a816215483cb1a28b6a3d0c73206e (patch) | |
tree | 5d26c53d7dfdeda7cb62384ab1af768cd3606db9 /packages/contracts/test | |
parent | 5fd378e4ceec96ae69085b5962a3e1b03c60246d (diff) | |
download | dexon-0x-contracts-246eca91aa9a816215483cb1a28b6a3d0c73206e.tar.gz dexon-0x-contracts-246eca91aa9a816215483cb1a28b6a3d0c73206e.tar.zst dexon-0x-contracts-246eca91aa9a816215483cb1a28b6a3d0c73206e.zip |
Add logDecoder, remove outdated tests
Diffstat (limited to 'packages/contracts/test')
-rw-r--r-- | packages/contracts/test/exchange/core.ts | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts index c7724c511..ae136816e 100644 --- a/packages/contracts/test/exchange/core.ts +++ b/packages/contracts/test/exchange/core.ts @@ -19,6 +19,7 @@ import { Balances } from '../../src/utils/balances'; import { constants } from '../../src/utils/constants'; import { crypto } from '../../src/utils/crypto'; import { ExchangeWrapper } from '../../src/utils/exchange_wrapper'; +import { LogDecoder } from '../../src/utils/log_decoder'; import { OrderFactory } from '../../src/utils/order_factory'; import { BalancesByOwner, ContractName, ExchangeContractErrs } from '../../src/utils/types'; import { chaiSetup } from '../utils/chai_setup'; @@ -393,7 +394,7 @@ describe('Exchange', () => { const res = await exWrapper.fillOrderAsync(signedOrder, taker, { takerTokenFillAmount: signedOrder.takerTokenAmount, }); - const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>; + const log = logDecoder.tryToDecodeLogOrNoop(res.logs[0]) as LogWithDecodedArgs<LogFillContractEventArgs>; expect(log.args.takerTokenFilledAmount).to.be.bignumber.equal( signedOrder.takerTokenAmount.minus(takerTokenFillAmount), ); @@ -429,7 +430,7 @@ describe('Exchange', () => { }); expect(res.logs).to.have.length(1); - const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>; + const log = logDecoder.tryToDecodeLogOrNoop(res.logs[0]) as LogWithDecodedArgs<LogFillContractEventArgs>; const logArgs = log.args; const expectedFilledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor); const expectedFilledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor); @@ -460,7 +461,7 @@ describe('Exchange', () => { }); expect(res.logs).to.have.length(1); - const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>; + const log = logDecoder.tryToDecodeLogOrNoop(res.logs[0]) as LogWithDecodedArgs<LogFillContractEventArgs>; const logArgs = log.args; const expectedFilledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor); const expectedFilledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor); @@ -688,8 +689,8 @@ describe('Exchange', () => { const res = await exWrapper.fillOrderAsync(signedOrder, taker); expect(res.logs).to.have.length(1); - const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>; - const errCode = log.args.errorId; + const log = logDecoder.tryToDecodeLogOrNoop(res.logs[0]) as LogWithDecodedArgs<LogErrorContractEventArgs>; + const errCode = log.args.errorId.toNumber(); expect(errCode).to.be.equal(ExchangeContractErrs.ERROR_ORDER_EXPIRED); }); @@ -699,8 +700,8 @@ describe('Exchange', () => { const res = await exWrapper.fillOrderAsync(signedOrder, taker); expect(res.logs).to.have.length(1); - const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>; - const errCode = log.args.errorId; + const log = logDecoder.tryToDecodeLogOrNoop(res.logs[0]) as LogWithDecodedArgs<LogErrorContractEventArgs>; + const errCode = log.args.errorId.toNumber(); expect(errCode).to.be.equal(ExchangeContractErrs.ERROR_ORDER_FULLY_FILLED_OR_CANCELLED); }); }); @@ -760,7 +761,7 @@ describe('Exchange', () => { const res = await exWrapper.fillOrderAsync(signedOrder, taker, { takerTokenFillAmount: signedOrder.takerTokenAmount, }); - const log = res.logs[0] as LogWithDecodedArgs<LogFillContractEventArgs>; + const log = logDecoder.tryToDecodeLogOrNoop(res.logs[0]) as LogWithDecodedArgs<LogFillContractEventArgs>; expect(log.args.takerTokenFilledAmount).to.be.bignumber.equal( signedOrder.takerTokenAmount.minus(takerTokenCancelAmount), ); @@ -805,7 +806,7 @@ describe('Exchange', () => { }); expect(res.logs).to.have.length(1); - const log = res.logs[0] as LogWithDecodedArgs<LogCancelContractEventArgs>; + const log = logDecoder.tryToDecodeLogOrNoop(res.logs[0]) as LogWithDecodedArgs<LogCancelContractEventArgs>; const logArgs = log.args; const expectedCancelledMakerTokenAmount = signedOrder.makerTokenAmount.div(divisor); const expectedCancelledTakerTokenAmount = signedOrder.takerTokenAmount.div(divisor); @@ -826,8 +827,8 @@ describe('Exchange', () => { const res = await exWrapper.cancelOrderAsync(signedOrder, maker); expect(res.logs).to.have.length(1); - const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>; - const errCode = log.args.errorId; + const log = logDecoder.tryToDecodeLogOrNoop(res.logs[0]) as LogWithDecodedArgs<LogErrorContractEventArgs>; + const errCode = log.args.errorId.toNumber(); expect(errCode).to.be.equal(ExchangeContractErrs.ERROR_ORDER_FULLY_FILLED_OR_CANCELLED); }); @@ -838,8 +839,8 @@ describe('Exchange', () => { const res = await exWrapper.cancelOrderAsync(signedOrder, maker); expect(res.logs).to.have.length(1); - const log = res.logs[0] as LogWithDecodedArgs<LogErrorContractEventArgs>; - const errCode = log.args.errorId; + const log = logDecoder.tryToDecodeLogOrNoop(res.logs[0]) as LogWithDecodedArgs<LogErrorContractEventArgs>; + const errCode = log.args.errorId.toNumber(); expect(errCode).to.be.equal(ExchangeContractErrs.ERROR_ORDER_EXPIRED); }); }); |