aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--contracts/libs/contracts/test/TestLibs/TestLibs.sol26
-rw-r--r--contracts/protocol/test/exchange/fill_order.ts2
-rw-r--r--contracts/protocol/test/exchange/internal.ts2
-rw-r--r--contracts/protocol/test/utils/exchange_wrapper.ts16
-rw-r--r--contracts/protocol/test/utils/fill_order_combinatorial_utils.ts7
5 files changed, 46 insertions, 7 deletions
diff --git a/contracts/libs/contracts/test/TestLibs/TestLibs.sol b/contracts/libs/contracts/test/TestLibs/TestLibs.sol
index bd5f9f9da..7a090adfb 100644
--- a/contracts/libs/contracts/test/TestLibs/TestLibs.sol
+++ b/contracts/libs/contracts/test/TestLibs/TestLibs.sol
@@ -48,6 +48,32 @@ contract TestLibs is
return fillOrderCalldata;
}
+ function publicAbiDecodeFillOrder(
+ bytes memory fillOrderCalldata
+ )
+ public
+ pure
+ returns (
+ Order memory order,
+ uint256 takerAssetFillAmount,
+ bytes memory signature
+ )
+ {
+ (
+ order,
+ takerAssetFillAmount,
+ signature
+ ) = abi.decode(
+ fillOrderCalldata,
+ "((address,address,address,address,uint256,uint256,uint256,uint256,uint256,uint256,bytes,bytes),uint256,bytes)"
+ );
+ return (
+ order,
+ takerAssetFillAmount,
+ signature
+ );
+ }
+
function publicGetPartialAmountFloor(
uint256 numerator,
uint256 denominator,
diff --git a/contracts/protocol/test/exchange/fill_order.ts b/contracts/protocol/test/exchange/fill_order.ts
index 82f1dd9bf..2bdbe4855 100644
--- a/contracts/protocol/test/exchange/fill_order.ts
+++ b/contracts/protocol/test/exchange/fill_order.ts
@@ -51,7 +51,7 @@ const defaultFillScenario = {
},
};
-describe.skip('FillOrder Tests', () => {
+describe('FillOrder Tests', () => {
let fillOrderCombinatorialUtils: FillOrderCombinatorialUtils;
before(async () => {
diff --git a/contracts/protocol/test/exchange/internal.ts b/contracts/protocol/test/exchange/internal.ts
index ffe1f8a55..c65c477b2 100644
--- a/contracts/protocol/test/exchange/internal.ts
+++ b/contracts/protocol/test/exchange/internal.ts
@@ -50,7 +50,7 @@ const emptySignedOrder: SignedOrder = {
const overflowErrorForCall = new Error(RevertReason.Uint256Overflow);
-describe.skip('Exchange core internal functions', () => {
+describe('Exchange core internal functions', () => {
let testExchange: TestExchangeInternalsContract;
let overflowErrorForSendTransaction: Error | undefined;
let divisionByZeroErrorForCall: Error | undefined;
diff --git a/contracts/protocol/test/utils/exchange_wrapper.ts b/contracts/protocol/test/utils/exchange_wrapper.ts
index cb6dce901..28532f44b 100644
--- a/contracts/protocol/test/utils/exchange_wrapper.ts
+++ b/contracts/protocol/test/utils/exchange_wrapper.ts
@@ -7,10 +7,12 @@ import {
SignedTransaction,
} from '@0x/contracts-test-utils';
import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
-import { SignedOrder } from '@0x/types';
+import { OrderWithoutExchangeAddress, SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
-import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
+import { AbiDefinition, MethodAbi ,Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
+import * as _ from 'lodash';
+import { AbiEncoder } from '@0x/utils';
import { ExchangeContract } from '../../generated-wrappers/exchange';
import { artifacts } from '../../src/artifacts';
@@ -275,6 +277,16 @@ export class ExchangeWrapper {
);
return data;
}
+ // @hysz -- TEMPORARY HACK @TODO remove
+ public abiDecodeFillOrder(data: string): {order: OrderWithoutExchangeAddress, takerAssetFillAmount: BigNumber, signature: string} {
+ let fillOrderAbi = _.find(this._exchange.abi, (value: AbiDefinition) => {
+ if ((value.type === 'function') && (value as MethodAbi).name === 'fillOrder') {
+ return true;
+ }
+ return false;
+ }) as MethodAbi;
+ return (new AbiEncoder.Method(fillOrderAbi)).decode(data) as {order: OrderWithoutExchangeAddress, takerAssetFillAmount: BigNumber, signature: string};
+ }
public getExchangeAddress(): string {
return this._exchange.address;
}
diff --git a/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts b/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts
index 5d0ea07a8..df38bd59c 100644
--- a/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts
+++ b/contracts/protocol/test/utils/fill_order_combinatorial_utils.ts
@@ -42,6 +42,7 @@ import { ExchangeWrapper } from './exchange_wrapper';
import { OrderFactoryFromScenario } from './order_factory_from_scenario';
import { SimpleAssetBalanceAndProxyAllowanceFetcher } from './simple_asset_balance_and_proxy_allowance_fetcher';
import { SimpleOrderFilledCancelledFetcher } from './simple_order_filled_cancelled_fetcher';
+import { Method } from '@0x/utils/lib/src/abi_encoder';
chaiSetup.configure();
const expect = chai.expect;
@@ -613,13 +614,13 @@ export class FillOrderCombinatorialUtils {
takerAssetFillAmount: BigNumber,
): Promise<void> {
const params = orderUtils.createFill(signedOrder, takerAssetFillAmount);
- const expectedAbiEncodedData = this.exchangeWrapper.abiEncodeFillOrder(signedOrder, { takerAssetFillAmount });
- const libsAbiEncodedData = await this.testLibsContract.publicAbiEncodeFillOrder.callAsync(
+ const abiDataEncodedByContract = await this.testLibsContract.publicAbiEncodeFillOrder.callAsync(
params.order,
params.takerAssetFillAmount,
params.signature,
);
- expect(libsAbiEncodedData).to.be.equal(expectedAbiEncodedData, 'ABIEncodedFillOrderData');
+ const paramsDecodeddByClient = this.exchangeWrapper.abiDecodeFillOrder(abiDataEncodedByContract);
+ expect(paramsDecodeddByClient).to.be.deep.equal(params, 'ABIEncodedFillOrderData');
}
private async _getTakerAssetFillAmountAsync(
signedOrder: SignedOrder,