All contract tests working with new abi encoder
This commit is contained in:
@@ -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,
|
||||
|
@@ -51,7 +51,7 @@ const defaultFillScenario = {
|
||||
},
|
||||
};
|
||||
|
||||
describe.skip('FillOrder Tests', () => {
|
||||
describe('FillOrder Tests', () => {
|
||||
let fillOrderCombinatorialUtils: FillOrderCombinatorialUtils;
|
||||
|
||||
before(async () => {
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user