diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-02 00:21:12 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-02 00:21:12 +0800 |
commit | 0554f947b12f36a1cd5f7be469123e794b467f0b (patch) | |
tree | c3d1a55af98063dadfb37cf588adc6e00dfdf3b1 /test | |
parent | 6ced554d9f6cf00d0d9e8f9ff8170af4f1cfbee3 (diff) | |
download | dexon-sol-tools-0554f947b12f36a1cd5f7be469123e794b467f0b.tar dexon-sol-tools-0554f947b12f36a1cd5f7be469123e794b467f0b.tar.gz dexon-sol-tools-0554f947b12f36a1cd5f7be469123e794b467f0b.tar.bz2 dexon-sol-tools-0554f947b12f36a1cd5f7be469123e794b467f0b.tar.lz dexon-sol-tools-0554f947b12f36a1cd5f7be469123e794b467f0b.tar.xz dexon-sol-tools-0554f947b12f36a1cd5f7be469123e794b467f0b.tar.zst dexon-sol-tools-0554f947b12f36a1cd5f7be469123e794b467f0b.zip |
Add not enough taker balance tests
Diffstat (limited to 'test')
-rw-r--r-- | test/exchange_wrapper_test.ts | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index ad5eba699..09fb11cb3 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -104,7 +104,7 @@ describe('ExchangeWrapper', () => { }); describe('#fillOrderAsync', () => { let tokens: Token[]; - const fillAmount = new BigNumber(5); + const fillTakerAmountInBaseUnits = new BigNumber(5); let maker: string; let taker: string; const addressBySymbol: {[symbol: string]: string} = {}; @@ -141,19 +141,29 @@ describe('ExchangeWrapper', () => { const takerAmount = 5; const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, maker, taker, makerAmount, addressBySymbol.MLN, takerAmount, addressBySymbol.GNT); - expect(zeroEx.exchange.fillOrderAsync(signedOrder, fillAmount, shouldCheckTransfer)) + expect(zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer)) .to.be.rejectedWith(FillOrderValidationErrs.NOT_A_TAKER); }); it('should throw when order is expired', async () => { - const oldTimestamp = new BigNumber(42); + const timestampInThePast = new BigNumber(42); const makerAmount = 5; const takerAmount = 5; const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, maker, taker, - makerAmount, addressBySymbol.MLN, takerAmount, addressBySymbol.GNT, oldTimestamp); + makerAmount, addressBySymbol.MLN, takerAmount, addressBySymbol.GNT, timestampInThePast); zeroEx.setDefaultAccount(taker); - expect(zeroEx.exchange.fillOrderAsync(signedOrder, fillAmount, shouldCheckTransfer)) + expect(zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer)) .to.be.rejectedWith(FillOrderValidationErrs.EXPIRED); }); + it('should throw when not enough balance', async () => { + const makerAmount = 10; + const takerAmount = 10; + const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, maker, taker, + makerAmount, addressBySymbol.MLN, takerAmount, addressBySymbol.GNT); + zeroEx.setDefaultAccount(taker); + const moreThanTheBalance = new BigNumber(6); + expect(zeroEx.exchange.fillOrderAsync(signedOrder, moreThanTheBalance, true)) + .to.be.rejectedWith(FillOrderValidationErrs.NOT_ENOUGH_TAKER_BALANCE); + }); }); describe('successful fills', () => { it('should fill the valid order', async () => { @@ -162,9 +172,9 @@ describe('ExchangeWrapper', () => { const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, maker, taker, makerAmount, addressBySymbol.MLN, takerAmount, addressBySymbol.GNT); zeroEx.setDefaultAccount(taker); - await zeroEx.exchange.fillOrderAsync(signedOrder, fillAmount, shouldCheckTransfer); + await zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer); expect(await zeroEx.token.getBalanceAsync(addressBySymbol.MLN, taker)) - .to.be.bignumber.equal(fillAmount); + .to.be.bignumber.equal(fillTakerAmountInBaseUnits); expect(await zeroEx.token.getBalanceAsync(addressBySymbol.GNT, taker)) .to.be.bignumber.equal(0); }); |