From fb38867e788fefe652e5c32b3c23c33fa481dee4 Mon Sep 17 00:00:00 2001 From: Lawrence Forman Date: Fri, 16 Aug 2019 17:40:48 -0400 Subject: [PATCH] Ran prettier --- .../dev-utils/test/lib_transaction_decoder.ts | 10 +- contracts/exchange/test/wrapper_unit_tests.ts | 98 +++++-------------- .../order-utils/src/exchange_revert_errors.ts | 9 +- packages/utils/test/revert_error_test.ts | 18 ++-- 4 files changed, 44 insertions(+), 91 deletions(-) diff --git a/contracts/dev-utils/test/lib_transaction_decoder.ts b/contracts/dev-utils/test/lib_transaction_decoder.ts index bc308021e5..0b3d24ec57 100644 --- a/contracts/dev-utils/test/lib_transaction_decoder.ts +++ b/contracts/dev-utils/test/lib_transaction_decoder.ts @@ -99,11 +99,11 @@ describe('LibTransactionDecoder', () => { } for (const func of [ - 'marketBuyOrdersNoThrow', - 'marketSellOrdersNoThrow', - 'marketBuyOrdersFillOrKill', - 'marketSellOrdersFillOrKill', - ]) { + 'marketBuyOrdersNoThrow', + 'marketSellOrdersNoThrow', + 'marketBuyOrdersFillOrKill', + 'marketSellOrdersFillOrKill', + ]) { const input = (exchangeInterface as any)[func].getABIEncodedTransactionData( [order, order], takerAssetFillAmount, diff --git a/contracts/exchange/test/wrapper_unit_tests.ts b/contracts/exchange/test/wrapper_unit_tests.ts index d146f6956b..f060c14762 100644 --- a/contracts/exchange/test/wrapper_unit_tests.ts +++ b/contracts/exchange/test/wrapper_unit_tests.ts @@ -170,10 +170,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { takerAssetAmount: fillAmount.minus(1), }); const signature = createOrderSignature(order); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - fillAmount, - getExpectedOrderHash(order), - ); + const expectedError = new ExchangeRevertErrors.IncompleteFillError(fillAmount, getExpectedOrderHash(order)); const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(order, fillAmount, signature); return expect(tx).to.revertWith(expectedError); }); @@ -186,10 +183,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { takerAssetAmount: fillAmount.plus(1), }); const signature = createOrderSignature(order); - const expectedError = new ExchangeRevertErrors.IncompleteFillError( - fillAmount, - getExpectedOrderHash(order), - ); + const expectedError = new ExchangeRevertErrors.IncompleteFillError(fillAmount, getExpectedOrderHash(order)); const tx = testContract.fillOrKillOrder.awaitTransactionSuccessAsync(order, fillAmount, signature); return expect(tx).to.revertWith(expectedError); }); @@ -723,23 +717,13 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { orders[0].takerAssetAmount, orders[1].takerAssetAmount, ); - const tx = txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - takerAssetFillAmount, - signatures, - ); + const tx = txHelper.getResultAndReceiptAsync(getContractFn(), orders, takerAssetFillAmount, signatures); return expect(tx).to.revertWith(expectedError); }); it('reverts with no orders', async () => { const expectedError = new AnyRevertError(); // Just a generic revert. - const tx = txHelper.getResultAndReceiptAsync( - getContractFn(), - [], - constants.ZERO_AMOUNT, - [], - ); + const tx = txHelper.getResultAndReceiptAsync(getContractFn(), [], constants.ZERO_AMOUNT, []); return expect(tx).to.revertWith(expectedError); }); } @@ -783,7 +767,11 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { (total, o) => o.takerAssetAmount.plus(total), constants.ZERO_AMOUNT, ); - const [expectedResult, expectedCalls] = simulateMarketSellOrders(orders, takerAssetFillAmount, signatures); + const [expectedResult, expectedCalls] = simulateMarketSellOrders( + orders, + takerAssetFillAmount, + signatures, + ); expect(expectedCalls.length).to.eq(COUNT - BAD_ORDERS_COUNT); const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( testContract.marketSellOrdersNoThrow, @@ -804,7 +792,11 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { (total, o) => o.takerAssetAmount.plus(total), constants.ZERO_AMOUNT, ); - const [expectedResult, expectedCalls] = simulateMarketSellOrders(orders, takerAssetFillAmount, signatures); + const [expectedResult, expectedCalls] = simulateMarketSellOrders( + orders, + takerAssetFillAmount, + signatures, + ); expect(expectedCalls.length).to.eq(0); const [actualResult, receipt] = await txHelper.getResultAndReceiptAsync( testContract.marketSellOrdersNoThrow, @@ -855,13 +847,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { orders, (total, o) => o.takerAssetAmount.plus(total), constants.ZERO_AMOUNT, - ).minus( - _.reduce( - badOrders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ), - ); + ).minus(_.reduce(badOrders, (total, o) => o.takerAssetAmount.plus(total), constants.ZERO_AMOUNT)); const [expectedResult, expectedCalls] = simulateMarketSellOrders( orders, takerAssetFillAmount, @@ -891,13 +877,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { orders, (total, o) => o.takerAssetAmount.plus(total), constants.ZERO_AMOUNT, - ).minus( - _.reduce( - badOrders, - (total, o) => o.takerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ), - ).plus(1); + ) + .minus(_.reduce(badOrders, (total, o) => o.takerAssetAmount.plus(total), constants.ZERO_AMOUNT)) + .plus(1); const expectedError = new ExchangeRevertErrors.IncompleteMarketSellError( takerAssetFillAmount, orders.map(o => getExpectedOrderHash(o)), @@ -1041,12 +1023,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { orders[0].takerAssetAmount, makerAssetFillAmount, ); - const tx = txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); + const tx = txHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); return expect(tx).to.revertWith(expectedError); }); @@ -1059,12 +1036,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { orders[0].takerAssetAmount.times(makerAssetFillAmount), orders[0].makerAssetAmount, ); - const tx = txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); + const tx = txHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); return expect(tx).to.revertWith(expectedError); }); @@ -1086,12 +1058,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { orders[0].makerAssetAmount, orders[1].makerAssetAmount, ); - const tx = txHelper.getResultAndReceiptAsync( - getContractFn(), - orders, - makerAssetFillAmount, - signatures, - ); + const tx = txHelper.getResultAndReceiptAsync(getContractFn(), orders, makerAssetFillAmount, signatures); return expect(tx).to.revertWith(expectedError); }); @@ -1130,10 +1097,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { } describe('marketBuyOrdersNoThrow', () => { - defineCommonMarketBuyOrdersTests( - () => testContract.marketBuyOrdersNoThrow, - simulateMarketBuyOrdersNoThrow, - ); + defineCommonMarketBuyOrdersTests(() => testContract.marketBuyOrdersNoThrow, simulateMarketBuyOrdersNoThrow); it('works when any fills revert', async () => { const COUNT = 4; @@ -1232,13 +1196,7 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { orders, (total, o) => o.makerAssetAmount.plus(total), constants.ZERO_AMOUNT, - ).minus( - _.reduce( - badOrders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ), - ); + ).minus(_.reduce(badOrders, (total, o) => o.makerAssetAmount.plus(total), constants.ZERO_AMOUNT)); const [expectedResult, expectedCalls] = simulateMarketBuyOrdersNoThrow( orders, makerAssetFillAmount, @@ -1268,13 +1226,9 @@ blockchainTests('Exchange wrapper functions unit tests.', env => { orders, (total, o) => o.makerAssetAmount.plus(total), constants.ZERO_AMOUNT, - ).minus( - _.reduce( - badOrders, - (total, o) => o.makerAssetAmount.plus(total), - constants.ZERO_AMOUNT, - ), - ).plus(1); + ) + .minus(_.reduce(badOrders, (total, o) => o.makerAssetAmount.plus(total), constants.ZERO_AMOUNT)) + .plus(1); const expectedError = new ExchangeRevertErrors.IncompleteMarketBuyError( makerAssetFillAmount, orders.map(o => getExpectedOrderHash(o)), diff --git a/packages/order-utils/src/exchange_revert_errors.ts b/packages/order-utils/src/exchange_revert_errors.ts index cd9d57b530..57e09edacf 100644 --- a/packages/order-utils/src/exchange_revert_errors.ts +++ b/packages/order-utils/src/exchange_revert_errors.ts @@ -209,11 +209,10 @@ export class TransactionExecutionError extends RevertError { export class IncompleteFillError extends RevertError { constructor(takerAssetFillAmount?: BigNumber, orderHash?: string) { - super( - 'IncompleteFillError', - 'IncompleteFillError(uint256 takerAssetFillAmount, bytes32 orderHash)', - { takerAssetFillAmount, orderHash }, - ); + super('IncompleteFillError', 'IncompleteFillError(uint256 takerAssetFillAmount, bytes32 orderHash)', { + takerAssetFillAmount, + orderHash, + }); } } diff --git a/packages/utils/test/revert_error_test.ts b/packages/utils/test/revert_error_test.ts index bd6a400432..d9dd9f001d 100644 --- a/packages/utils/test/revert_error_test.ts +++ b/packages/utils/test/revert_error_test.ts @@ -54,45 +54,45 @@ describe('RevertError', () => { expect(revert1.equals(revert2)).to.be.true(); }); it('should equate two revert errors with identical array fields', () => { - const strings = [ 'foo', 'bar' ]; + const strings = ['foo', 'bar']; const revert1 = new ArrayRevertError(strings); const revert2 = new ArrayRevertError(strings); expect(revert1.equals(revert2)).to.be.true(); }); it('should not equate two revert errors with different sized array fields', () => { - const strings = [ 'foo', 'bar' ]; + const strings = ['foo', 'bar']; const revert1 = new ArrayRevertError(strings); const revert2 = new ArrayRevertError(strings.slice(0, 1)); expect(revert1.equals(revert2)).to.be.false(); }); it('should not equate two revert errors with different array field values', () => { - const strings1 = [ 'foo', 'bar' ]; - const strings2 = [ 'foo', 'baz' ]; + const strings1 = ['foo', 'bar']; + const strings2 = ['foo', 'baz']; const revert1 = new ArrayRevertError(strings1); const revert2 = new ArrayRevertError(strings2); expect(revert1.equals(revert2)).to.be.false(); }); it('should equate two revert errors with identical fixed-size array fields', () => { - const strings = [ 'foo', 'bar' ]; + const strings = ['foo', 'bar']; const revert1 = new FixedSizeArrayRevertError(strings); const revert2 = new FixedSizeArrayRevertError(strings); expect(revert1.equals(revert2)).to.be.true(); }); it('should not equate two revert errors with different sized fixed-size array fields', () => { - const strings = [ 'foo', 'bar' ]; + const strings = ['foo', 'bar']; const revert1 = new FixedSizeArrayRevertError(strings); const revert2 = new FixedSizeArrayRevertError(strings.slice(0, 1)); expect(revert1.equals(revert2)).to.be.false(); }); it('should not equate two revert errors with the wrong sized fixed-size array fields', () => { - const strings = [ 'foo', 'bar', 'baz' ]; + const strings = ['foo', 'bar', 'baz']; const revert1 = new FixedSizeArrayRevertError(strings); const revert2 = new FixedSizeArrayRevertError(strings); expect(revert1.equals(revert2)).to.be.false(); }); it('should not equate two revert errors with different fixed-size array field values', () => { - const strings1 = [ 'foo', 'bar' ]; - const strings2 = [ 'foo', 'baz' ]; + const strings1 = ['foo', 'bar']; + const strings2 = ['foo', 'baz']; const revert1 = new FixedSizeArrayRevertError(strings1); const revert2 = new FixedSizeArrayRevertError(strings2); expect(revert1.equals(revert2)).to.be.false();