@0x/contracts-integrations: Fix broken tests.

This commit is contained in:
Lawrence Forman 2020-09-01 17:32:29 -04:00
parent 1cdc6e7184
commit d8844f6970
8 changed files with 39 additions and 21 deletions

View File

@ -558,7 +558,7 @@ blockchainTests.resets('Exchange core', () => {
const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( const expectedError = new ExchangeRevertErrors.AssetProxyTransferError(
orderHashHex, orderHashHex,
signedOrder.makerAssetData, signedOrder.makerAssetData,
new StringRevertError(RevertReason.TransferFailed).toString(), new StringRevertError(RevertReason.TransferFailed).encode(),
); );
const tx = exchange const tx = exchange
.fillOrder(signedOrder, takerAssetFillAmount, signedOrder.signature) .fillOrder(signedOrder, takerAssetFillAmount, signedOrder.signature)
@ -587,7 +587,7 @@ blockchainTests.resets('Exchange core', () => {
const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( const expectedError = new ExchangeRevertErrors.AssetProxyTransferError(
orderHashHex, orderHashHex,
signedOrder.takerAssetData, signedOrder.takerAssetData,
new StringRevertError(RevertReason.TransferFailed).toString(), new StringRevertError(RevertReason.TransferFailed).encode(),
); );
const tx = exchange const tx = exchange
.fillOrder(signedOrder, takerAssetFillAmount, signedOrder.signature) .fillOrder(signedOrder, takerAssetFillAmount, signedOrder.signature)
@ -616,7 +616,7 @@ blockchainTests.resets('Exchange core', () => {
const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( const expectedError = new ExchangeRevertErrors.AssetProxyTransferError(
orderHashHex, orderHashHex,
signedOrder.makerAssetData, signedOrder.makerAssetData,
new StringRevertError(RevertReason.InvalidAmount).toString(), new StringRevertError(RevertReason.InvalidAmount).encode(),
); );
const tx = exchange const tx = exchange
.fillOrder(signedOrder, takerAssetFillAmount, signedOrder.signature) .fillOrder(signedOrder, takerAssetFillAmount, signedOrder.signature)
@ -645,7 +645,7 @@ blockchainTests.resets('Exchange core', () => {
const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( const expectedError = new ExchangeRevertErrors.AssetProxyTransferError(
orderHashHex, orderHashHex,
signedOrder.takerAssetData, signedOrder.takerAssetData,
new StringRevertError(RevertReason.InvalidAmount).toString(), new StringRevertError(RevertReason.InvalidAmount).encode(),
); );
const tx = exchange const tx = exchange
.fillOrder(signedOrder, takerAssetFillAmount, signedOrder.signature) .fillOrder(signedOrder, takerAssetFillAmount, signedOrder.signature)
@ -980,7 +980,7 @@ blockchainTests.resets('Exchange core', () => {
const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( const expectedError = new ExchangeRevertErrors.AssetProxyTransferError(
orderHashHex, orderHashHex,
assetData, assetData,
new StringRevertError(RevertReason.TargetNotEven).toString(), new StringRevertError(RevertReason.TargetNotEven).encode(),
); );
const tx = exchange const tx = exchange
.fillOrder(signedOrder, signedOrder.takerAssetAmount, signedOrder.signature) .fillOrder(signedOrder, signedOrder.takerAssetAmount, signedOrder.signature)
@ -1015,7 +1015,7 @@ blockchainTests.resets('Exchange core', () => {
const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( const expectedError = new ExchangeRevertErrors.AssetProxyTransferError(
orderHashHex, orderHashHex,
assetData, assetData,
new StringRevertError(RevertReason.TargetNotEven).toString(), new StringRevertError(RevertReason.TargetNotEven).encode(),
); );
const tx = exchange const tx = exchange
.fillOrder(signedOrder, signedOrder.takerAssetAmount, signedOrder.signature) .fillOrder(signedOrder, signedOrder.takerAssetAmount, signedOrder.signature)

View File

@ -278,7 +278,7 @@ blockchainTests.resets('Exchange fills dydx orders', env => {
} catch (e) { } catch (e) {
assetProxyError = decodeThrownErrorAsRevertError(e).values.errorData; assetProxyError = decodeThrownErrorAsRevertError(e).values.errorData;
} }
expect(assetProxyError).to.deep.equal(new StringRevertError(expectedAssetProxyError.toString())); expect(assetProxyError).to.deep.equal(new StringRevertError(expectedAssetProxyError.encode()));
}); });
}); });
}); });

View File

