aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/exchange
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-15 06:03:00 +0800
committerFabio Berger <me@fabioberger.com>2018-06-15 06:03:00 +0800
commitfb55def54f44413a8b0a7f001fb18d6eac89e422 (patch)
tree788b374af5d6690149cd76548f386f237dc635f1 /packages/contracts/test/exchange
parenteea86757d5cdd63de4b0b06f7dd76fc2c2ddbd36 (diff)
downloaddexon-0x-contracts-fb55def54f44413a8b0a7f001fb18d6eac89e422.tar.gz
dexon-0x-contracts-fb55def54f44413a8b0a7f001fb18d6eac89e422.tar.zst
dexon-0x-contracts-fb55def54f44413a8b0a7f001fb18d6eac89e422.zip
Add ability to tweak the relevant balances/allowances for the maker and taker for a fillScenario. Convert more of the core tests to the declarative form.
Diffstat (limited to 'packages/contracts/test/exchange')
-rw-r--r--packages/contracts/test/exchange/core.ts43
-rw-r--r--packages/contracts/test/exchange/fill_order.ts57
2 files changed, 57 insertions, 43 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 193754e70..453f05df2 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -148,49 +148,6 @@ describe('Exchange core', () => {
);
});
- it('should throw if maker erc20Balances are too low to fill order', async () => {
- signedOrder = orderFactory.newSignedOrder({
- makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18),
- });
-
- return expectRevertOrAlwaysFailingTransactionAsync(
- exchangeWrapper.fillOrderAsync(signedOrder, takerAddress),
- );
- });
-
- it('should throw if taker erc20Balances are too low to fill order', async () => {
- signedOrder = orderFactory.newSignedOrder({
- takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100000), 18),
- });
- return expectRevertOrAlwaysFailingTransactionAsync(
- exchangeWrapper.fillOrderAsync(signedOrder, takerAddress),
- );
- });
-
- it('should throw if maker allowances are too low to fill order', async () => {
- await web3Wrapper.awaitTransactionSuccessAsync(
- await erc20TokenA.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
- from: makerAddress,
- }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- return expectRevertOrAlwaysFailingTransactionAsync(
- exchangeWrapper.fillOrderAsync(signedOrder, takerAddress),
- );
- });
-
- it('should throw if taker allowances are too low to fill order', async () => {
- await web3Wrapper.awaitTransactionSuccessAsync(
- await erc20TokenB.approve.sendTransactionAsync(erc20Proxy.address, new BigNumber(0), {
- from: takerAddress,
- }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- return expectRevertOrAlwaysFailingTransactionAsync(
- exchangeWrapper.fillOrderAsync(signedOrder, takerAddress),
- );
- });
-
it('should throw if no value is filled', async () => {
signedOrder = orderFactory.newSignedOrder();
await exchangeWrapper.fillOrderAsync(signedOrder, takerAddress);
diff --git a/packages/contracts/test/exchange/fill_order.ts b/packages/contracts/test/exchange/fill_order.ts
index 2498ee27e..5e8dd6ffc 100644
--- a/packages/contracts/test/exchange/fill_order.ts
+++ b/packages/contracts/test/exchange/fill_order.ts
@@ -13,6 +13,7 @@ import {
OrderScenario,
TakerAssetFillAmountScenario,
TakerScenario,
+ TokenAmountScenario,
} from '../../src/utils/types';
chaiSetup.configure();
@@ -31,6 +32,18 @@ const defaultFillScenario = {
takerAssetDataScenario: AssetDataScenario.ERC20NonZRXEighteenDecimals,
},
takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount,
+ makerStateScenario: {
+ traderAssetBalance: TokenAmountScenario.Higher,
+ traderAssetAllowance: TokenAmountScenario.Higher,
+ zrxFeeBalance: TokenAmountScenario.Higher,
+ zrxFeeAllowance: TokenAmountScenario.Higher,
+ },
+ takerStateScenario: {
+ traderAssetBalance: TokenAmountScenario.Higher,
+ traderAssetAllowance: TokenAmountScenario.Higher,
+ zrxFeeBalance: TokenAmountScenario.Higher,
+ zrxFeeAllowance: TokenAmountScenario.Higher,
+ },
};
describe('FillOrder Tests', () => {
@@ -144,6 +157,50 @@ describe('FillOrder Tests', () => {
};
await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario);
});
+
+ it('should throw if maker erc20Balances are too low to fill order', async () => {
+ const fillScenario = {
+ ...defaultFillScenario,
+ makerStateScenario: {
+ ...defaultFillScenario.makerStateScenario,
+ traderAssetBalance: TokenAmountScenario.TooLow,
+ },
+ };
+ await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario);
+ });
+
+ it('should throw if taker erc20Balances are too low to fill order', async () => {
+ const fillScenario = {
+ ...defaultFillScenario,
+ takerStateScenario: {
+ ...defaultFillScenario.makerStateScenario,
+ traderAssetBalance: TokenAmountScenario.TooLow,
+ },
+ };
+ await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario);
+ });
+
+ it('should throw if maker allowances are too low to fill order', async () => {
+ const fillScenario = {
+ ...defaultFillScenario,
+ makerStateScenario: {
+ ...defaultFillScenario.makerStateScenario,
+ traderAssetAllowance: TokenAmountScenario.TooLow,
+ },
+ };
+ await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario);
+ });
+
+ it('should throw if taker allowances are too low to fill order', async () => {
+ const fillScenario = {
+ ...defaultFillScenario,
+ takerStateScenario: {
+ ...defaultFillScenario.makerStateScenario,
+ traderAssetAllowance: TokenAmountScenario.TooLow,
+ },
+ };
+ await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario);
+ });
});
describe('Testing Exchange of ERC721 Tokens', () => {