diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-02 21:24:42 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-02 21:24:42 +0800 |
commit | d8587875b82ae2fde6dad1334a586c36cda2bfec (patch) | |
tree | caaacb3bcaacaca134d641fec4767a2e6725d734 /test/exchange_wrapper_test.ts | |
parent | a07a9d8571928dbbe82d2cc0917dafe6b446f701 (diff) | |
download | dexon-sol-tools-d8587875b82ae2fde6dad1334a586c36cda2bfec.tar dexon-sol-tools-d8587875b82ae2fde6dad1334a586c36cda2bfec.tar.gz dexon-sol-tools-d8587875b82ae2fde6dad1334a586c36cda2bfec.tar.bz2 dexon-sol-tools-d8587875b82ae2fde6dad1334a586c36cda2bfec.tar.lz dexon-sol-tools-d8587875b82ae2fde6dad1334a586c36cda2bfec.tar.xz dexon-sol-tools-d8587875b82ae2fde6dad1334a586c36cda2bfec.tar.zst dexon-sol-tools-d8587875b82ae2fde6dad1334a586c36cda2bfec.zip |
Add success test for fill with fees
Diffstat (limited to 'test/exchange_wrapper_test.ts')
-rw-r--r-- | test/exchange_wrapper_test.ts | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts index 7f8bad377..ecb5a408b 100644 --- a/test/exchange_wrapper_test.ts +++ b/test/exchange_wrapper_test.ts @@ -9,9 +9,9 @@ import promisify = require('es6-promisify'); 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 {FillScenarios} from './utils/fill_scenarios'; +import {TokenUtils} from './utils/token_utils'; chai.use(dirtyChai); chai.use(ChaiBigNumber()); @@ -111,15 +111,19 @@ describe('ExchangeWrapper', () => { let coinBase: string; let makerAddress: string; let takerAddress: string; + let feeRecipient: string; + let zrxTokenAddress: string; const fillTakerAmountInBaseUnits = new BigNumber(5); const shouldCheckTransfer = false; before('fetch tokens', async () => { - [coinBase, makerAddress, takerAddress] = userAddresses; + [coinBase, makerAddress, takerAddress, feeRecipient] = userAddresses; tokens = await zeroEx.tokenRegistry.getTokensAsync(); - const [makerToken, takerToken] = tokens; + const tokenUtils = new TokenUtils(tokens); + const [makerToken, takerToken] = tokenUtils.getNonProtocolTokens(); makerTokenAddress = makerToken.address; takerTokenAddress = takerToken.address; - fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens); + zrxTokenAddress = tokenUtils.getProtocolTokenOrThrow().address; + fillScenarios = new FillScenarios(zeroEx, userAddresses, tokens, zrxTokenAddress); }); afterEach('reset default account', () => { zeroEx.setTransactionSenderAccount(userAddresses[0]); @@ -262,6 +266,19 @@ describe('ExchangeWrapper', () => { expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress)) .to.be.bignumber.equal(fillableAmount.minus(partialFillAmount)); }); + it('should fill the valid orders with fees', async () => { + const fillableAmount = new BigNumber(5); + const makerFee = new BigNumber(1); + const takerFee = new BigNumber(2); + const signedOrder = await fillScenarios.createFillableSignedOrderWithFeesAsync( + makerTokenAddress, takerTokenAddress, makerFee, takerFee, + makerAddress, takerAddress, fillableAmount, feeRecipient, + ); + zeroEx.setTransactionSenderAccount(takerAddress); + await zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer); + expect(await zeroEx.token.getBalanceAsync(zrxTokenAddress, feeRecipient)) + .to.be.bignumber.equal(makerFee.plus(takerFee)); + }); }); }); }); |