Ran prettier

This commit is contained in:
Lawrence Forman 2019-08-16 17:40:48 -04:00
parent a2613625c6
commit fb38867e78
4 changed files with 44 additions and 91 deletions

View File

@ -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,

View File

@ -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)),

View File

@ -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,
});
}
}

View File

@ -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();