aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2017-06-02 16:02:19 +0800
committerFabio Berger <me@fabioberger.com>2017-06-02 16:02:19 +0800
commit03bc3f08cd0d1c51dc9eb4441a3415e131b72c95 (patch)
tree0d5a79eb9c3e1ab08bf02363a6b8b4e041f13b4e /test
parent114b5ea0fe78b9b9b5b4fc46e13b21e45f77a628 (diff)
downloaddexon-sol-tools-03bc3f08cd0d1c51dc9eb4441a3415e131b72c95.tar
dexon-sol-tools-03bc3f08cd0d1c51dc9eb4441a3415e131b72c95.tar.gz
dexon-sol-tools-03bc3f08cd0d1c51dc9eb4441a3415e131b72c95.tar.bz2
dexon-sol-tools-03bc3f08cd0d1c51dc9eb4441a3415e131b72c95.tar.lz
dexon-sol-tools-03bc3f08cd0d1c51dc9eb4441a3415e131b72c95.tar.xz
dexon-sol-tools-03bc3f08cd0d1c51dc9eb4441a3415e131b72c95.tar.zst
dexon-sol-tools-03bc3f08cd0d1c51dc9eb4441a3415e131b72c95.zip
Simplify tests
Diffstat (limited to 'test')
-rw-r--r--test/exchange_wrapper_test.ts27
1 files changed, 11 insertions, 16 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index 519442d9f..d50a5f031 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -10,7 +10,7 @@ import {web3Factory} from './utils/web3_factory';
import {ZeroEx} from '../src/0x.js';
import {BlockchainLifecycle} from './utils/blockchain_lifecycle';
import {orderFactory} from './utils/order_factory';
-import {FillOrderValidationErrs, Token} from '../src/types';
+import {FillOrderValidationErrs, Token, SignedOrder} from '../src/types';
import {FillScenarios} from './utils/fill_scenarios';
chai.use(dirtyChai);
@@ -187,12 +187,22 @@ describe('ExchangeWrapper', () => {
let makerTokenAddress: string;
let takerTokenAddress: string;
let takerAddress: string;
+ let fillableAmount: BigNumber.BigNumber;
+ let partialFillAmount: BigNumber.BigNumber;
+ let signedOrder: SignedOrder;
before(() => {
takerAddress = userAddresses[1];
const [makerToken, takerToken] = tokens;
makerTokenAddress = makerToken.address;
takerTokenAddress = takerToken.address;
});
+ beforeEach(async () => {
+ fillableAmount = new BigNumber(5);
+ partialFillAmount = new BigNumber(2);
+ signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync(
+ makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount,
+ );
+ });
describe('#getUnavailableTakerAmountAsync', () => {
it ('should throw if passed an invalid orderHash', async () => {
const invalidOrderHashHex = '0x123';
@@ -203,11 +213,6 @@ describe('ExchangeWrapper', () => {
expect(unavailableValueT).to.be.bignumber.equal(0);
});
it ('should return the unavailableValueT for a valid and partially filled orderHash', async () => {
- const fillableAmount = new BigNumber(5);
- const partialFillAmount = new BigNumber(2);
- const signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount,
- );
const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder);
const unavailableValueT = await zeroEx.exchange.getUnavailableTakerAmountAsync(orderHash);
expect(unavailableValueT).to.be.bignumber.equal(partialFillAmount);
@@ -223,11 +228,6 @@ describe('ExchangeWrapper', () => {
expect(filledValueT).to.be.bignumber.equal(0);
});
it ('should return the filledValueT for a valid and partially filled orderHash', async () => {
- const fillableAmount = new BigNumber(5);
- const partialFillAmount = new BigNumber(2);
- const signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount,
- );
const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder);
const filledValueT = await zeroEx.exchange.getFilledTakerAmountAsync(orderHash);
expect(filledValueT).to.be.bignumber.equal(partialFillAmount);
@@ -243,11 +243,6 @@ describe('ExchangeWrapper', () => {
expect(cancelledValueT).to.be.bignumber.equal(0);
});
it ('should return the cancelledValueT for a valid and partially filled orderHash', async () => {
- const fillableAmount = new BigNumber(5);
- const partialFillAmount = new BigNumber(2);
- const signedOrder = await fillScenarios.createPartiallyFilledSignedOrderAsync(
- makerTokenAddress, takerTokenAddress, takerAddress, fillableAmount, partialFillAmount,
- );
const orderHash = await zeroEx.getOrderHashHexAsync(signedOrder);
const cancelledValueT = await zeroEx.exchange.getCanceledTakerAmountAsync(orderHash);
expect(cancelledValueT).to.be.bignumber.equal(0);