diff options
author | Leonid <logvinov.leon@gmail.com> | 2017-07-12 08:44:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-12 08:44:24 +0800 |
commit | 98e8a6dd706f0a630402d9009ad3dcf9b0ff872d (patch) | |
tree | 67abd7c0bca868a3b2d1f46c6f30321ba7c175be /test/exchange_wrapper_test.ts | |
parent | 9bb14a1d69f63485650604b83b6bc784cfe2a8c6 (diff) | |
parent | 4efba2a4bc93f49f1962f1c774c628aea4d19251 (diff) | |
download | dexon-sol-tools-98e8a6dd706f0a630402d9009ad3dcf9b0ff872d.tar dexon-sol-tools-98e8a6dd706f0a630402d9009ad3dcf9b0ff872d.tar.gz dexon-sol-tools-98e8a6dd706f0a630402d9009ad3dcf9b0ff872d.tar.bz2 dexon-sol-tools-98e8a6dd706f0a630402d9009ad3dcf9b0ff872d.tar.lz dexon-sol-tools-98e8a6dd706f0a630402d9009ad3dcf9b0ff872d.tar.xz dexon-sol-tools-98e8a6dd706f0a630402d9009ad3dcf9b0ff872d.tar.zst dexon-sol-tools-98e8a6dd706f0a630402d9009ad3dcf9b0ff872d.zip |
Merge pull request #106 from 0xProject/single-exchange
Single exchange
Diffstat (limited to 'test/exchange_wrapper_test.ts')
-rw-r--r-- | test/exchange_wrapper_test.ts | 67 |
1 files changed, 18 insertions, 49 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index ed2e45abf..d8af9d1cd 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -44,7 +44,7 @@ describe('ExchangeWrapper', () => { before(async () => { web3 = web3Factory.create(); zeroEx = new ZeroEx(web3.currentProvider); - [exchangeContractAddress] = await zeroEx.getAvailableExchangeContractAddressesAsync(); + exchangeContractAddress = await zeroEx.exchange.getContractAddressAsync(); userAddresses = await promisify(web3.eth.getAccounts)(); tokens = await zeroEx.tokenRegistry.getTokensAsync(); tokenUtils = new TokenUtils(tokens); @@ -418,12 +418,8 @@ describe('ExchangeWrapper', () => { }); it('should successfully fill multiple orders', async () => { await zeroEx.exchange.batchFillOrdersAsync(orderFillBatch, shouldCheckTransfer, takerAddress); - const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync( - signedOrderHashHex, exchangeContractAddress, - ); - const anotherFilledAmount = await zeroEx.exchange.getFilledTakerAmountAsync( - anotherOrderHashHex, exchangeContractAddress, - ); + const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex); + const anotherFilledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(anotherOrderHashHex); expect(filledAmount).to.be.bignumber.equal(fillTakerAmount); expect(anotherFilledAmount).to.be.bignumber.equal(fillTakerAmount); }); @@ -455,12 +451,8 @@ describe('ExchangeWrapper', () => { await zeroEx.exchange.fillOrdersUpToAsync( signedOrders, fillUpToAmount, shouldCheckTransfer, takerAddress, ); - const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync( - signedOrderHashHex, exchangeContractAddress, - ); - const anotherFilledAmount = await zeroEx.exchange.getFilledTakerAmountAsync( - anotherOrderHashHex, exchangeContractAddress, - ); + const filledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(signedOrderHashHex); + const anotherFilledAmount = await zeroEx.exchange.getFilledTakerAmountAsync(anotherOrderHashHex); expect(filledAmount).to.be.bignumber.equal(fillableAmount); const remainingFillAmount = fillableAmount.minus(1); expect(anotherFilledAmount).to.be.bignumber.equal(remainingFillAmount); @@ -520,9 +512,7 @@ describe('ExchangeWrapper', () => { describe('successful cancels', () => { it('should cancel an order', async () => { await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmount); - const cancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync( - orderHashHex, exchangeContractAddress, - ); + const cancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHashHex); expect(cancelledAmount).to.be.bignumber.equal(cancelAmount); }); it('should return cancelled amount', async () => { @@ -568,11 +558,9 @@ describe('ExchangeWrapper', () => { describe('successful batch cancels', () => { it('should cancel a batch of orders', async () => { await zeroEx.exchange.batchCancelOrdersAsync(cancelBatch); - const cancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync( - orderHashHex, exchangeContractAddress, - ); + const cancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHashHex); const anotherCancelledAmount = await zeroEx.exchange.getCanceledTakerAmountAsync( - anotherOrderHashHex, exchangeContractAddress, + anotherOrderHashHex, ); expect(cancelledAmount).to.be.bignumber.equal(cancelAmount); expect(anotherCancelledAmount).to.be.bignumber.equal(cancelAmount); @@ -605,68 +593,49 @@ describe('ExchangeWrapper', () => { describe('#getUnavailableTakerAmountAsync', () => { it('should throw if passed an invalid orderHash', async () => { const invalidOrderHashHex = '0x123'; - return expect(zeroEx.exchange.getUnavailableTakerAmountAsync( - invalidOrderHashHex, exchangeContractAddress, - )).to.be.rejected(); + return expect(zeroEx.exchange.getUnavailableTakerAmountAsync(invalidOrderHashHex)).to.be.rejected(); }); it('should return zero if passed a valid but non-existent orderHash', async () => { - const unavailableValueT = await zeroEx.exchange.getUnavailableTakerAmountAsync( - NON_EXISTENT_ORDER_HASH, exchangeContractAddress, - ); + const unavailableValueT = await zeroEx.exchange.getUnavailableTakerAmountAsync(NON_EXISTENT_ORDER_HASH); expect(unavailableValueT).to.be.bignumber.equal(0); }); it('should return the unavailableValueT for a valid and partially filled orderHash', async () => { - const unavailableValueT = await zeroEx.exchange.getUnavailableTakerAmountAsync( - orderHash, exchangeContractAddress, - ); + const unavailableValueT = await zeroEx.exchange.getUnavailableTakerAmountAsync(orderHash); expect(unavailableValueT).to.be.bignumber.equal(partialFillAmount); }); }); describe('#getFilledTakerAmountAsync', () => { it('should throw if passed an invalid orderHash', async () => { const invalidOrderHashHex = '0x123'; - return expect(zeroEx.exchange.getFilledTakerAmountAsync( - invalidOrderHashHex, exchangeContractAddress, - )).to.be.rejected(); + return expect(zeroEx.exchange.getFilledTakerAmountAsync(invalidOrderHashHex)).to.be.rejected(); }); it('should return zero if passed a valid but non-existent orderHash', async () => { - const filledValueT = await zeroEx.exchange.getFilledTakerAmountAsync( - NON_EXISTENT_ORDER_HASH, exchangeContractAddress, + const filledValueT = await zeroEx.exchange.getFilledTakerAmountAsync(NON_EXISTENT_ORDER_HASH, ); expect(filledValueT).to.be.bignumber.equal(0); }); it('should return the filledValueT for a valid and partially filled orderHash', async () => { - const filledValueT = await zeroEx.exchange.getFilledTakerAmountAsync( - orderHash, exchangeContractAddress, - ); + const filledValueT = await zeroEx.exchange.getFilledTakerAmountAsync(orderHash); expect(filledValueT).to.be.bignumber.equal(partialFillAmount); }); }); describe('#getCanceledTakerAmountAsync', () => { it('should throw if passed an invalid orderHash', async () => { const invalidOrderHashHex = '0x123'; - return expect(zeroEx.exchange.getCanceledTakerAmountAsync( - invalidOrderHashHex, exchangeContractAddress, - )).to.be.rejected(); + return expect(zeroEx.exchange.getCanceledTakerAmountAsync(invalidOrderHashHex)).to.be.rejected(); }); it('should return zero if passed a valid but non-existent orderHash', async () => { - const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync( - NON_EXISTENT_ORDER_HASH, exchangeContractAddress, - ); + const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync(NON_EXISTENT_ORDER_HASH); expect(cancelledValueT).to.be.bignumber.equal(0); }); it('should return the cancelledValueT for a valid and partially filled orderHash', async () => { - const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync( - orderHash, exchangeContractAddress, - ); + const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHash); expect(cancelledValueT).to.be.bignumber.equal(0); }); it('should return the cancelledValueT for a valid and cancelled orderHash', async () => { const cancelAmount = fillableAmount.minus(partialFillAmount); await zeroEx.exchange.cancelOrderAsync(signedOrder, cancelAmount); - const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync( - orderHash, exchangeContractAddress, - ); + const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHash); expect(cancelledValueT).to.be.bignumber.equal(cancelAmount); }); }); |