From f9814b09aea42062bbecb578688ecc61a01c9e34 Mon Sep 17 00:00:00 2001 From: Lawrence Forman Date: Thu, 8 Aug 2019 03:18:32 -0400 Subject: [PATCH] `@0x/contracts-dev-utils`: Prettier. `@0x/contracts-exchange`: Update reentrancy tests. `@0x/contracts-exchange`: Add all mutator functions to `ExchangeFunctions` type. `@0x/contracts-tes-utils`: Remove unused import. --- .../dev-utils/test/lib_transaction_decoder.ts | 2 +- contracts/exchange/test/reentrancy_tests.ts | 2 +- contracts/exchange/test/utils/constants.ts | 10 ++++----- contracts/exchange/test/utils/types.ts | 22 +++++++++++++------ contracts/test-utils/src/log_decoder.ts | 2 -- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/contracts/dev-utils/test/lib_transaction_decoder.ts b/contracts/dev-utils/test/lib_transaction_decoder.ts index fff118b383..efa8dd8593 100644 --- a/contracts/dev-utils/test/lib_transaction_decoder.ts +++ b/contracts/dev-utils/test/lib_transaction_decoder.ts @@ -97,7 +97,7 @@ describe('LibTransactionDecoder', () => { }); } - for (const func of ['marketBuyOrders', 'marketSellOrders', ]) { + for (const func of ['marketBuyOrders', 'marketSellOrders']) { const input = (exchangeInterface as any)[func].getABIEncodedTransactionData( [order, order], takerAssetFillAmount, diff --git a/contracts/exchange/test/reentrancy_tests.ts b/contracts/exchange/test/reentrancy_tests.ts index 760e7963ca..69e05bf822 100644 --- a/contracts/exchange/test/reentrancy_tests.ts +++ b/contracts/exchange/test/reentrancy_tests.ts @@ -19,7 +19,7 @@ blockchainTests.resets('Reentrancy Tests', env => { !method.constant && !_.includes(['view', 'pure'], method.stateMutability) ) { - if (_.includes(TestConstants.REENTRANT_FUNCTIONS, method.name)) { + if (_.includes(TestConstants.REENTRANT_FUNCTIONS as string[], method.name)) { reentrantFunctions.push(method); } else { nonReentrantFunctions.push(method); diff --git a/contracts/exchange/test/utils/constants.ts b/contracts/exchange/test/utils/constants.ts index 775059527a..35800f28ab 100644 --- a/contracts/exchange/test/utils/constants.ts +++ b/contracts/exchange/test/utils/constants.ts @@ -4,11 +4,11 @@ export const constants = { // These are functions not secured by the `nonReentrant`, directly or // indirectly (by calling a function that has the modifier). REENTRANT_FUNCTIONS: [ - 'batchExecuteTransactions', - 'executeTransaction', - 'registerAssetProxy', - 'simulateDispatchTransferFromCalls', - 'transferOwnership', + ExchangeFunctionName.BatchExecuteTransactions, + ExchangeFunctionName.ExecuteTransaction, + ExchangeFunctionName.RegisterAssetProxy, + ExchangeFunctionName.SimulateDispatchTransferFromCalls, + ExchangeFunctionName.TransferOwnership, ], SINGLE_FILL_FN_NAMES: [ ExchangeFunctionName.FillOrder, diff --git a/contracts/exchange/test/utils/types.ts b/contracts/exchange/test/utils/types.ts index 56d870049d..48cfcffed6 100644 --- a/contracts/exchange/test/utils/types.ts +++ b/contracts/exchange/test/utils/types.ts @@ -8,18 +8,26 @@ export interface AbiDecodedFillOrderData { } export enum ExchangeFunctionName { - FillOrder = 'fillOrder', - FillOrKillOrder = 'fillOrKillOrder', - FillOrderNoThrow = 'fillOrderNoThrow', - BatchFillOrders = 'batchFillOrders', + BatchCancelOrders = 'batchCancelOrders', + BatchExecuteTransactions = 'batchExecuteTransactions', BatchFillOrKillOrders = 'batchFillOrKillOrders', + BatchFillOrders = 'batchFillOrders', BatchFillOrdersNoThrow = 'batchFillOrdersNoThrow', + BatchMatchOrders = 'batchMatchOrders', + BatchMatchordersWithMaximalFill = 'batchMatchOrdersWithMaximalFill', + CancelOrder = 'cancelOrder', + CancelOrdersUpTo = 'cancelOrdersUpTo', + ExecuteTransaction = 'executeTransaction', + FillOrKillOrder = 'fillOrKillOrder', + FillOrder = 'fillOrder', + FillOrderNoThrow = 'fillOrderNoThrow', MarketBuyOrders = 'marketBuyOrders', MarketSellOrders = 'marketSellOrders', MatchOrders = 'matchOrders', - CancelOrder = 'cancelOrder', - BatchCancelOrders = 'batchCancelOrders', - CancelOrdersUpTo = 'cancelOrdersUpTo', + MatchOrdersWithMaximalfill = 'matchOrdersWithMaximalFill', PreSign = 'preSign', + RegisterAssetProxy = 'registerAssetProxy', SetSignatureValidatorApproval = 'setSignatureValidatorApproval', + SimulateDispatchTransferFromCalls = 'simulateDispatchTransferFromCalls', + TransferOwnership = 'transferOwnership', } diff --git a/contracts/test-utils/src/log_decoder.ts b/contracts/test-utils/src/log_decoder.ts index db1c91424a..07a19c48ba 100644 --- a/contracts/test-utils/src/log_decoder.ts +++ b/contracts/test-utils/src/log_decoder.ts @@ -12,8 +12,6 @@ import { } from 'ethereum-types'; import * as _ from 'lodash'; -import { constants } from './constants'; - export class LogDecoder { private readonly _web3Wrapper: Web3Wrapper; private readonly _abiDecoder: AbiDecoder;