aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/test
diff options
context:
space:
mode:
Diffstat (limited to 'packages/asset-buyer/test')
-rw-r--r--packages/asset-buyer/test/buy_quote_calculator_test.ts28
-rw-r--r--packages/asset-buyer/test/utils/test_helpers.ts4
2 files changed, 30 insertions, 2 deletions
diff --git a/packages/asset-buyer/test/buy_quote_calculator_test.ts b/packages/asset-buyer/test/buy_quote_calculator_test.ts
index 1dd829a0f..98458cd5b 100644
--- a/packages/asset-buyer/test/buy_quote_calculator_test.ts
+++ b/packages/asset-buyer/test/buy_quote_calculator_test.ts
@@ -81,6 +81,34 @@ describe('buyQuoteCalculator', () => {
};
testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(400));
});
+ it('should throw if not enough maker asset liquidity (multiple orders with 20% slippage)', () => {
+ // we have 400 makerAsset units available to fill but attempt to calculate a quote for 500 makerAsset units
+ const errorFunction = () => {
+ buyQuoteCalculator.calculate(
+ ordersAndFillableAmounts,
+ smallFeeOrderAndFillableAmount,
+ new BigNumber(500),
+ 0,
+ 0.2,
+ false,
+ );
+ };
+ testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(333));
+ });
+ it('should throw if not enough maker asset liquidity (multiple orders with 5% slippage)', () => {
+ // we have 400 makerAsset units available to fill but attempt to calculate a quote for 500 makerAsset units
+ const errorFunction = () => {
+ buyQuoteCalculator.calculate(
+ ordersAndFillableAmounts,
+ smallFeeOrderAndFillableAmount,
+ new BigNumber(600),
+ 0,
+ 0.05,
+ false,
+ );
+ };
+ testHelpers.expectInsufficientLiquidityError(expect, errorFunction, new BigNumber(380));
+ });
it('should throw if not enough maker asset liquidity (partially filled order)', () => {
const firstOrderAndFillableAmount: OrdersAndFillableAmounts = {
orders: [firstOrder],
diff --git a/packages/asset-buyer/test/utils/test_helpers.ts b/packages/asset-buyer/test/utils/test_helpers.ts
index fd1313ac8..b99906792 100644
--- a/packages/asset-buyer/test/utils/test_helpers.ts
+++ b/packages/asset-buyer/test/utils/test_helpers.ts
@@ -6,7 +6,7 @@ export const testHelpers = {
expectInsufficientLiquidityError: (
expect: Chai.ExpectStatic,
functionWhichTriggersError: () => void,
- expectedNumAvailable: BigNumber,
+ expectedAmountAvailableToFill: BigNumber,
): void => {
let errorThrown = false;
try {
@@ -14,7 +14,7 @@ export const testHelpers = {
} catch (e) {
errorThrown = true;
expect(e).to.be.instanceOf(InsufficientAssetLiquidityError);
- expect(e.numAssetsAvailable).to.be.bignumber.equal(expectedNumAvailable);
+ expect(e.amountAvailableToFill).to.be.bignumber.equal(expectedAmountAvailableToFill);
}
expect(errorThrown).to.be.true();