From d3ab2b077a996a14f5d1cc3a728ef1869e9689e5 Mon Sep 17 00:00:00 2001 From: Amir Bandeali Date: Mon, 5 Aug 2019 10:12:39 -0700 Subject: [PATCH] Remove cancelOrderNoThrow tests --- .../contracts/src/MixinExchangeCore.sol | 2 +- .../exchange/test/utils/exchange_wrapper.ts | 17 --- contracts/exchange/test/wrapper.ts | 105 ------------------ 3 files changed, 1 insertion(+), 123 deletions(-) diff --git a/contracts/exchange/contracts/src/MixinExchangeCore.sol b/contracts/exchange/contracts/src/MixinExchangeCore.sol index 298a27dc6b..656b31806f 100644 --- a/contracts/exchange/contracts/src/MixinExchangeCore.sol +++ b/contracts/exchange/contracts/src/MixinExchangeCore.sol @@ -257,7 +257,7 @@ contract MixinExchangeCore is _assertValidCancel(order, orderInfo); // Noop if order is already unfillable - if (orderInfo.orderStatus != OrderStatus.FILLABLE) { + if (orderInfo.orderStatus != uint8(OrderStatus.FILLABLE)) { return; } diff --git a/contracts/exchange/test/utils/exchange_wrapper.ts b/contracts/exchange/test/utils/exchange_wrapper.ts index 1fe35b3cd9..fc07fc1534 100644 --- a/contracts/exchange/test/utils/exchange_wrapper.ts +++ b/contracts/exchange/test/utils/exchange_wrapper.ts @@ -56,15 +56,6 @@ export class ExchangeWrapper { const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); return tx; } - public async cancelOrderNoThrowAsync( - signedOrder: SignedOrder, - from: string, - ): Promise { - const params = orderUtils.createCancel(signedOrder); - const txHash = await this._exchange.cancelOrderNoThrow.sendTransactionAsync(params.order, { from }); - const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); - return tx; - } public async fillOrKillOrderAsync( signedOrder: SignedOrder, from: string, @@ -207,14 +198,6 @@ export class ExchangeWrapper { const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); return tx; } - public async batchCancelOrdersNoThrowAsync( - orders: SignedOrder[], - from: string, - ): Promise { - const txHash = await this._exchange.batchCancelOrdersNoThrow.sendTransactionAsync(orders, { from }); - const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); - return tx; - } public async cancelOrdersUpToAsync(salt: BigNumber, from: string): Promise { const txHash = await this._exchange.cancelOrdersUpTo.sendTransactionAsync(salt, { from }); const tx = await this._logDecoder.getTxWithDecodedLogsAsync(txHash); diff --git a/contracts/exchange/test/wrapper.ts b/contracts/exchange/test/wrapper.ts index 4d48862012..786e3aef87 100644 --- a/contracts/exchange/test/wrapper.ts +++ b/contracts/exchange/test/wrapper.ts @@ -19,13 +19,11 @@ import { OrderStatus, SignedOrder } from '@0x/types'; import { BigNumber, providerUtils, ReentrancyGuardRevertErrors } from '@0x/utils'; import { Web3Wrapper } from '@0x/web3-wrapper'; import * as chai from 'chai'; -import { LogWithDecodedArgs } from 'ethereum-types'; import * as _ from 'lodash'; import { artifacts, constants as exchangeConstants, - ExchangeCancelEventArgs, ExchangeContract, ExchangeWrapper, ReentrantERC20TokenContract, @@ -551,88 +549,6 @@ describe('Exchange wrappers', () => { }); }); - describe('cancelOrderNoThrow', () => { - it('should return false if not sent by maker', async () => { - const signedOrder = await orderFactory.newSignedOrderAsync(); - const orderHash = orderHashUtils.getOrderHashHex(signedOrder); - const didCancel = await exchange.cancelOrderNoThrow.callAsync(signedOrder, { from: takerAddress }); - const isCancelled = await exchange.cancelled.callAsync(orderHash); - expect(didCancel).to.equal(false); - expect(isCancelled).to.equal(false); - }); - - it('should return false if makerAssetAmount is 0', async () => { - const signedOrder = await orderFactory.newSignedOrderAsync({ - makerAssetAmount: new BigNumber(0), - }); - const orderHash = orderHashUtils.getOrderHashHex(signedOrder); - const didCancel = await exchange.cancelOrderNoThrow.callAsync(signedOrder, { from: makerAddress }); - const isCancelled = await exchange.cancelled.callAsync(orderHash); - expect(didCancel).to.equal(false); - expect(isCancelled).to.equal(false); - }); - - it('should return false if takerAssetAmount is 0', async () => { - const signedOrder = await orderFactory.newSignedOrderAsync({ - takerAssetAmount: new BigNumber(0), - }); - const orderHash = orderHashUtils.getOrderHashHex(signedOrder); - const didCancel = await exchange.cancelOrderNoThrow.callAsync(signedOrder, { from: makerAddress }); - const isCancelled = await exchange.cancelled.callAsync(orderHash); - expect(didCancel).to.equal(false); - expect(isCancelled).to.equal(false); - }); - - it('should be able to cancel an order', async () => { - const signedOrder = await orderFactory.newSignedOrderAsync(); - await exchangeWrapper.cancelOrderNoThrowAsync(signedOrder, makerAddress); - const orderHash = orderHashUtils.getOrderHashHex(signedOrder); - const expectedError = new ExchangeRevertErrors.OrderStatusError(orderHash, OrderStatus.Cancelled); - const tx = exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { - takerAssetFillAmount: signedOrder.takerAssetAmount.div(2), - }); - return expect(tx).to.revertWith(expectedError); - }); - - it('should log 1 event with correct arguments if successful', async () => { - const signedOrder = await orderFactory.newSignedOrderAsync(); - const res = await exchangeWrapper.cancelOrderNoThrowAsync(signedOrder, makerAddress); - expect(res.logs).to.have.length(1); - - const log = res.logs[0] as LogWithDecodedArgs; - const logArgs = log.args; - - expect(signedOrder.makerAddress).to.be.equal(logArgs.makerAddress); - expect(signedOrder.makerAddress).to.be.equal(logArgs.senderAddress); - expect(signedOrder.feeRecipientAddress).to.be.equal(logArgs.feeRecipientAddress); - expect(signedOrder.makerAssetData).to.be.equal(logArgs.makerAssetData); - expect(signedOrder.takerAssetData).to.be.equal(logArgs.takerAssetData); - expect(orderHashUtils.getOrderHashHex(signedOrder)).to.be.equal(logArgs.orderHash); - }); - - it('should return false if already cancelled', async () => { - const signedOrder = await orderFactory.newSignedOrderAsync(); - const orderHash = orderHashUtils.getOrderHashHex(signedOrder); - await exchangeWrapper.cancelOrderAsync(signedOrder, makerAddress); - const isCancelled = await exchange.cancelled.callAsync(orderHash); - expect(isCancelled).to.equal(true); - const didCancel = await exchange.cancelOrderNoThrow.callAsync(signedOrder, { from: makerAddress }); - expect(didCancel).to.equal(false); - }); - - it('should return false if order is expired', async () => { - const currentTimestamp = await getLatestBlockTimestampAsync(); - const signedOrder = await orderFactory.newSignedOrderAsync({ - expirationTimeSeconds: new BigNumber(currentTimestamp).minus(10), - }); - const orderHash = orderHashUtils.getOrderHashHex(signedOrder); - const didCancel = await exchange.cancelOrderNoThrow.callAsync(signedOrder, { from: makerAddress }); - const isCancelled = await exchange.cancelled.callAsync(orderHash); - expect(didCancel).to.equal(false); - expect(isCancelled).to.equal(false); - }); - }); - describe('batch functions', () => { let signedOrders: SignedOrder[]; beforeEach(async () => { @@ -1775,27 +1691,6 @@ describe('Exchange wrappers', () => { }); }); - describe('batchCancelOrdersNoThrow', () => { - it('should be able to cancel multiple signedOrders', async () => { - const takerAssetCancelAmounts = _.map(signedOrders, signedOrder => signedOrder.takerAssetAmount); - await exchangeWrapper.batchCancelOrdersNoThrowAsync(signedOrders, makerAddress); - - await exchangeWrapper.batchFillOrdersNoThrowAsync(signedOrders, takerAddress, { - takerAssetFillAmounts: takerAssetCancelAmounts, - }); - const newBalances = await erc20Wrapper.getBalancesAsync(); - expect(erc20Balances).to.be.deep.equal(newBalances); - }); - it('should return false for cancelled orders', async () => { - await exchangeWrapper.cancelOrderAsync(signedOrders[1], makerAddress); - const didCancelArray = await exchange.batchCancelOrdersNoThrow.callAsync(signedOrders, { - from: makerAddress, - }); - expect(didCancelArray[0]).to.equal(true); - expect(didCancelArray[1]).to.equal(false); - }); - }); - describe('getOrdersInfo', () => { beforeEach(async () => { signedOrders = [