Minor fixes to order matching fuzz code
This commit is contained in:
@@ -99,7 +99,7 @@ export function MakerMixin<TBase extends Constructor>(Base: TBase): TBase & Cons
|
||||
);
|
||||
|
||||
// Maker and taker set balances/allowances to guarantee that the fill succeeds.
|
||||
// Amounts are chosen to be within each actor's balance (divided by 2, in case
|
||||
// Amounts are chosen to be within each actor's balance (divided by 8, in case
|
||||
// e.g. makerAsset = makerFeeAsset)
|
||||
const [makerAssetAmount, makerFee, takerAssetAmount, takerFee] = await Promise.all(
|
||||
[
|
||||
|
||||
@@ -79,7 +79,6 @@ export function TakerMixin<TBase extends Constructor>(Base: TBase): TBase & Cons
|
||||
.matchOrders(leftOrder, rightOrder, leftOrder.signature, rightOrder.signature)
|
||||
.awaitTransactionSuccessAsync({
|
||||
from: this.actor.address,
|
||||
gasPrice: DeploymentManager.gasPrice,
|
||||
value: DeploymentManager.protocolFee,
|
||||
...txData,
|
||||
});
|
||||
@@ -97,7 +96,6 @@ export function TakerMixin<TBase extends Constructor>(Base: TBase): TBase & Cons
|
||||
.matchOrdersWithMaximalFill(leftOrder, rightOrder, leftOrder.signature, rightOrder.signature)
|
||||
.awaitTransactionSuccessAsync({
|
||||
from: this.actor.address,
|
||||
gasPrice: DeploymentManager.gasPrice,
|
||||
value: DeploymentManager.protocolFee,
|
||||
...txData,
|
||||
});
|
||||
|
||||
@@ -3,7 +3,6 @@ import { TxData } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { Maker } from '../actors/maker';
|
||||
import { filterActorsByRole } from '../actors/utils';
|
||||
import { DeploymentManager } from '../deployment_manager';
|
||||
import { SimulationEnvironment } from '../simulation';
|
||||
import { assertProtocolFeePaidAsync, getPoolInfoAsync, PoolInfo } from '../utils/assert_protocol_fee';
|
||||
@@ -11,7 +10,7 @@ import { verifyMatchEvents } from '../utils/verify_match_events';
|
||||
|
||||
import { FunctionAssertion, FunctionResult } from './function_assertion';
|
||||
|
||||
export const matchOrderRuntimeAssertion = (
|
||||
export const matchOrdersRuntimeAssertion = (
|
||||
deployment: DeploymentManager,
|
||||
simulationEnvironment: SimulationEnvironment,
|
||||
withMaximalFill: boolean,
|
||||
@@ -22,9 +21,9 @@ export const matchOrderRuntimeAssertion = (
|
||||
return {
|
||||
before: async (args: [Order, Order, string, string]) => {
|
||||
const [order] = args;
|
||||
const maker = filterActorsByRole(actors, Maker).find(actor => actor.address === order.makerAddress);
|
||||
// tslint:disable-next-line no-non-null-assertion
|
||||
const poolInfo = getPoolInfoAsync(maker!, simulationEnvironment, deployment);
|
||||
// tslint:disable-next-line no-unnecessary-type-assertion
|
||||
const maker = actors.find(actor => actor.address === order.makerAddress) as Maker;
|
||||
const poolInfo = getPoolInfoAsync(maker, simulationEnvironment, deployment);
|
||||
return poolInfo;
|
||||
},
|
||||
after: async (
|
||||
@@ -72,7 +71,7 @@ export function validMatchOrdersAssertion(
|
||||
return new FunctionAssertion<[Order, Order, string, string], PoolInfo | void, MatchedFillResults>(
|
||||
deployment.exchange,
|
||||
'matchOrders',
|
||||
matchOrderRuntimeAssertion(deployment, simulationEnvironment, false),
|
||||
matchOrdersRuntimeAssertion(deployment, simulationEnvironment, false),
|
||||
);
|
||||
}
|
||||
/* tslint:enable:no-non-null-assertion */
|
||||
|
||||
@@ -6,7 +6,7 @@ import { SimulationEnvironment } from '../simulation';
|
||||
import { PoolInfo } from '../utils/assert_protocol_fee';
|
||||
|
||||
import { FunctionAssertion } from './function_assertion';
|
||||
import { matchOrderRuntimeAssertion } from './matchOrders';
|
||||
import { matchOrdersRuntimeAssertion } from './matchOrders';
|
||||
|
||||
/**
|
||||
* A function assertion that verifies that a complete and valid `matchOrdersWithMaximalFill` succeeded and emitted the correct logs.
|
||||
@@ -20,7 +20,7 @@ export function validMatchOrdersWithMaximalFillAssertion(
|
||||
return new FunctionAssertion<[Order, Order, string, string], PoolInfo | void, MatchedFillResults>(
|
||||
deployment.exchange,
|
||||
'matchOrdersWithMaximalFill',
|
||||
matchOrderRuntimeAssertion(deployment, simulationEnvironment, true),
|
||||
matchOrdersRuntimeAssertion(deployment, simulationEnvironment, true),
|
||||
);
|
||||
}
|
||||
/* tslint:enable:no-non-null-assertion */
|
||||
|
||||
@@ -34,7 +34,7 @@ export async function getPoolInfoAsync(
|
||||
): Promise<PoolInfo | undefined> {
|
||||
const { stakingWrapper } = deployment.staking;
|
||||
// tslint:disable-next-line no-non-null-assertion no-unnecessary-type-assertion
|
||||
const poolId = maker!.makerPoolId;
|
||||
const poolId = maker.makerPoolId;
|
||||
const { currentEpoch } = simulationEnvironment;
|
||||
if (poolId === undefined) {
|
||||
return;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ERC20TokenEvents, ERC20TokenTransferEventArgs } from '@0x/contracts-erc20';
|
||||
import { ExchangeEvents, ExchangeFillEventArgs } from '@0x/contracts-exchange';
|
||||
import { ReferenceFunctions } from '@0x/contracts-exchange-libs';
|
||||
import { orderHashUtils, verifyEvents } from '@0x/contracts-test-utils';
|
||||
import { constants, orderHashUtils, verifyEvents } from '@0x/contracts-test-utils';
|
||||
import { MatchedFillResults, Order } from '@0x/types';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { TransactionReceiptWithDecodedLogs, TxData } from 'ethereum-types';
|
||||
@@ -122,7 +122,7 @@ const verifyMatchTransferEvents = (
|
||||
_to: deployment.staking.stakingProxy.address,
|
||||
_value: value.isLessThan(DeploymentManager.protocolFee.times(2))
|
||||
? DeploymentManager.protocolFee
|
||||
: new BigNumber(0),
|
||||
: constants.ZERO_AMOUNT,
|
||||
},
|
||||
{
|
||||
_from: takerAddress,
|
||||
@@ -134,7 +134,7 @@ const verifyMatchTransferEvents = (
|
||||
_to: rightOrder.feeRecipientAddress,
|
||||
_value:
|
||||
leftOrder.feeRecipientAddress === rightOrder.feeRecipientAddress
|
||||
? new BigNumber(0)
|
||||
? constants.ZERO_AMOUNT
|
||||
: matchResults.right.takerFeePaid,
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user