aboutsummaryrefslogtreecommitdiffstats
path: root/packages/asset-buyer/test
diff options
context:
space:
mode:
authorBrandon Millman <brandon.millman@gmail.com>2018-10-04 14:14:55 +0800
committerBrandon Millman <brandon.millman@gmail.com>2018-10-04 14:22:13 +0800
commit059162a90a3d26e5fdfefd8553bb1f721a3116fc (patch)
treebb3dfc2ef2cefb1d78d65fb7318e8e1c6884a09e /packages/asset-buyer/test
parent250a9a480940ae4fca48109aae97ee0323d57a52 (diff)
downloaddexon-sol-tools-059162a90a3d26e5fdfefd8553bb1f721a3116fc.tar
dexon-sol-tools-059162a90a3d26e5fdfefd8553bb1f721a3116fc.tar.gz
dexon-sol-tools-059162a90a3d26e5fdfefd8553bb1f721a3116fc.tar.bz2
dexon-sol-tools-059162a90a3d26e5fdfefd8553bb1f721a3116fc.tar.lz
dexon-sol-tools-059162a90a3d26e5fdfefd8553bb1f721a3116fc.tar.xz
dexon-sol-tools-059162a90a3d26e5fdfefd8553bb1f721a3116fc.tar.zst
dexon-sol-tools-059162a90a3d26e5fdfefd8553bb1f721a3116fc.zip
Add additional order factory methods and refactor test to use them
Diffstat (limited to 'packages/asset-buyer/test')
-rw-r--r--packages/asset-buyer/test/buy_quote_calculator_test.ts83
1 files changed, 23 insertions, 60 deletions
diff --git a/packages/asset-buyer/test/buy_quote_calculator_test.ts b/packages/asset-buyer/test/buy_quote_calculator_test.ts
index 37a429531..3bd0f8d4e 100644
--- a/packages/asset-buyer/test/buy_quote_calculator_test.ts
+++ b/packages/asset-buyer/test/buy_quote_calculator_test.ts
@@ -27,74 +27,37 @@ describe('buyQuoteCalculator', () => {
// the second order has a rate of 2 makerAsset / WETH with a takerFee of 100 ZRX and has 200 / 200 makerAsset units left to fill (completely fillable)
// generate one order for fees
// the fee order has a rate of 1 ZRX / WETH with no taker fee and has 100 ZRX left to fill (completely fillable)
- const firstOrder = orderFactory.createOrder(
- NULL_ADDRESS,
- new BigNumber(400),
- NULL_BYTES,
- new BigNumber(100),
- NULL_BYTES,
- NULL_ADDRESS,
- {
- takerFee: new BigNumber(200),
- },
- );
+ const firstOrder = orderFactory.createSignedOrderFromPartial({
+ makerAssetAmount: new BigNumber(400),
+ takerAssetAmount: new BigNumber(100),
+ takerFee: new BigNumber(200),
+ });
const firstRemainingFillAmount = new BigNumber(200);
- const secondOrder = orderFactory.createOrder(
- NULL_ADDRESS,
- new BigNumber(200),
- NULL_BYTES,
- new BigNumber(100),
- NULL_BYTES,
- NULL_ADDRESS,
- {
- takerFee: new BigNumber(100),
- },
- );
- const secondRemainingFillAmount = secondOrder.makerAssetAmount;
- const signedOrders = _.map([firstOrder, secondOrder], order => {
- return {
- ...order,
- signature: NULL_BYTES,
- };
+ const secondOrder = orderFactory.createSignedOrderFromPartial({
+ makerAssetAmount: new BigNumber(200),
+ takerAssetAmount: new BigNumber(100),
+ takerFee: new BigNumber(100),
});
+ const secondRemainingFillAmount = secondOrder.makerAssetAmount;
ordersAndFillableAmounts = {
- orders: signedOrders,
+ orders: [firstOrder, secondOrder],
remainingFillableMakerAssetAmounts: [firstRemainingFillAmount, secondRemainingFillAmount],
};
- const smallFeeOrder = orderFactory.createOrder(
- NULL_ADDRESS,
- new BigNumber(100),
- NULL_BYTES,
- new BigNumber(100),
- NULL_BYTES,
- NULL_ADDRESS,
- );
- const signedSmallFeeOrder = {
- ...smallFeeOrder,
- signature: NULL_BYTES,
- };
+ const smallFeeOrder = orderFactory.createSignedOrderFromPartial({
+ makerAssetAmount: new BigNumber(100),
+ takerAssetAmount: new BigNumber(100),
+ });
smallFeeOrderAndFillableAmount = {
- orders: [signedSmallFeeOrder],
- remainingFillableMakerAssetAmounts: [signedSmallFeeOrder.makerAssetAmount],
- };
- const largeFeeOrder = orderFactory.createOrder(
- NULL_ADDRESS,
- new BigNumber(100),
- NULL_BYTES,
- new BigNumber(200),
- NULL_BYTES,
- NULL_ADDRESS,
- );
- const signedLargeFeeOrder = {
- ...largeFeeOrder,
- signature: NULL_BYTES,
+ orders: [smallFeeOrder],
+ remainingFillableMakerAssetAmounts: [smallFeeOrder.makerAssetAmount],
};
+ const largeFeeOrder = orderFactory.createSignedOrderFromPartial({
+ makerAssetAmount: new BigNumber(100),
+ takerAssetAmount: new BigNumber(200),
+ });
allFeeOrdersAndFillableAmounts = {
- orders: [signedSmallFeeOrder, signedLargeFeeOrder],
- remainingFillableMakerAssetAmounts: [
- signedSmallFeeOrder.makerAssetAmount,
- largeFeeOrder.makerAssetAmount,
- ],
+ orders: [smallFeeOrder, largeFeeOrder],
+ remainingFillableMakerAssetAmounts: [smallFeeOrder.makerAssetAmount, largeFeeOrder.makerAssetAmount],
};
});
it('should throw if not enough maker asset liquidity', () => {