@ -121,7 +121,7 @@ blockchainTests.resets('Transaction <> protocol fee integration tests', env => {
maker.address, maker.address,
wethless.address, wethless.address,
'0x', '0x',
).toString(); ).encode();
return new ExchangeRevertErrors.TransactionExecutionError( return new ExchangeRevertErrors.TransactionExecutionError(
transactionHashUtils.getTransactionHashHex(failedTransaction), transactionHashUtils.getTransactionHashHex(failedTransaction),
nestedError, nestedError,
@ -252,7 +252,7 @@ blockchainTests.resets('Transaction <> protocol fee integration tests', env => {
.awaitTransactionSuccessAsync({ from: alice.address, value: REFUND_AMOUNT }); .awaitTransactionSuccessAsync({ from: alice.address, value: REFUND_AMOUNT });
const expectedError = new ExchangeRevertErrors.TransactionExecutionError( const expectedError = new ExchangeRevertErrors.TransactionExecutionError(
transactionHashUtils.getTransactionHashHex(recursiveTransaction), transactionHashUtils.getTransactionHashHex(recursiveTransaction),
protocolFeeError(order, transaction).toString(), protocolFeeError(order, transaction).encode(),
); );
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
}); });

View File

@ -280,7 +280,7 @@ blockchainTests.resets('Transaction integration tests', env => {
const noReentrancyError = new ExchangeRevertErrors.TransactionInvalidContextError( const noReentrancyError = new ExchangeRevertErrors.TransactionInvalidContextError(
transactionHashHex, transactionHashHex,
transaction.signerAddress, transaction.signerAddress,
).toString(); ).encode();
const expectedError = new ExchangeRevertErrors.TransactionExecutionError( const expectedError = new ExchangeRevertErrors.TransactionExecutionError(
recursiveTransactionHashHex, recursiveTransactionHashHex,
noReentrancyError, noReentrancyError,
@ -330,7 +330,7 @@ blockchainTests.resets('Transaction integration tests', env => {
orderHashUtils.getOrderHashHex(order), orderHashUtils.getOrderHashHex(order),
order.makerAddress, order.makerAddress,
order.signature, order.signature,
).toString(); ).encode();
const expectedError = new ExchangeRevertErrors.TransactionExecutionError( const expectedError = new ExchangeRevertErrors.TransactionExecutionError(
transactionHashHex, transactionHashHex,
nestedError, nestedError,
@ -353,7 +353,7 @@ blockchainTests.resets('Transaction integration tests', env => {
ExchangeRevertErrors.ExchangeContextErrorCodes.InvalidMaker, ExchangeRevertErrors.ExchangeContextErrorCodes.InvalidMaker,
orderHashUtils.getOrderHashHex(order), orderHashUtils.getOrderHashHex(order),
takers[0].address, takers[0].address,
).toString(); ).encode();
const expectedError = new ExchangeRevertErrors.TransactionExecutionError( const expectedError = new ExchangeRevertErrors.TransactionExecutionError(
transactionHashHex, transactionHashHex,
nestedError, nestedError,
@ -403,7 +403,7 @@ blockchainTests.resets('Transaction integration tests', env => {
ExchangeRevertErrors.ExchangeContextErrorCodes.InvalidMaker, ExchangeRevertErrors.ExchangeContextErrorCodes.InvalidMaker,
orderHashUtils.getOrderHashHex(orders[0]), orderHashUtils.getOrderHashHex(orders[0]),
takers[0].address, takers[0].address,
).toString(); ).encode();
const expectedError = new ExchangeRevertErrors.TransactionExecutionError( const expectedError = new ExchangeRevertErrors.TransactionExecutionError(
transactionHashHex, transactionHashHex,
nestedError, nestedError,
@ -771,7 +771,7 @@ blockchainTests.resets('Transaction integration tests', env => {
const nestedError = new ExchangeRevertErrors.OrderStatusError( const nestedError = new ExchangeRevertErrors.OrderStatusError(
orderHashUtils.getOrderHashHex(order), orderHashUtils.getOrderHashHex(order),
OrderStatus.Cancelled, OrderStatus.Cancelled,
).toString(); ).encode();
const expectedError = new ExchangeRevertErrors.TransactionExecutionError( const expectedError = new ExchangeRevertErrors.TransactionExecutionError(
transactionHashUtils.getTransactionHashHex(transaction2), transactionHashUtils.getTransactionHashHex(transaction2),
nestedError, nestedError,

View File

@ -123,7 +123,7 @@ blockchainTests.resets('Chainlink stop-limit order tests', env => {
const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( const expectedError = new ExchangeRevertErrors.AssetProxyTransferError(
orderHashUtils.getOrderHashHex(order), orderHashUtils.getOrderHashHex(order),
order.makerAssetData, order.makerAssetData,
new StringRevertError('ChainlinkStopLimit/OUT_OF_PRICE_RANGE').toString(), new StringRevertError('ChainlinkStopLimit/OUT_OF_PRICE_RANGE').encode(),
); );
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
}); });
@ -133,7 +133,7 @@ blockchainTests.resets('Chainlink stop-limit order tests', env => {
const expectedError = new ExchangeRevertErrors.AssetProxyTransferError( const expectedError = new ExchangeRevertErrors.AssetProxyTransferError(
orderHashUtils.getOrderHashHex(order), orderHashUtils.getOrderHashHex(order),
order.makerAssetData, order.makerAssetData,
new StringRevertError('ChainlinkStopLimit/OUT_OF_PRICE_RANGE').toString(), new StringRevertError('ChainlinkStopLimit/OUT_OF_PRICE_RANGE').encode(),
); );
return expect(tx).to.revertWith(expectedError); return expect(tx).to.revertWith(expectedError);
}); });

View File

@ -45,8 +45,12 @@ export async function deployBootstrapFeaturesAsync(
)).address, )).address,
ownable: ownable:
features.ownable || features.ownable ||
(await OwnableFeatureContract.deployFrom0xArtifactAsync(artifacts.OwnableFeature, provider, txDefaults, artifacts)) (await OwnableFeatureContract.deployFrom0xArtifactAsync(
.address, artifacts.OwnableFeature,
provider,
txDefaults,
artifacts,
)).address,
}; };
} }

View File

@ -52,7 +52,12 @@ blockchainTests.resets('MetaTransactions feature', env => {
zeroEx = await fullMigrateAsync(owner, env.provider, env.txDefaults, { zeroEx = await fullMigrateAsync(owner, env.provider, env.txDefaults, {
transformERC20: transformERC20Feature.address, transformERC20: transformERC20Feature.address,
}); });
feature = new MetaTransactionsFeatureContract(zeroEx.address, env.provider, { ...env.txDefaults, from: sender }, abis); feature = new MetaTransactionsFeatureContract(
zeroEx.address,
env.provider,
{ ...env.txDefaults, from: sender },
abis,
);
feeToken = await TestMintableERC20TokenContract.deployFrom0xArtifactAsync( feeToken = await TestMintableERC20TokenContract.deployFrom0xArtifactAsync(
artifacts.TestMintableERC20Token, artifacts.TestMintableERC20Token,
env.provider, env.provider,

View File

@ -60,7 +60,12 @@ blockchainTests.resets('TransformERC20 feature', env => {
}, },
{ transformerDeployer }, { transformerDeployer },
); );
feature = new TransformERC20FeatureContract(zeroEx.address, env.provider, { ...env.txDefaults, from: sender }, abis); feature = new TransformERC20FeatureContract(
zeroEx.address,
env.provider,
{ ...env.txDefaults, from: sender },
abis,
);
wallet = new FlashWalletContract(await feature.getTransformWallet().callAsync(), env.provider, env.txDefaults); wallet = new FlashWalletContract(await feature.getTransformWallet().callAsync(), env.provider, env.txDefaults);
allowanceTarget = await new ITokenSpenderFeatureContract(zeroEx.address, env.provider, env.txDefaults) allowanceTarget = await new ITokenSpenderFeatureContract(zeroEx.address, env.provider, env.txDefaults)
.getAllowanceTarget() .getAllowanceTarget()
@ -122,7 +127,11 @@ blockchainTests.resets('TransformERC20 feature', env => {
it('owner can set the quote signer with `setQuoteSigner()`', async () => { it('owner can set the quote signer with `setQuoteSigner()`', async () => {
const newSigner = randomAddress(); const newSigner = randomAddress();
const receipt = await feature.setQuoteSigner(newSigner).awaitTransactionSuccessAsync({ from: owner }); const receipt = await feature.setQuoteSigner(newSigner).awaitTransactionSuccessAsync({ from: owner });
verifyEventsFromLogs(receipt.logs, [{ quoteSigner: newSigner }], TransformERC20FeatureEvents.QuoteSignerUpdated); verifyEventsFromLogs(
receipt.logs,
[{ quoteSigner: newSigner }],
TransformERC20FeatureEvents.QuoteSignerUpdated,
);
const actualSigner = await feature.getQuoteSigner().callAsync(); const actualSigner = await feature.getQuoteSigner().callAsync();
expect(actualSigner).to.eq(newSigner); expect(actualSigner).to.eq(newSigner);
}); });