aboutsummaryrefslogtreecommitdiffstats
path: root/test/exchange_wrapper_test.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-05 22:22:56 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-05 22:22:56 +0800
commitbac6833436960d2a7eb50d89e94fed226a16008b (patch)
tree69556bb591ecd1fc5ebcd3e2da8c688d5cbaccd0 /test/exchange_wrapper_test.ts
parenteb5c9ae70886cb1a14ae154f363f052a76b24479 (diff)
downloaddexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.tar
dexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.tar.gz
dexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.tar.bz2
dexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.tar.lz
dexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.tar.xz
dexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.tar.zst
dexon-sol-tools-bac6833436960d2a7eb50d89e94fed226a16008b.zip
Make methods accept senderAccount
Diffstat (limited to 'test/exchange_wrapper_test.ts')
-rw-r--r--test/exchange_wrapper_test.ts54
1 files changed, 21 insertions, 33 deletions
diff --git a/test/exchange_wrapper_test.ts b/test/exchange_wrapper_test.ts
index 4f3a48b26..a841f82ec 100644
--- a/test/exchange_wrapper_test.ts
+++ b/test/exchange_wrapper_test.ts
@@ -138,9 +138,6 @@ describe('ExchangeWrapper', () => {
makerTokenAddress = makerToken.address;
takerTokenAddress = takerToken.address;
});
- afterEach('reset default account', () => {
- zeroEx.setTransactionSenderAccount(userAddresses[0]);
- });
describe('failed fills', () => {
it('should throw when the fill amount is zero', async () => {
const fillableAmount = new BigNumber(5);
@@ -148,9 +145,8 @@ describe('ExchangeWrapper', () => {
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
const zeroFillAmount = new BigNumber(0);
- zeroEx.setTransactionSenderAccount(takerAddress);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, zeroFillAmount, shouldCheckTransfer,
+ signedOrder, zeroFillAmount, shouldCheckTransfer, takerAddress,
)).to.be.rejectedWith(ExchangeContractErrs.ORDER_REMAINING_FILL_AMOUNT_ZERO);
});
it('should throw when sender is not a taker', async () => {
@@ -159,7 +155,7 @@ describe('ExchangeWrapper', () => {
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmount, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer, takerAddress,
)).to.be.rejectedWith(ExchangeContractErrs.TRANSACTION_SENDER_IS_NOT_FILL_ORDER_TAKER);
});
it('should throw when order is expired', async () => {
@@ -168,9 +164,8 @@ describe('ExchangeWrapper', () => {
const signedOrder = await fillScenarios.createFillableSignedOrderAsync(
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount, expirationInPast,
);
- zeroEx.setTransactionSenderAccount(takerAddress);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmount, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer, takerAddress,
)).to.be.rejectedWith(ExchangeContractErrs.ORDER_FILL_EXPIRED);
});
describe('should throw when not enough balance or allowance to fulfill the order', () => {
@@ -187,36 +182,32 @@ describe('ExchangeWrapper', () => {
await zeroEx.token.transferAsync(
takerTokenAddress, takerAddress, coinbase, balanceToSubtractFromMaker,
);
- zeroEx.setTransactionSenderAccount(takerAddress);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmount, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer, takerAddress,
)).to.be.rejectedWith(ExchangeContractErrs.INSUFFICIENT_TAKER_BALANCE);
});
it('should throw when taker allowance is less than fill amount', async () => {
const newAllowanceWhichIsLessThanFillAmount = fillTakerAmount.minus(lackingAllowance);
await zeroEx.token.setProxyAllowanceAsync(takerTokenAddress, takerAddress,
newAllowanceWhichIsLessThanFillAmount);
- zeroEx.setTransactionSenderAccount(takerAddress);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmount, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer, takerAddress,
)).to.be.rejectedWith(ExchangeContractErrs.INSUFFICIENT_TAKER_ALLOWANCE);
});
it('should throw when maker balance is less than maker fill amount', async () => {
await zeroEx.token.transferAsync(
makerTokenAddress, makerAddress, coinbase, balanceToSubtractFromMaker,
);
- zeroEx.setTransactionSenderAccount(takerAddress);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmount, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer, takerAddress,
)).to.be.rejectedWith(ExchangeContractErrs.INSUFFICIENT_MAKER_BALANCE);
});
it('should throw when maker allowance is less than maker fill amount', async () => {
const newAllowanceWhichIsLessThanFillAmount = fillTakerAmount.minus(lackingAllowance);
await zeroEx.token.setProxyAllowanceAsync(makerTokenAddress, makerAddress,
newAllowanceWhichIsLessThanFillAmount);
- zeroEx.setTransactionSenderAccount(takerAddress);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmount, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer, takerAddress,
)).to.be.rejectedWith(ExchangeContractErrs.INSUFFICIENT_MAKER_ALLOWANCE);
});
});
@@ -228,9 +219,8 @@ describe('ExchangeWrapper', () => {
makerAmount, takerAmount,
);
const fillTakerAmountThatCausesRoundingError = new BigNumber(3);
- zeroEx.setTransactionSenderAccount(takerAddress);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmountThatCausesRoundingError, shouldCheckTransfer,
+ signedOrder, fillTakerAmountThatCausesRoundingError, shouldCheckTransfer, takerAddress,
)).to.be.rejectedWith(ExchangeContractErrs.ORDER_FILL_ROUNDING_ERROR);
});
describe('should throw when not enough balance or allowance to pay fees', () => {
@@ -243,7 +233,6 @@ describe('ExchangeWrapper', () => {
makerTokenAddress, takerTokenAddress, makerFee, takerFee,
makerAddress, takerAddress, fillableAmount, feeRecipient,
);
- zeroEx.setTransactionSenderAccount(takerAddress);
});
it('should throw when maker doesn\'t have enough balance to pay fees', async () => {
const balanceToSubtractFromMaker = new BigNumber(1);
@@ -251,7 +240,7 @@ describe('ExchangeWrapper', () => {
zrxTokenAddress, makerAddress, coinbase, balanceToSubtractFromMaker,
);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmount, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer, takerAddress,
)).to.be.rejectedWith(ExchangeContractErrs.INSUFFICIENT_MAKER_FEE_BALANCE);
});
it('should throw when maker doesn\'t have enough allowance to pay fees', async () => {
@@ -259,7 +248,7 @@ describe('ExchangeWrapper', () => {
await zeroEx.token.setProxyAllowanceAsync(zrxTokenAddress, makerAddress,
newAllowanceWhichIsLessThanFees);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmount, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer, takerAddress,
)).to.be.rejectedWith(ExchangeContractErrs.INSUFFICIENT_MAKER_FEE_ALLOWANCE);
});
it('should throw when taker doesn\'t have enough balance to pay fees', async () => {
@@ -268,7 +257,7 @@ describe('ExchangeWrapper', () => {
zrxTokenAddress, takerAddress, coinbase, balanceToSubtractFromTaker,
);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmount, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer, takerAddress,
)).to.be.rejectedWith(ExchangeContractErrs.INSUFFICIENT_TAKER_FEE_BALANCE);
});
it('should throw when taker doesn\'t have enough allowance to pay fees', async () => {
@@ -276,7 +265,7 @@ describe('ExchangeWrapper', () => {
await zeroEx.token.setProxyAllowanceAsync(zrxTokenAddress, takerAddress,
newAllowanceWhichIsLessThanFees);
return expect(zeroEx.exchange.fillOrderAsync(
- signedOrder, fillTakerAmount, shouldCheckTransfer,
+ signedOrder, fillTakerAmount, shouldCheckTransfer, takerAddress,
)).to.be.rejectedWith(ExchangeContractErrs.INSUFFICIENT_TAKER_FEE_ALLOWANCE);
});
});
@@ -295,8 +284,7 @@ describe('ExchangeWrapper', () => {
.to.be.bignumber.equal(0);
expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, takerAddress))
.to.be.bignumber.equal(fillableAmount);
- zeroEx.setTransactionSenderAccount(takerAddress);
- await zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmount, shouldCheckTransfer);
+ await zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmount, shouldCheckTransfer, takerAddress);
expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress))
.to.be.bignumber.equal(fillableAmount.minus(fillTakerAmount));
expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress))
@@ -312,8 +300,7 @@ describe('ExchangeWrapper', () => {
makerTokenAddress, takerTokenAddress, makerAddress, takerAddress, fillableAmount,
);
const partialFillAmount = new BigNumber(3);
- zeroEx.setTransactionSenderAccount(takerAddress);
- await zeroEx.exchange.fillOrderAsync(signedOrder, partialFillAmount, shouldCheckTransfer);
+ await zeroEx.exchange.fillOrderAsync(signedOrder, partialFillAmount, shouldCheckTransfer, takerAddress);
expect(await zeroEx.token.getBalanceAsync(makerTokenAddress, makerAddress))
.to.be.bignumber.equal(fillableAmount.minus(partialFillAmount));
expect(await zeroEx.token.getBalanceAsync(takerTokenAddress, makerAddress))
@@ -331,8 +318,7 @@ describe('ExchangeWrapper', () => {
makerTokenAddress, takerTokenAddress, makerFee, takerFee,
makerAddress, takerAddress, fillableAmount, feeRecipient,
);
- zeroEx.setTransactionSenderAccount(takerAddress);
- await zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmount, shouldCheckTransfer);
+ await zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmount, shouldCheckTransfer, takerAddress);
expect(await zeroEx.token.getBalanceAsync(zrxTokenAddress, feeRecipient))
.to.be.bignumber.equal(makerFee.plus(takerFee));
});
@@ -447,8 +433,9 @@ describe('ExchangeWrapper', () => {
done();
});
const fillTakerAmountInBaseUnits = new BigNumber(1);
- zeroEx.setTransactionSenderAccount(takerAddress);
- await zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer);
+ await zeroEx.exchange.fillOrderAsync(
+ signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer, takerAddress,
+ );
})();
});
it('Outstanding subscriptions are cancelled when zeroEx.setProviderAsync called', (done: DoneCallback) => {
@@ -473,8 +460,9 @@ describe('ExchangeWrapper', () => {
});
const fillTakerAmountInBaseUnits = new BigNumber(1);
- zeroEx.setTransactionSenderAccount(takerAddress);
- await zeroEx.exchange.fillOrderAsync(signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer);
+ await zeroEx.exchange.fillOrderAsync(
+ signedOrder, fillTakerAmountInBaseUnits, shouldCheckTransfer, takerAddress,
+ );
})();
});
});