Created tests for batchMatchOrders

This commit is contained in:
James Towle
2019-06-24 17:21:48 -05:00
committed by Amir Bandeali
parent f289b3112b
commit 6cf11554de
6 changed files with 594 additions and 32 deletions

View File

@@ -5,7 +5,7 @@ import { BigNumber } from '@0x/utils';
import * as _ from 'lodash';
import { constants } from './constants';
import { CancelOrder, MatchOrder } from './types';
import { BatchMatchOrder, CancelOrder, MatchOrder } from './types';
export const orderUtils = {
getPartialAmountFloor(numerator: BigNumber, denominator: BigNumber, target: BigNumber): BigNumber {
@@ -33,6 +33,19 @@ export const orderUtils = {
getOrderWithoutDomain(signedOrder: SignedOrder): OrderWithoutDomain {
return _.omit(signedOrder, ['signature', 'domain']) as OrderWithoutDomain;
},
createBatchMatchOrders(signedOrdersLeft: SignedOrder[], signedOrdersRight: SignedOrder[]): BatchMatchOrder {
return {
leftOrders: signedOrdersLeft.map(order => orderUtils.getOrderWithoutDomain(order)),
rightOrders: signedOrdersRight.map(order => {
const right = orderUtils.getOrderWithoutDomain(order);
right.makerAssetData = constants.NULL_BYTES;
right.takerAssetData = constants.NULL_BYTES;
return right;
}),
leftSignatures: signedOrdersLeft.map(order => order.signature),
rightSignatures: signedOrdersRight.map(order => order.signature),
};
},
createMatchOrders(signedOrderLeft: SignedOrder, signedOrderRight: SignedOrder): MatchOrder {
const fill = {
left: orderUtils.getOrderWithoutDomain(signedOrderLeft),