aboutsummaryrefslogtreecommitdiffstats
path: root/test/exchange_wrapper_test.ts
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-10-16 16:41:04 +0800
committerGitHub <noreply@github.com>2017-10-16 16:41:04 +0800
commitd24eeec1a1d501b4a7814d1bbb564523a35dd567 (patch)
tree43a7ee4b5dab08091178b09985e180ab8de7f53f /test/exchange_wrapper_test.ts
parentdf5fe4a84f3c5ee8946fa615428c5b9de8f8b06f (diff)
parenta798f32cc89b61788856073265d20ad3812576ae (diff)
downloaddexon-sol-tools-d24eeec1a1d501b4a7814d1bbb564523a35dd567.tar
dexon-sol-tools-d24eeec1a1d501b4a7814d1bbb564523a35dd567.tar.gz
dexon-sol-tools-d24eeec1a1d501b4a7814d1bbb564523a35dd567.tar.bz2
dexon-sol-tools-d24eeec1a1d501b4a7814d1bbb564523a35dd567.tar.lz
dexon-sol-tools-d24eeec1a1d501b4a7814d1bbb564523a35dd567.tar.xz
dexon-sol-tools-d24eeec1a1d501b4a7814d1bbb564523a35dd567.tar.zst
dexon-sol-tools-d24eeec1a1d501b4a7814d1bbb564523a35dd567.zip
Merge pull request #187 from apackin/setFillOrKillToUseRequestInterface
[WIP] Use OrderFillRequest interface for batchFillOrKill
Diffstat (limited to 'test/exchange_wrapper_test.ts')
-rw-r--r--test/exchange_wrapper_test.ts63
1 files changed, 31 insertions, 32 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index 5f979ad76..f3f16643e 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -17,7 +17,6 @@ import {
OrderFillRequest,
LogFillContractEventArgs,
LogCancelContractEventArgs,
- OrderFillOrKillRequest,
LogEvent,
} from '../src';
import {DoneCallback, BlockParamLiteral} from '../src/types';
@@ -62,7 +61,7 @@ describe('ExchangeWrapper', () => {
let makerAddress: string;
let takerAddress: string;
let feeRecipient: string;
- const fillTakerAmount = new BigNumber(5);
+ const takerTokenFillAmount = new BigNumber(5);
before(async () => {
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
tokens = await zeroEx.tokenRegistry.getTokensAsync();
@@ -80,44 +79,44 @@ describe('ExchangeWrapper', () => {
const anotherSignedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
- const orderFillOrKillRequests = [
+ const orderFillRequests = [
{
signedOrder,
- fillTakerAmount: partialFillTakerAmount,
+ takerTokenFillAmount: partialFillTakerAmount,
},
{
signedOrder: anotherSignedOrder,
- fillTakerAmount: partialFillTakerAmount,
+ takerTokenFillAmount: partialFillTakerAmount,
},
];
- await zeroEx.exchange.batchFillOrKillAsync(orderFillOrKillRequests, takerAddress);
+ await zeroEx.exchange.batchFillOrKillAsync(orderFillRequests, takerAddress);
});
describe('order transaction options', () => {
let signedOrder: SignedOrder;
- let orderFillOrKillRequests: OrderFillOrKillRequest[];
+ let orderFillRequests: OrderFillRequest[];
const fillableAmount = new BigNumber(5);
beforeEach(async () => {
signedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
- orderFillOrKillRequests = [
+ orderFillRequests = [
{
signedOrder,
- fillTakerAmount: new BigNumber(0),
+ takerTokenFillAmount: new BigNumber(0),
},
];
});
it('should validate when orderTransactionOptions are not present', async () => {
- return expect(zeroEx.exchange.batchFillOrKillAsync(orderFillOrKillRequests, takerAddress))
+ return expect(zeroEx.exchange.batchFillOrKillAsync(orderFillRequests, takerAddress))
.to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
it('should validate when orderTransactionOptions specify to validate', async () => {
- return expect(zeroEx.exchange.batchFillOrKillAsync(orderFillOrKillRequests, takerAddress, {
+ return expect(zeroEx.exchange.batchFillOrKillAsync(orderFillRequests, takerAddress, {
shouldValidate: true,
})).to.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
it('should not validate when orderTransactionOptions specify not to validate', async () => {
- return expect(zeroEx.exchange.batchFillOrKillAsync(orderFillOrKillRequests, takerAddress, {
+ return expect(zeroEx.exchange.batchFillOrKillAsync(orderFillRequests, takerAddress, {
shouldValidate: false,
})).to.not.be.rejectedWith(ExchangeContractErrs.OrderFillAmountZero);
});
@@ -141,15 +140,15 @@ describe('ExchangeWrapper', () => {
.to.be.bignumber.equal(0);
expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress))
.to.be.bignumber.equal(fillableAmount);
- await zeroEx.exchange.fillOrKillOrderAsync(signedOrder, fillTakerAmount, takerAddress);
+ await zeroEx.exchange.fillOrKillOrderAsync(signedOrder, takerTokenFillAmount, takerAddress);
expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(fillTakerAmount));
+ .to.be.bignumber.equal(fillableAmount.minus(takerTokenFillAmount));
expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress))
- .to.be.bignumber.equal(fillTakerAmount);
+ .to.be.bignumber.equal(takerTokenFillAmount);
expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress))
- .to.be.bignumber.equal(fillTakerAmount);
+ .to.be.bignumber.equal(takerTokenFillAmount);
expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(fillTakerAmount));
+ .to.be.bignumber.equal(fillableAmount.minus(takerTokenFillAmount));
});
it('should partially fill a valid order', async () => {
const partialFillAmount = new BigNumber(3);
@@ -191,7 +190,7 @@ describe('ExchangeWrapper', () => {
let takerAddress: string;
let feeRecipient: string;
const fillableAmount = new BigNumber(5);
- const fillTakerAmount = new BigNumber(5);
+ const takerTokenFillAmount = new BigNumber(5);
const shouldThrowOnInsufficientBalanceOrAllowance = true;
before(async () => {
[coinbase, makerAddress, takerAddress, feeRecipient] = userAddresses;
@@ -215,16 +214,16 @@ describe('ExchangeWrapper', () => {
expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress))
.to.be.bignumber.equal(fillableAmount);
const txHash = await zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress);
+ signedOrder, takerTokenFillAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress);
await zeroEx.awaitTransactionMinedAsync(txHash);
expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(fillTakerAmount));
+ .to.be.bignumber.equal(fillableAmount.minus(takerTokenFillAmount));
expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress))
- .to.be.bignumber.equal(fillTakerAmount);
+ .to.be.bignumber.equal(takerTokenFillAmount);
expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, takerAddress))
- .to.be.bignumber.equal(fillTakerAmount);
+ .to.be.bignumber.equal(takerTokenFillAmount);
expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress))
- .to.be.bignumber.equal(fillableAmount.minus(fillTakerAmount));
+ .to.be.bignumber.equal(fillableAmount.minus(takerTokenFillAmount));
});
it('should partially fill the valid order', async () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
@@ -251,7 +250,7 @@ describe('ExchangeWrapper', () => {
makerAddress, takerAddress, fillableAmount, feeRecipient,
);
const txHash = await zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress);
+ signedOrder, takerTokenFillAmount, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress);
await zeroEx.awaitTransactionMinedAsync(txHash);
expect(await zeroEx.token.getBalanceAsync(zrxTokenAddress, feeRecipient))
.to.be.bignumber.equal(makerFee.plus(takerFee));
@@ -305,11 +304,11 @@ describe('ExchangeWrapper', () => {
orderFillBatch = [
{
signedOrder,
- takerTokenFillAmount: fillTakerAmount,
+ takerTokenFillAmount: takerTokenFillAmount,
},
{
signedOrder: anotherSignedOrder,
- takerTokenFillAmount: fillTakerAmount,
+ takerTokenFillAmount: takerTokenFillAmount,
},
];
});
@@ -324,8 +323,8 @@ describe('ExchangeWrapper', () => {
await zeroEx.awaitTransactionMinedAsync(txHash);
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);
+ expect(filledAmount).to.be.bignumber.equal(takerTokenFillAmount);
+ expect(anotherFilledAmount).to.be.bignumber.equal(takerTokenFillAmount);
});
});
describe('order transaction options', () => {
@@ -624,7 +623,7 @@ describe('ExchangeWrapper', () => {
let makerAddress: string;
let fillableAmount: BigNumber.BigNumber;
let signedOrder: SignedOrder;
- const fillTakerAmountInBaseUnits = new BigNumber(1);
+ const takerTokenFillAmountInBaseUnits = new BigNumber(1);
const cancelTakerAmountInBaseUnits = new BigNumber(1);
before(() => {
[coinbase, makerAddress, takerAddress] = userAddresses;
@@ -656,7 +655,7 @@ describe('ExchangeWrapper', () => {
ExchangeEvents.LogFill, indexFilterValues, callback,
);
await zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnits, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
+ signedOrder, takerTokenFillAmountInBaseUnits, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
);
})().catch(done);
});
@@ -692,7 +691,7 @@ describe('ExchangeWrapper', () => {
ExchangeEvents.LogFill, indexFilterValues, callback,
);
await zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnits, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
+ signedOrder, takerTokenFillAmountInBaseUnits, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
);
})().catch(done);
});
@@ -706,7 +705,7 @@ describe('ExchangeWrapper', () => {
);
zeroEx.exchange.unsubscribe(subscriptionToken);
await zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountInBaseUnits, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
+ signedOrder, takerTokenFillAmountInBaseUnits, shouldThrowOnInsufficientBalanceOrAllowance, takerAddress,
);
done();
})().catch(done);