@0x/contracts-exchange
: Update CHANGELOG, lint, prettify.
This commit is contained in:
parent
7ce65e3cfe
commit
0d05411cd2
@ -137,6 +137,10 @@
|
||||
{
|
||||
"note": "Remove `_assertValidFill()`",
|
||||
"pr": 2031
|
||||
},
|
||||
{
|
||||
"note": "Add `wrapper_unit_tests` tests and `TestWrapperFunctions` contract",
|
||||
"pr": "TODO"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -49,6 +49,19 @@ contract TestWrapperFunctions is
|
||||
Exchange(0x74657374)
|
||||
{}
|
||||
|
||||
/// @dev Overridden to be deterministic and simplified.
|
||||
function getOrderInfo(Order memory order)
|
||||
public
|
||||
view
|
||||
returns (OrderInfo memory orderInfo)
|
||||
{
|
||||
// Lower uint128 of `order.salt` is the `orderTakerAssetFilledAmount`.
|
||||
orderInfo.orderTakerAssetFilledAmount = uint128(order.salt);
|
||||
// High byte of `order.salt` is the `orderStatus`.
|
||||
orderInfo.orderStatus = uint8(order.salt >> 248) % (MAX_ORDER_STATUS + 1);
|
||||
orderInfo.orderHash = _getOrderHash(order);
|
||||
}
|
||||
|
||||
/// @dev Overridden to log arguments, be deterministic, and revert with certain inputs.
|
||||
function _fillOrder(
|
||||
Order memory order,
|
||||
@ -94,19 +107,7 @@ contract TestWrapperFunctions is
|
||||
}
|
||||
}
|
||||
|
||||
/// @dev Overridden to be deterministic and simplified.
|
||||
function getOrderInfo(Order memory order)
|
||||
public
|
||||
view
|
||||
returns (OrderInfo memory orderInfo)
|
||||
{
|
||||
// Lower uint128 of `order.salt` is the `orderTakerAssetFilledAmount`.
|
||||
orderInfo.orderTakerAssetFilledAmount = uint128(order.salt);
|
||||
// High byte of `order.salt` is the `orderStatus`.
|
||||
orderInfo.orderStatus = uint8(order.salt >> 248) % (MAX_ORDER_STATUS + 1);
|
||||
orderInfo.orderHash = _getOrderHash(order);
|
||||
}
|
||||
|
||||
/// @dev Simplified order hashing.
|
||||
function _getOrderHash(Order memory order)
|
||||
internal
|
||||
pure
|
||||
|
@ -933,8 +933,7 @@ describe('Exchange wrappers', () => {
|
||||
});
|
||||
}
|
||||
};
|
||||
describe('marketSellOrders reentrancy tests', () =>
|
||||
reentrancyTest(exchangeConstants.FUNCTIONS_WITH_MUTEX));
|
||||
describe('marketSellOrders reentrancy tests', () => reentrancyTest(exchangeConstants.FUNCTIONS_WITH_MUTEX));
|
||||
|
||||
it('should stop when the entire takerAssetFillAmount is filled', async () => {
|
||||
const takerAssetFillAmount = signedOrders[0].takerAssetAmount.plus(
|
||||
@ -1151,8 +1150,7 @@ describe('Exchange wrappers', () => {
|
||||
});
|
||||
}
|
||||
};
|
||||
describe('marketBuyOrders reentrancy tests', () =>
|
||||
reentrancyTest(exchangeConstants.FUNCTIONS_WITH_MUTEX));
|
||||
describe('marketBuyOrders reentrancy tests', () => reentrancyTest(exchangeConstants.FUNCTIONS_WITH_MUTEX));
|
||||
|
||||
it('should stop when the entire makerAssetFillAmount is filled', async () => {
|
||||
const makerAssetFillAmount = signedOrders[0].makerAssetAmount.plus(
|
||||
|
@ -1,34 +1,22 @@
|
||||
import { ReferenceFunctions as LibReferenceFunctions } from '@0x/contracts-exchange-libs';
|
||||
import {
|
||||
blockchainTests,
|
||||
constants,
|
||||
describe,
|
||||
expect,
|
||||
hexRandom,
|
||||
TransactionHelper,
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { blockchainTests, constants, describe, expect, hexRandom, TransactionHelper } from '@0x/contracts-test-utils';
|
||||
import { ReferenceFunctions as UtilReferenceFunctions } from '@0x/contracts-utils';
|
||||
import { ExchangeRevertErrors } from '@0x/order-utils';
|
||||
import { FillResults, OrderInfo, OrderStatus, OrderWithoutDomain as Order } from '@0x/types';
|
||||
import {
|
||||
AnyRevertError,
|
||||
BigNumber,
|
||||
SafeMathRevertErrors,
|
||||
StringRevertError,
|
||||
} from '@0x/utils';
|
||||
import { AnyRevertError, BigNumber, SafeMathRevertErrors, StringRevertError } from '@0x/utils';
|
||||
import { LogEntry, LogWithDecodedArgs } from 'ethereum-types';
|
||||
import * as ethjs from 'ethereumjs-util';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import {
|
||||
artifacts,
|
||||
TestWrapperFunctionsCancelOrderCalledEventArgs as CancelOrderCalledEventArgs,
|
||||
TestWrapperFunctionsContract,
|
||||
TestWrapperFunctionsFillOrderCalledEventArgs as FillOrderCalledEventArgs,
|
||||
TestWrapperFunctionsCancelOrderCalledEventArgs as CancelOrderCalledEventArgs,
|
||||
} from '../src';
|
||||
|
||||
blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const { ONE_ETHER, MAX_UINT256, MAX_UINT256_ROOT } = constants;
|
||||
const { ONE_ETHER, MAX_UINT256 } = constants;
|
||||
const { addFillResults, getPartialAmountFloor } = LibReferenceFunctions;
|
||||
const { safeSub } = UtilReferenceFunctions;
|
||||
const randomAddress = () => hexRandom(constants.ADDRESS_LENGTH);
|
||||
@ -49,7 +37,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
let senderAddress: string;
|
||||
|
||||
before(async () => {
|
||||
[ senderAddress ] = await env.getAccountAddressesAsync();
|
||||
[senderAddress] = await env.getAccountAddressesAsync();
|
||||
txHelper = new TransactionHelper(env.web3Wrapper, artifacts);
|
||||
testContract = await TestWrapperFunctionsContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestWrapperFunctions,
|
||||
@ -59,31 +47,38 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
});
|
||||
|
||||
function randomOrder(fields?: Partial<Order>): Order {
|
||||
return _.assign({
|
||||
makerAddress: randomAddress(),
|
||||
takerAddress: randomAddress(),
|
||||
feeRecipientAddress: randomAddress(),
|
||||
senderAddress: randomAddress(),
|
||||
takerAssetAmount: randomAmount(),
|
||||
makerAssetAmount: randomAmount(),
|
||||
makerFee: randomAmount(),
|
||||
takerFee: randomAmount(),
|
||||
expirationTimeSeconds: randomTimestamp(),
|
||||
salt: randomSalt(),
|
||||
makerAssetData: randomAssetData(),
|
||||
takerAssetData: randomAssetData(),
|
||||
makerFeeAssetData: randomAssetData(),
|
||||
takerFeeAssetData: randomAssetData(),
|
||||
}, fields);
|
||||
return _.assign(
|
||||
{
|
||||
makerAddress: randomAddress(),
|
||||
takerAddress: randomAddress(),
|
||||
feeRecipientAddress: randomAddress(),
|
||||
senderAddress: randomAddress(),
|
||||
takerAssetAmount: randomAmount(),
|
||||
makerAssetAmount: randomAmount(),
|
||||
makerFee: randomAmount(),
|
||||
takerFee: randomAmount(),
|
||||
expirationTimeSeconds: randomTimestamp(),
|
||||
salt: randomSalt(),
|
||||
makerAssetData: randomAssetData(),
|
||||
takerAssetData: randomAssetData(),
|
||||
makerFeeAssetData: randomAssetData(),
|
||||
takerFeeAssetData: randomAssetData(),
|
||||
},
|
||||
fields,
|
||||
);
|
||||
}
|
||||
|
||||
// Computes the expected (fake) order hash generated by the `TestWrapperFunctions` contract.
|
||||
function getExpectedOrderHash(order: Order): string {
|
||||
return ethjs.bufferToHex(ethjs.sha3(Buffer.concat([
|
||||
ethjs.toBuffer(order.makerAssetData),
|
||||
ethjs.toBuffer(order.takerAssetData),
|
||||
ethjs.setLengthLeft(`0x${order.salt.toString(16)}`, constants.WORD_LENGTH),
|
||||
])));
|
||||
return ethjs.bufferToHex(
|
||||
ethjs.sha3(
|
||||
Buffer.concat([
|
||||
ethjs.toBuffer(order.makerAssetData),
|
||||
ethjs.toBuffer(order.takerAssetData),
|
||||
ethjs.setLengthLeft(`0x${order.salt.toString(16)}`, constants.WORD_LENGTH),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Computes the expected (fake) fill results from `TestWrapperFunctions` `_fillOrder` implementation.
|
||||
@ -107,18 +102,11 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
|
||||
// Asserts that `_fillOrder()` was called in the same order and with the same
|
||||
// arguments as given by examining receipt logs.
|
||||
function assertFillOrderCallsFromLogs(
|
||||
logs: LogEntry[],
|
||||
calls: Array<[Order, BigNumber, string]>,
|
||||
): void {
|
||||
function assertFillOrderCallsFromLogs(logs: LogEntry[], calls: Array<[Order, BigNumber, string]>): void {
|
||||
expect(logs.length).to.eq(calls.length);
|
||||
for (const i of _.times(calls.length)) {
|
||||
const log = logs[i] as LogWithDecodedArgs<FillOrderCalledEventArgs>;
|
||||
const [
|
||||
expectedOrder,
|
||||
expectedTakerAssetFillAmount,
|
||||
expectedSignature,
|
||||
] = calls[i];
|
||||
const log = (logs[i] as any) as LogWithDecodedArgs<FillOrderCalledEventArgs>;
|
||||
const [expectedOrder, expectedTakerAssetFillAmount, expectedSignature] = calls[i];
|
||||
expect(log.event).to.eq('FillOrderCalled');
|
||||
assertSameOrderFromEvent(log.args.order as any, expectedOrder);
|
||||
expect(log.args.takerAssetFillAmount).to.bignumber.eq(expectedTakerAssetFillAmount);
|
||||
@ -154,8 +142,8 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
});
|
||||
const signature = createOrderSignature(order);
|
||||
const expectedResult = getExpectedFillResults(order, signature);
|
||||
const expectedCalls = [[ order, fillAmount, signature ]];
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const expectedCalls = [[order, fillAmount, signature]];
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.fillOrKillOrder,
|
||||
order,
|
||||
fillAmount,
|
||||
@ -173,14 +161,8 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
takerAssetAmount: fillAmount.minus(1),
|
||||
});
|
||||
const signature = createOrderSignature(order);
|
||||
const expectedError = new ExchangeRevertErrors.IncompleteFillError(
|
||||
getExpectedOrderHash(order),
|
||||
);
|
||||
const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(
|
||||
order,
|
||||
fillAmount,
|
||||
signature,
|
||||
);
|
||||
const expectedError = new ExchangeRevertErrors.IncompleteFillError(getExpectedOrderHash(order));
|
||||
const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(order, fillAmount, signature);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
@ -192,14 +174,8 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
takerAssetAmount: fillAmount.plus(1),
|
||||
});
|
||||
const signature = createOrderSignature(order);
|
||||
const expectedError = new ExchangeRevertErrors.IncompleteFillError(
|
||||
getExpectedOrderHash(order),
|
||||
);
|
||||
const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(
|
||||
order,
|
||||
fillAmount,
|
||||
signature,
|
||||
);
|
||||
const expectedError = new ExchangeRevertErrors.IncompleteFillError(getExpectedOrderHash(order));
|
||||
const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(order, fillAmount, signature);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
@ -210,11 +186,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
});
|
||||
const signature = createOrderSignature(order);
|
||||
const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR;
|
||||
const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(
|
||||
order,
|
||||
fillAmount,
|
||||
signature,
|
||||
);
|
||||
const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(order, fillAmount, signature);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
});
|
||||
@ -225,8 +197,8 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const order = randomOrder();
|
||||
const signature = createOrderSignature(order);
|
||||
const expectedResult = getExpectedFillResults(order, signature);
|
||||
const expectedCalls = [[ order, fillAmount, signature ]];
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const expectedCalls = [[order, fillAmount, signature]];
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.fillOrderNoThrow,
|
||||
order,
|
||||
fillAmount,
|
||||
@ -243,7 +215,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
});
|
||||
const signature = createOrderSignature(order);
|
||||
const expectedResult = EMPTY_FILL_RESULTS;
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.fillOrderNoThrow,
|
||||
order,
|
||||
fillAmount,
|
||||
@ -256,7 +228,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
|
||||
describe('batchFillOrders', () => {
|
||||
it('works with no fills', async () => {
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrders,
|
||||
[],
|
||||
[],
|
||||
@ -273,7 +245,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const signatures = _.times(COUNT, i => createOrderSignature(orders[i]));
|
||||
const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i]));
|
||||
const expectedCalls = _.zip(orders, fillAmounts, signatures);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrders,
|
||||
orders,
|
||||
fillAmounts,
|
||||
@ -290,7 +262,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const signatures = _.times(COUNT, i => createOrderSignature(orders[i]));
|
||||
const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i]));
|
||||
const expectedCalls = _.zip(orders, fillAmounts, signatures);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrders,
|
||||
orders,
|
||||
fillAmounts,
|
||||
@ -309,7 +281,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const signatures = _.times(COUNT, i => createOrderSignature(orders[i]));
|
||||
const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i]));
|
||||
const expectedCalls = _.zip(orders, fillAmounts, signatures);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrders,
|
||||
orders,
|
||||
fillAmounts,
|
||||
@ -325,12 +297,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const fillAmounts = _.times(COUNT - 1, i => orders[i].takerAssetAmount);
|
||||
const signatures = _.times(COUNT, i => createOrderSignature(orders[i]));
|
||||
const expectedError = new AnyRevertError(); // Just a generic revert.
|
||||
const tx = txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrders,
|
||||
orders,
|
||||
fillAmounts,
|
||||
signatures,
|
||||
);
|
||||
const tx = txHelper.getResultAndReceiptAsync(testContract.batchFillOrders, orders, fillAmounts, signatures);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
@ -340,19 +307,14 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const fillAmounts = _.times(COUNT, i => orders[i].takerAssetAmount);
|
||||
const signatures = _.times(COUNT - 1, i => createOrderSignature(orders[i]));
|
||||
const expectedError = new AnyRevertError(); // Just a generic revert.
|
||||
const tx = txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrders,
|
||||
orders,
|
||||
fillAmounts,
|
||||
signatures,
|
||||
);
|
||||
const tx = txHelper.getResultAndReceiptAsync(testContract.batchFillOrders, orders, fillAmounts, signatures);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
});
|
||||
|
||||
describe('batchFillOrKillOrders', () => {
|
||||
it('works with no fills', async () => {
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrKillOrders,
|
||||
[],
|
||||
[],
|
||||
@ -369,7 +331,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const signatures = _.times(COUNT, i => createOrderSignature(orders[i]));
|
||||
const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i]));
|
||||
const expectedCalls = _.zip(orders, fillAmounts, signatures);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrKillOrders,
|
||||
orders,
|
||||
fillAmounts,
|
||||
@ -386,7 +348,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const signatures = _.times(COUNT, i => createOrderSignature(orders[i]));
|
||||
const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i]));
|
||||
const expectedCalls = _.zip(orders, fillAmounts, signatures);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrKillOrders,
|
||||
orders,
|
||||
fillAmounts,
|
||||
@ -405,7 +367,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const signatures = _.times(COUNT, i => createOrderSignature(orders[i]));
|
||||
const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i]));
|
||||
const expectedCalls = _.zip(orders, fillAmounts, signatures);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrKillOrders,
|
||||
orders,
|
||||
fillAmounts,
|
||||
@ -425,9 +387,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
// `_fillOrder()` is overridden to always return `order.takerAssetAmount` as
|
||||
// the `takerAssetFilledAmount`.
|
||||
failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.minus(1);
|
||||
const expectedError = new ExchangeRevertErrors.IncompleteFillError(
|
||||
getExpectedOrderHash(failingOrder),
|
||||
);
|
||||
const expectedError = new ExchangeRevertErrors.IncompleteFillError(getExpectedOrderHash(failingOrder));
|
||||
const tx = txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrKillOrders,
|
||||
orders,
|
||||
@ -447,9 +407,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
// `_fillOrder()` is overridden to always return `order.takerAssetAmount` as
|
||||
// the `takerAssetFilledAmount`.
|
||||
failingOrder.takerAssetAmount = failingOrder.takerAssetAmount.plus(1);
|
||||
const expectedError = new ExchangeRevertErrors.IncompleteFillError(
|
||||
getExpectedOrderHash(failingOrder),
|
||||
);
|
||||
const expectedError = new ExchangeRevertErrors.IncompleteFillError(getExpectedOrderHash(failingOrder));
|
||||
const tx = txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrKillOrders,
|
||||
orders,
|
||||
@ -492,7 +450,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
|
||||
describe('batchFillOrdersNoThrow', () => {
|
||||
it('works with no fills', async () => {
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrdersNoThrow,
|
||||
[],
|
||||
[],
|
||||
@ -509,7 +467,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const signatures = _.times(COUNT, i => createOrderSignature(orders[i]));
|
||||
const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i]));
|
||||
const expectedCalls = _.zip(orders, fillAmounts, signatures);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrdersNoThrow,
|
||||
orders,
|
||||
fillAmounts,
|
||||
@ -526,7 +484,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const signatures = _.times(COUNT, i => createOrderSignature(orders[i]));
|
||||
const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i]));
|
||||
const expectedCalls = _.zip(orders, fillAmounts, signatures);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrdersNoThrow,
|
||||
orders,
|
||||
fillAmounts,
|
||||
@ -545,7 +503,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const signatures = _.times(COUNT, i => createOrderSignature(orders[i]));
|
||||
const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i]));
|
||||
const expectedCalls = _.zip(orders, fillAmounts, signatures);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrdersNoThrow,
|
||||
orders,
|
||||
fillAmounts,
|
||||
@ -566,7 +524,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const expectedResult = _.times(COUNT, i => getExpectedFillResults(orders[i], signatures[i]));
|
||||
const expectedCalls = _.zip(orders, fillAmounts, signatures);
|
||||
expectedCalls.splice(FAILING_ORDER_INDEX, 1);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchFillOrdersNoThrow,
|
||||
orders,
|
||||
fillAmounts,
|
||||
@ -616,11 +574,8 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const fillOrderCalls = [];
|
||||
let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS);
|
||||
const takerAssetData = orders[0].takerAssetData;
|
||||
for (const [ order, signature ] of _.zip(orders, signatures) as [[Order, string]]) {
|
||||
const remainingTakerAssetFillAmount = safeSub(
|
||||
takerAssetFillAmount,
|
||||
fillResults.takerAssetFilledAmount,
|
||||
);
|
||||
for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) {
|
||||
const remainingTakerAssetFillAmount = safeSub(takerAssetFillAmount, fillResults.takerAssetFilledAmount);
|
||||
if (order.salt !== ALWAYS_FAILING_SALT) {
|
||||
const modifiedOrder = { ...order, takerAssetData };
|
||||
fillOrderCalls.push([modifiedOrder, remainingTakerAssetFillAmount, signature]);
|
||||
@ -642,13 +597,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
(total, o) => o.takerAssetAmount.plus(total),
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketSellOrders(
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketSellOrders(orders, takerAssetFillAmount, signatures);
|
||||
expect(expectedCalls.length).to.eq(COUNT);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketSellOrders,
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
@ -667,13 +618,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
(total, o) => o.takerAssetAmount.plus(total),
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketSellOrders(
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketSellOrders(orders, takerAssetFillAmount, signatures);
|
||||
expect(expectedCalls.length).to.eq(COUNT);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketSellOrders,
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
@ -694,13 +641,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
(total, o) => o.takerAssetAmount.plus(total),
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketSellOrders(
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketSellOrders(orders, takerAssetFillAmount, signatures);
|
||||
expect(expectedCalls.length).to.eq(COUNT);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketSellOrders,
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
@ -724,13 +667,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
(total, o) => o.takerAssetAmount.plus(total),
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketSellOrders(
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketSellOrders(orders, takerAssetFillAmount, signatures);
|
||||
expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketSellOrders,
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
@ -749,13 +688,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
(total, o) => o.takerAssetAmount.plus(total),
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketSellOrders(
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketSellOrders(orders, takerAssetFillAmount, signatures);
|
||||
expect(expectedCalls.length).to.eq(0);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketSellOrders,
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
@ -775,14 +710,10 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
(total, o) => o.takerAssetAmount.plus(total),
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketSellOrders(
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketSellOrders(orders, takerAssetFillAmount, signatures);
|
||||
// It should stop filling after the penultimate order.
|
||||
expect(expectedCalls.length).to.eq(COUNT - 1);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketSellOrders,
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
@ -805,14 +736,10 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
// setting the first order's `takerAssetAmount` to larger than
|
||||
// `takerAssetFillAmount` will cause an overfill.
|
||||
orders[0].takerAssetAmount = takerAssetFillAmount.plus(1);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketSellOrders(
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketSellOrders(orders, takerAssetFillAmount, signatures);
|
||||
// It should stop filling after first order.
|
||||
expect(expectedCalls.length).to.eq(1);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketSellOrders,
|
||||
orders,
|
||||
takerAssetFillAmount,
|
||||
@ -844,12 +771,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
|
||||
it('reverts with no orders', async () => {
|
||||
const expectedError = new AnyRevertError(); // Just a generic revert.
|
||||
const tx = txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketSellOrders,
|
||||
[],
|
||||
constants.ZERO_AMOUNT,
|
||||
[],
|
||||
);
|
||||
const tx = txHelper.getResultAndReceiptAsync(testContract.marketSellOrders, [], constants.ZERO_AMOUNT, []);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
});
|
||||
@ -863,11 +785,8 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const fillOrderCalls = [];
|
||||
let fillResults = _.cloneDeep(EMPTY_FILL_RESULTS);
|
||||
const makerAssetData = orders[0].makerAssetData;
|
||||
for (const [ order, signature ] of _.zip(orders, signatures) as [[Order, string]]) {
|
||||
const remainingMakerAssetFillAmount = safeSub(
|
||||
makerAssetFillAmount,
|
||||
fillResults.makerAssetFilledAmount,
|
||||
);
|
||||
for (const [order, signature] of _.zip(orders, signatures) as [[Order, string]]) {
|
||||
const remainingMakerAssetFillAmount = safeSub(makerAssetFillAmount, fillResults.makerAssetFilledAmount);
|
||||
const remainingTakerAssetFillAmount = getPartialAmountFloor(
|
||||
order.takerAssetAmount,
|
||||
order.makerAssetAmount,
|
||||
@ -894,13 +813,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
(total, o) => o.makerAssetAmount.plus(total),
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketBuyOrders(
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketBuyOrders(orders, makerAssetFillAmount, signatures);
|
||||
expect(expectedCalls.length).to.eq(COUNT);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketBuyOrders,
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
@ -919,13 +834,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
(total, o) => o.makerAssetAmount.plus(total),
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketBuyOrders(
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketBuyOrders(orders, makerAssetFillAmount, signatures);
|
||||
expect(expectedCalls.length).to.eq(COUNT);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketBuyOrders,
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
@ -946,13 +857,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
(total, o) => o.makerAssetAmount.plus(total),
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketBuyOrders(
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketBuyOrders(orders, makerAssetFillAmount, signatures);
|
||||
expect(expectedCalls.length).to.eq(COUNT);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketBuyOrders,
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
@ -976,13 +883,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
(total, o) => o.makerAssetAmount.plus(total),
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketBuyOrders(
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketBuyOrders(orders, makerAssetFillAmount, signatures);
|
||||
expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketBuyOrders,
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
@ -1001,13 +904,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
(total, o) => o.makerAssetAmount.plus(total),
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketBuyOrders(
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketBuyOrders(orders, makerAssetFillAmount, signatures);
|
||||
expect(expectedCalls.length).to.eq(0);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketBuyOrders,
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
@ -1027,14 +926,10 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
(total, o) => o.makerAssetAmount.plus(total),
|
||||
constants.ZERO_AMOUNT,
|
||||
);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketBuyOrders(
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketBuyOrders(orders, makerAssetFillAmount, signatures);
|
||||
// It should stop filling after the penultimate order.
|
||||
expect(expectedCalls.length).to.eq(COUNT - 1);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketBuyOrders,
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
@ -1057,14 +952,10 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
// setting the first order's `makerAssetAmount` to larger than
|
||||
// `makerAssetFillAmount` will cause an overfill.
|
||||
orders[0].makerAssetAmount = makerAssetFillAmount.plus(1);
|
||||
const [ expectedResult, expectedCalls ] = simulateMarketBuyOrders(
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
signatures,
|
||||
);
|
||||
const [expectedResult, expectedCalls] = simulateMarketBuyOrders(orders, makerAssetFillAmount, signatures);
|
||||
// It should stop filling after first order.
|
||||
expect(expectedCalls.length).to.eq(1);
|
||||
const [ actualResult, receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketBuyOrders,
|
||||
orders,
|
||||
makerAssetFillAmount,
|
||||
@ -1075,7 +966,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
});
|
||||
|
||||
it('reverts when an overflow occurs when computing `remainingTakerAssetFillAmount`', async () => {
|
||||
const orders = [ randomOrder({ takerAssetAmount: MAX_UINT256 }) ];
|
||||
const orders = [randomOrder({ takerAssetAmount: MAX_UINT256 })];
|
||||
const signatures = _.times(orders.length, i => createOrderSignature(orders[i]));
|
||||
const makerAssetFillAmount = new BigNumber(2);
|
||||
const expectedError = new SafeMathRevertErrors.SafeMathError(
|
||||
@ -1092,8 +983,8 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
it('reverts when an order\'s `makerAssetAmount` is zero', async () => {
|
||||
const orders = [ randomOrder({ makerAssetAmount: constants.ZERO_AMOUNT }) ];
|
||||
it("reverts when an order's `makerAssetAmount` is zero", async () => {
|
||||
const orders = [randomOrder({ makerAssetAmount: constants.ZERO_AMOUNT })];
|
||||
const signatures = _.times(orders.length, i => createOrderSignature(orders[i]));
|
||||
const makerAssetFillAmount = ONE_ETHER;
|
||||
const expectedError = new SafeMathRevertErrors.SafeMathError(
|
||||
@ -1139,12 +1030,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
|
||||
it('reverts with no orders', async () => {
|
||||
const expectedError = new AnyRevertError(); // Just a generic revert.
|
||||
const tx = txHelper.getResultAndReceiptAsync(
|
||||
testContract.marketBuyOrders,
|
||||
[],
|
||||
constants.ZERO_AMOUNT,
|
||||
[],
|
||||
);
|
||||
const tx = txHelper.getResultAndReceiptAsync(testContract.marketBuyOrders, [], constants.ZERO_AMOUNT, []);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
});
|
||||
@ -1152,13 +1038,10 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
describe('batchCancelOrders', () => {
|
||||
// Asserts that `_cancelOrder()` was called in the same order and with the same
|
||||
// arguments as given by examining receipt logs.
|
||||
function assertCancelOrderCallsFromLogs(
|
||||
logs: LogEntry[],
|
||||
calls: Order[],
|
||||
): void {
|
||||
function assertCancelOrderCallsFromLogs(logs: LogEntry[], calls: Order[]): void {
|
||||
expect(logs.length).to.eq(calls.length);
|
||||
for (const i of _.times(calls.length)) {
|
||||
const log = logs[i] as LogWithDecodedArgs<CancelOrderCalledEventArgs>;
|
||||
const log = (logs[i] as any) as LogWithDecodedArgs<CancelOrderCalledEventArgs>;
|
||||
const expectedOrder = calls[i];
|
||||
expect(log.event).to.eq('CancelOrderCalled');
|
||||
assertSameOrderFromEvent(log.args.order as any, expectedOrder);
|
||||
@ -1166,20 +1049,14 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
}
|
||||
|
||||
it('works with no orders', async () => {
|
||||
const [ , receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchCancelOrders,
|
||||
[],
|
||||
);
|
||||
const [, receipt] = await txHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, []);
|
||||
assertCancelOrderCallsFromLogs(receipt.logs, []);
|
||||
});
|
||||
|
||||
it('works with many orders', async () => {
|
||||
const COUNT = 8;
|
||||
const orders = _.times(COUNT, () => randomOrder({ makerAddress: senderAddress }));
|
||||
const [ , receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchCancelOrders,
|
||||
orders,
|
||||
);
|
||||
const [, receipt] = await txHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders);
|
||||
assertCancelOrderCallsFromLogs(receipt.logs, orders);
|
||||
});
|
||||
|
||||
@ -1188,10 +1065,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const COUNT = 6;
|
||||
const uniqueOrders = _.times(UNIQUE_ORDERS, () => randomOrder({ makerAddress: senderAddress }));
|
||||
const orders = _.shuffle(_.flatten(_.times(COUNT / UNIQUE_ORDERS, () => uniqueOrders)));
|
||||
const [ , receipt ] = await txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchCancelOrders,
|
||||
orders,
|
||||
);
|
||||
const [, receipt] = await txHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders);
|
||||
assertCancelOrderCallsFromLogs(receipt.logs, orders);
|
||||
});
|
||||
|
||||
@ -1202,10 +1076,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
const failingOrder = orders[FAILING_ORDER_INDEX];
|
||||
failingOrder.salt = ALWAYS_FAILING_SALT;
|
||||
const expectedError = ALWAYS_FAILING_SALT_REVERT_ERROR;
|
||||
const tx = txHelper.getResultAndReceiptAsync(
|
||||
testContract.batchCancelOrders,
|
||||
orders,
|
||||
);
|
||||
const tx = txHelper.getResultAndReceiptAsync(testContract.batchCancelOrders, orders);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
});
|
||||
@ -1213,14 +1084,14 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
describe('getOrdersInfo', () => {
|
||||
// Computes the expected (fake) order info generated by the `TestWrapperFunctions` contract.
|
||||
function getExpectedOrderInfo(order: Order): OrderInfo {
|
||||
const MAX_ORDER_STATUS = OrderStatus.Cancelled;
|
||||
const MAX_ORDER_STATUS = OrderStatus.Cancelled as number;
|
||||
return {
|
||||
orderHash: getExpectedOrderHash(order),
|
||||
// Lower uint128 of `order.salt` is the `orderTakerAssetFilledAmount`.
|
||||
orderTakerAssetFilledAmount: order.salt.mod(new BigNumber(2).pow(128)),
|
||||
// High byte of `order.salt` is the `orderStatus`.
|
||||
orderStatus: order.salt.dividedToIntegerBy(
|
||||
new BigNumber(2).pow(248)).toNumber() % (MAX_ORDER_STATUS + 1),
|
||||
orderStatus:
|
||||
order.salt.dividedToIntegerBy(new BigNumber(2).pow(248)).toNumber() % (MAX_ORDER_STATUS + 1),
|
||||
};
|
||||
}
|
||||
|
||||
@ -1230,7 +1101,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => {
|
||||
});
|
||||
|
||||
it('works with one order', async () => {
|
||||
const orders = [ randomOrder() ];
|
||||
const orders = [randomOrder()];
|
||||
const expectedResult = orders.map(getExpectedOrderInfo);
|
||||
const actualResult = await testContract.getOrdersInfo.callAsync(orders);
|
||||
expect(actualResult).to.deep.eq(expectedResult);
|
||||
|
Loading…
x
Reference in New Issue
Block a user