diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-01 23:00:43 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-01 23:01:54 +0800 |
commit | 5ded2bd52ba911e50e2cb3606a2e0e7a32cbd778 (patch) | |
tree | 67db0db669ce43aacc0fbb4dc6f9e107d7d8a215 /test | |
parent | 8193d0f5b28043cbcb005b58790abf32ffee38e1 (diff) | |
download | dexon-0x-contracts-5ded2bd52ba911e50e2cb3606a2e0e7a32cbd778.tar.gz dexon-0x-contracts-5ded2bd52ba911e50e2cb3606a2e0e7a32cbd778.tar.zst dexon-0x-contracts-5ded2bd52ba911e50e2cb3606a2e0e7a32cbd778.zip |
Refactor tests
Diffstat (limited to 'test')
-rw-r--r-- | test/exchange_wrapper_test.ts | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index f324c5492..4c61320e3 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -108,6 +108,8 @@ describe('ExchangeWrapper', () => { const addressBySymbol: {[symbol: string]: string} = {}; let networkId: number; const shouldCheckTransfer = false; + let maker: string; + let taker: string; const setBalance = async (toAddress: string, amountInBaseUnits: BigNumber.BigNumber|number, tokenAddress: string) => { @@ -127,19 +129,23 @@ describe('ExchangeWrapper', () => { }); networkId = await promisify(web3.version.getNetwork)(); }); + beforeEach('setup', () => { + maker = userAddresses[0]; + taker = userAddresses[1]; + }); + afterEach('reset default account', () => { + zeroEx.setDefaultAccount(userAddresses[0]); + }); describe('failed fills', () => { it('should throw when the fill amount is zero', async () => { - const maker = userAddresses[0]; - const taker = userAddresses[0]; const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, networkId, maker, taker, 5, addressBySymbol.MLN, 5, addressBySymbol.GNT); const fillAmount = new BigNumber(0); - expect(zeroEx.exchange.fillOrderAsync(signedOrder, fillAmount, shouldCheckTransfer)) + zeroEx.setDefaultAccount(taker); + expect(zeroEx.exchange.fillOrderAsync(signedOrder, fillAmount)) .to.be.rejectedWith(FillOrderValidationErrs.FILL_AMOUNT_IS_ZERO); }); it('should throw when sender is not a taker', async () => { - const maker = userAddresses[0]; - const taker = userAddresses[1]; const signedOrder = await orderFactory.createSignedOrderAsync(zeroEx, networkId, maker, taker, 5, addressBySymbol.MLN, 5, addressBySymbol.GNT); const fillAmount = new BigNumber(5); @@ -148,12 +154,7 @@ describe('ExchangeWrapper', () => { }); }); describe('successful fills', () => { - afterEach('reset default account', () => { - zeroEx.setDefaultAccount(userAddresses[0]); - }); it('should fill the valid order', async () => { - const maker = userAddresses[0]; - const taker = userAddresses[1]; await setAllowance(maker, 5, addressBySymbol.MLN); await setBalance(taker, 5, addressBySymbol.GNT); await setAllowance(taker, 5, addressBySymbol.GNT); |