In @0x/contracts-extensions
: Upgrade tests for rich reverts
This commit is contained in:
parent
233336ea16
commit
991348bbbe
@ -31,6 +31,10 @@
|
|||||||
{
|
{
|
||||||
"note": "Refactor BalanceThresholdFilter to use new ITransactions interface",
|
"note": "Refactor BalanceThresholdFilter to use new ITransactions interface",
|
||||||
"pr": 1753
|
"pr": 1753
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Update tests for rich reverts",
|
||||||
|
"pr": TODO
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"timestamp": 1563006338
|
"timestamp": 1563006338
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange';
|
import { ExchangeContract, ExchangeWrapper } from '@0x/contracts-exchange';
|
||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||||
import { assetDataUtils } from '@0x/order-utils';
|
import { assetDataUtils, ExchangeRevertErrors } from '@0x/order-utils';
|
||||||
import { Order, RevertReason, SignedOrder } from '@0x/types';
|
import { Order, RevertReason, SignedOrder } from '@0x/types';
|
||||||
import { BigNumber, providerUtils } from '@0x/utils';
|
import { BigNumber, providerUtils } from '@0x/utils';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
@ -15,7 +15,6 @@ import {
|
|||||||
constants,
|
constants,
|
||||||
ContractName,
|
ContractName,
|
||||||
ERC20BalancesByOwner,
|
ERC20BalancesByOwner,
|
||||||
expectTransactionFailedAsync,
|
|
||||||
OrderFactory,
|
OrderFactory,
|
||||||
OrderStatus,
|
OrderStatus,
|
||||||
provider,
|
provider,
|
||||||
@ -293,15 +292,13 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
const badSelectorHex = '0x00000000';
|
const badSelectorHex = '0x00000000';
|
||||||
const signatureHex = '0x';
|
const signatureHex = '0x';
|
||||||
// Call valid forwarder
|
// Call valid forwarder
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721BalanceThresholdFilterInstance.executeTransaction.sendTransactionAsync(
|
||||||
erc721BalanceThresholdFilterInstance.executeTransaction.sendTransactionAsync(
|
salt,
|
||||||
salt,
|
validTakerAddress,
|
||||||
validTakerAddress,
|
badSelectorHex,
|
||||||
badSelectorHex,
|
signatureHex,
|
||||||
signatureHex,
|
|
||||||
),
|
|
||||||
RevertReason.InvalidOrBlockedExchangeSelector,
|
|
||||||
);
|
);
|
||||||
|
return expect(tx).to.revertWith(RevertReason.InvalidOrBlockedExchangeSelector);
|
||||||
});
|
});
|
||||||
it('should revert if senderAddress is not set to the valid forwarding contract', async () => {
|
it('should revert if senderAddress is not set to the valid forwarding contract', async () => {
|
||||||
// Create signed order with incorrect senderAddress
|
// Create signed order with incorrect senderAddress
|
||||||
@ -309,13 +306,14 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
const signedOrderWithBadSenderAddress = await orderFactory.newSignedOrderAsync({
|
const signedOrderWithBadSenderAddress = await orderFactory.newSignedOrderAsync({
|
||||||
senderAddress: notBalanceThresholdFilterAddress,
|
senderAddress: notBalanceThresholdFilterAddress,
|
||||||
});
|
});
|
||||||
|
const expectedError = new ExchangeRevertErrors.TransactionExecutionError();
|
||||||
// Call valid forwarder
|
// Call valid forwarder
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721TakerBalanceThresholdWrapper.fillOrderAsync(
|
||||||
erc721TakerBalanceThresholdWrapper.fillOrderAsync(signedOrderWithBadSenderAddress, validTakerAddress, {
|
signedOrderWithBadSenderAddress,
|
||||||
takerAssetFillAmount,
|
validTakerAddress,
|
||||||
}),
|
{ takerAssetFillAmount },
|
||||||
RevertReason.FailedExecution,
|
|
||||||
);
|
);
|
||||||
|
return expect(tx).to.revertWith(expectedError);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -396,22 +394,18 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
});
|
});
|
||||||
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
||||||
// Execute transaction
|
// Execute transaction
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721TakerBalanceThresholdWrapper.batchFillOrdersAsync(orders, validTakerAddress, {
|
||||||
erc721TakerBalanceThresholdWrapper.batchFillOrdersAsync(orders, validTakerAddress, {
|
takerAssetFillAmounts,
|
||||||
takerAssetFillAmounts,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('should revert if taker does not meet the balance threshold', async () => {
|
it('should revert if taker does not meet the balance threshold', async () => {
|
||||||
const orders = [validSignedOrder, validSignedOrder2];
|
const orders = [validSignedOrder, validSignedOrder2];
|
||||||
const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount];
|
const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount];
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721NonValidBalanceThresholdWrapper.batchFillOrdersAsync(orders, invalidAddress, {
|
||||||
erc721NonValidBalanceThresholdWrapper.batchFillOrdersAsync(orders, invalidAddress, {
|
takerAssetFillAmounts,
|
||||||
takerAssetFillAmounts,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -500,22 +494,18 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
});
|
});
|
||||||
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
||||||
// Execute transaction
|
// Execute transaction
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721TakerBalanceThresholdWrapper.batchFillOrdersNoThrowAsync(orders, validTakerAddress, {
|
||||||
erc721TakerBalanceThresholdWrapper.batchFillOrdersNoThrowAsync(orders, validTakerAddress, {
|
takerAssetFillAmounts,
|
||||||
takerAssetFillAmounts,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('should revert if taker does not meet the balance threshold', async () => {
|
it('should revert if taker does not meet the balance threshold', async () => {
|
||||||
const orders = [validSignedOrder, validSignedOrder2];
|
const orders = [validSignedOrder, validSignedOrder2];
|
||||||
const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount];
|
const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount];
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721NonValidBalanceThresholdWrapper.batchFillOrdersNoThrowAsync(orders, invalidAddress, {
|
||||||
erc721NonValidBalanceThresholdWrapper.batchFillOrdersNoThrowAsync(orders, invalidAddress, {
|
takerAssetFillAmounts,
|
||||||
takerAssetFillAmounts,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -598,33 +588,29 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
});
|
});
|
||||||
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
||||||
// Execute transaction
|
// Execute transaction
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721TakerBalanceThresholdWrapper.batchFillOrKillOrdersAsync(orders, validTakerAddress, {
|
||||||
erc721TakerBalanceThresholdWrapper.batchFillOrKillOrdersAsync(orders, validTakerAddress, {
|
takerAssetFillAmounts,
|
||||||
takerAssetFillAmounts,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('should revert if taker does not meet the balance threshold', async () => {
|
it('should revert if taker does not meet the balance threshold', async () => {
|
||||||
const orders = [validSignedOrder, validSignedOrder2];
|
const orders = [validSignedOrder, validSignedOrder2];
|
||||||
const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount];
|
const takerAssetFillAmounts = [takerAssetFillAmount, takerAssetFillAmount];
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721NonValidBalanceThresholdWrapper.batchFillOrKillOrdersAsync(orders, invalidAddress, {
|
||||||
erc721NonValidBalanceThresholdWrapper.batchFillOrKillOrdersAsync(orders, invalidAddress, {
|
takerAssetFillAmounts,
|
||||||
takerAssetFillAmounts,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('should revert if one takerAssetFillAmount is not fully filled', async () => {
|
it('should revert if one takerAssetFillAmount is not fully filled', async () => {
|
||||||
const tooBigTakerAssetFillAmount = validSignedOrder.takerAssetAmount.times(2);
|
const tooBigTakerAssetFillAmount = validSignedOrder.takerAssetAmount.times(2);
|
||||||
const orders = [validSignedOrder, validSignedOrder2];
|
const orders = [validSignedOrder, validSignedOrder2];
|
||||||
const takerAssetFillAmounts = [takerAssetFillAmount, tooBigTakerAssetFillAmount];
|
const takerAssetFillAmounts = [takerAssetFillAmount, tooBigTakerAssetFillAmount];
|
||||||
return expectTransactionFailedAsync(
|
const expectedError = new ExchangeRevertErrors.TransactionExecutionError();
|
||||||
erc721TakerBalanceThresholdWrapper.batchFillOrKillOrdersAsync(orders, validTakerAddress, {
|
// Call valid forwarder
|
||||||
takerAssetFillAmounts,
|
const tx = erc721TakerBalanceThresholdWrapper.batchFillOrKillOrdersAsync(orders, validTakerAddress, {
|
||||||
}),
|
takerAssetFillAmounts,
|
||||||
RevertReason.FailedExecution,
|
});
|
||||||
);
|
return expect(tx).to.revertWith(expectedError);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -683,20 +669,18 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
makerAddress: invalidAddress,
|
makerAddress: invalidAddress,
|
||||||
});
|
});
|
||||||
// Execute transaction
|
// Execute transaction
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721TakerBalanceThresholdWrapper.fillOrderAsync(
|
||||||
erc721TakerBalanceThresholdWrapper.fillOrderAsync(signedOrderWithBadMakerAddress, validTakerAddress, {
|
signedOrderWithBadMakerAddress,
|
||||||
takerAssetFillAmount,
|
validTakerAddress,
|
||||||
}),
|
{ takerAssetFillAmount },
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
);
|
||||||
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
});
|
});
|
||||||
it('should revert if taker does not meet the balance threshold', async () => {
|
it('should revert if taker does not meet the balance threshold', async () => {
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721NonValidBalanceThresholdWrapper.fillOrderAsync(validSignedOrder, invalidAddress, {
|
||||||
erc721NonValidBalanceThresholdWrapper.fillOrderAsync(validSignedOrder, invalidAddress, {
|
takerAssetFillAmount,
|
||||||
takerAssetFillAmount,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -761,22 +745,18 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
makerAddress: invalidAddress,
|
makerAddress: invalidAddress,
|
||||||
});
|
});
|
||||||
// Execute transaction
|
// Execute transaction
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721TakerBalanceThresholdWrapper.fillOrderNoThrowAsync(
|
||||||
erc721TakerBalanceThresholdWrapper.fillOrderNoThrowAsync(
|
signedOrderWithBadMakerAddress,
|
||||||
signedOrderWithBadMakerAddress,
|
validTakerAddress,
|
||||||
validTakerAddress,
|
{ takerAssetFillAmount },
|
||||||
{ takerAssetFillAmount },
|
|
||||||
),
|
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
);
|
||||||
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
});
|
});
|
||||||
it('should revert if taker does not meet the balance threshold', async () => {
|
it('should revert if taker does not meet the balance threshold', async () => {
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721NonValidBalanceThresholdWrapper.fillOrderNoThrowAsync(validSignedOrder, invalidAddress, {
|
||||||
erc721NonValidBalanceThresholdWrapper.fillOrderNoThrowAsync(validSignedOrder, invalidAddress, {
|
takerAssetFillAmount,
|
||||||
takerAssetFillAmount,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -836,31 +816,26 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
makerAddress: invalidAddress,
|
makerAddress: invalidAddress,
|
||||||
});
|
});
|
||||||
// Execute transaction
|
// Execute transaction
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721TakerBalanceThresholdWrapper.fillOrKillOrderAsync(
|
||||||
erc721TakerBalanceThresholdWrapper.fillOrKillOrderAsync(
|
signedOrderWithBadMakerAddress,
|
||||||
signedOrderWithBadMakerAddress,
|
validTakerAddress,
|
||||||
validTakerAddress,
|
{ takerAssetFillAmount },
|
||||||
{ takerAssetFillAmount },
|
|
||||||
),
|
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
);
|
||||||
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
});
|
});
|
||||||
it('should revert if taker does not meet the balance threshold', async () => {
|
it('should revert if taker does not meet the balance threshold', async () => {
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721NonValidBalanceThresholdWrapper.fillOrKillOrderAsync(validSignedOrder, invalidAddress, {
|
||||||
erc721NonValidBalanceThresholdWrapper.fillOrKillOrderAsync(validSignedOrder, invalidAddress, {
|
takerAssetFillAmount,
|
||||||
takerAssetFillAmount,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('should revert if takerAssetFillAmount is not fully filled', async () => {
|
it('should revert if takerAssetFillAmount is not fully filled', async () => {
|
||||||
const tooBigTakerAssetFillAmount = validSignedOrder.takerAssetAmount.times(2);
|
const tooBigTakerAssetFillAmount = validSignedOrder.takerAssetAmount.times(2);
|
||||||
return expectTransactionFailedAsync(
|
const expectedError = new ExchangeRevertErrors.TransactionExecutionError();
|
||||||
erc721TakerBalanceThresholdWrapper.fillOrKillOrderAsync(validSignedOrder, validTakerAddress, {
|
const tx = erc721TakerBalanceThresholdWrapper.fillOrKillOrderAsync(validSignedOrder, validTakerAddress, {
|
||||||
takerAssetFillAmount: tooBigTakerAssetFillAmount,
|
takerAssetFillAmount: tooBigTakerAssetFillAmount,
|
||||||
}),
|
});
|
||||||
RevertReason.FailedExecution,
|
return expect(tx).to.revertWith(expectedError);
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -944,21 +919,17 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
});
|
});
|
||||||
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
||||||
// Execute transaction
|
// Execute transaction
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721TakerBalanceThresholdWrapper.marketSellOrdersAsync(orders, validTakerAddress, {
|
||||||
erc721TakerBalanceThresholdWrapper.marketSellOrdersAsync(orders, validTakerAddress, {
|
takerAssetFillAmount,
|
||||||
takerAssetFillAmount,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('should revert if taker does not meet the balance threshold', async () => {
|
it('should revert if taker does not meet the balance threshold', async () => {
|
||||||
const orders = [validSignedOrder, validSignedOrder2];
|
const orders = [validSignedOrder, validSignedOrder2];
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721NonValidBalanceThresholdWrapper.marketSellOrdersAsync(orders, invalidAddress, {
|
||||||
erc721NonValidBalanceThresholdWrapper.marketSellOrdersAsync(orders, invalidAddress, {
|
takerAssetFillAmount,
|
||||||
takerAssetFillAmount,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1048,21 +1019,17 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
});
|
});
|
||||||
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
||||||
// Execute transaction
|
// Execute transaction
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721TakerBalanceThresholdWrapper.marketSellOrdersNoThrowAsync(orders, validTakerAddress, {
|
||||||
erc721TakerBalanceThresholdWrapper.marketSellOrdersNoThrowAsync(orders, validTakerAddress, {
|
takerAssetFillAmount,
|
||||||
takerAssetFillAmount,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('should revert if taker does not meet the balance threshold', async () => {
|
it('should revert if taker does not meet the balance threshold', async () => {
|
||||||
const orders = [validSignedOrder, validSignedOrder2];
|
const orders = [validSignedOrder, validSignedOrder2];
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721NonValidBalanceThresholdWrapper.marketSellOrdersNoThrowAsync(orders, invalidAddress, {
|
||||||
erc721NonValidBalanceThresholdWrapper.marketSellOrdersNoThrowAsync(orders, invalidAddress, {
|
takerAssetFillAmount,
|
||||||
takerAssetFillAmount,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1145,22 +1112,18 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
||||||
// Execute transaction
|
// Execute transaction
|
||||||
const dummyMakerAssetFillAmount = new BigNumber(0);
|
const dummyMakerAssetFillAmount = new BigNumber(0);
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721TakerBalanceThresholdWrapper.marketBuyOrdersAsync(orders, validTakerAddress, {
|
||||||
erc721TakerBalanceThresholdWrapper.marketBuyOrdersAsync(orders, validTakerAddress, {
|
makerAssetFillAmount: dummyMakerAssetFillAmount,
|
||||||
makerAssetFillAmount: dummyMakerAssetFillAmount,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('should revert if taker does not meet the balance threshold', async () => {
|
it('should revert if taker does not meet the balance threshold', async () => {
|
||||||
const orders = [validSignedOrder, validSignedOrder2];
|
const orders = [validSignedOrder, validSignedOrder2];
|
||||||
const dummyMakerAssetFillAmount = new BigNumber(0);
|
const dummyMakerAssetFillAmount = new BigNumber(0);
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721NonValidBalanceThresholdWrapper.marketBuyOrdersAsync(orders, invalidAddress, {
|
||||||
erc721NonValidBalanceThresholdWrapper.marketBuyOrdersAsync(orders, invalidAddress, {
|
makerAssetFillAmount: dummyMakerAssetFillAmount,
|
||||||
makerAssetFillAmount: dummyMakerAssetFillAmount,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1251,22 +1214,18 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
const orders = [validSignedOrder, signedOrderWithBadMakerAddress];
|
||||||
// Execute transaction
|
// Execute transaction
|
||||||
const dummyMakerAssetFillAmount = new BigNumber(0);
|
const dummyMakerAssetFillAmount = new BigNumber(0);
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721TakerBalanceThresholdWrapper.marketBuyOrdersNoThrowAsync(orders, validTakerAddress, {
|
||||||
erc721TakerBalanceThresholdWrapper.marketBuyOrdersNoThrowAsync(orders, validTakerAddress, {
|
makerAssetFillAmount: dummyMakerAssetFillAmount,
|
||||||
makerAssetFillAmount: dummyMakerAssetFillAmount,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('should revert if taker does not meet the balance threshold', async () => {
|
it('should revert if taker does not meet the balance threshold', async () => {
|
||||||
const orders = [validSignedOrder, validSignedOrder2];
|
const orders = [validSignedOrder, validSignedOrder2];
|
||||||
const dummyMakerAssetFillAmount = new BigNumber(0);
|
const dummyMakerAssetFillAmount = new BigNumber(0);
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721NonValidBalanceThresholdWrapper.marketBuyOrdersNoThrowAsync(orders, invalidAddress, {
|
||||||
erc721NonValidBalanceThresholdWrapper.marketBuyOrdersNoThrowAsync(orders, invalidAddress, {
|
makerAssetFillAmount: dummyMakerAssetFillAmount,
|
||||||
makerAssetFillAmount: dummyMakerAssetFillAmount,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1409,14 +1368,12 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
makerAddress: invalidAddress,
|
makerAddress: invalidAddress,
|
||||||
});
|
});
|
||||||
// Execute transaction
|
// Execute transaction
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721TakerBalanceThresholdWrapper.matchOrdersAsync(
|
||||||
erc721TakerBalanceThresholdWrapper.matchOrdersAsync(
|
validSignedOrder,
|
||||||
validSignedOrder,
|
signedOrderWithBadMakerAddress,
|
||||||
signedOrderWithBadMakerAddress,
|
validTakerAddress,
|
||||||
validTakerAddress,
|
|
||||||
),
|
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
);
|
||||||
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
});
|
});
|
||||||
it('should revert if right maker does not meet the balance threshold', async () => {
|
it('should revert if right maker does not meet the balance threshold', async () => {
|
||||||
// Create signed order with non-valid maker address
|
// Create signed order with non-valid maker address
|
||||||
@ -1425,24 +1382,20 @@ describe(ContractName.BalanceThresholdFilter, () => {
|
|||||||
makerAddress: invalidAddress,
|
makerAddress: invalidAddress,
|
||||||
});
|
});
|
||||||
// Execute transaction
|
// Execute transaction
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721TakerBalanceThresholdWrapper.matchOrdersAsync(
|
||||||
erc721TakerBalanceThresholdWrapper.matchOrdersAsync(
|
signedOrderWithBadMakerAddress,
|
||||||
signedOrderWithBadMakerAddress,
|
validSignedOrder,
|
||||||
validSignedOrder,
|
validTakerAddress,
|
||||||
validTakerAddress,
|
|
||||||
),
|
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
);
|
||||||
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
});
|
});
|
||||||
it('should revert if taker does not meet the balance threshold', async () => {
|
it('should revert if taker does not meet the balance threshold', async () => {
|
||||||
return expectTransactionFailedAsync(
|
const tx = erc721NonValidBalanceThresholdWrapper.matchOrdersAsync(
|
||||||
erc721NonValidBalanceThresholdWrapper.matchOrdersAsync(
|
validSignedOrder,
|
||||||
validSignedOrder,
|
validSignedOrder,
|
||||||
validSignedOrder,
|
invalidAddress,
|
||||||
invalidAddress,
|
|
||||||
),
|
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold,
|
|
||||||
);
|
);
|
||||||
|
return expect(tx).to.revertWith(RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import {
|
|||||||
constants,
|
constants,
|
||||||
ContractName,
|
ContractName,
|
||||||
ERC20BalancesByOwner,
|
ERC20BalancesByOwner,
|
||||||
expectTransactionFailedAsync,
|
|
||||||
getLatestBlockTimestampAsync,
|
getLatestBlockTimestampAsync,
|
||||||
OrderFactory,
|
OrderFactory,
|
||||||
provider,
|
provider,
|
||||||
@ -287,28 +286,22 @@ describe(ContractName.DutchAuction, () => {
|
|||||||
expirationTimeSeconds: auctionEndTimeSeconds,
|
expirationTimeSeconds: auctionEndTimeSeconds,
|
||||||
makerAssetData,
|
makerAssetData,
|
||||||
});
|
});
|
||||||
return expectTransactionFailedAsync(
|
const tx = dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress);
|
||||||
dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress),
|
return expect(tx).to.revertWith(RevertReason.AuctionExpired);
|
||||||
RevertReason.AuctionExpired,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('cannot be filled for less than the current price', async () => {
|
it('cannot be filled for less than the current price', async () => {
|
||||||
buyOrder = await buyerOrderFactory.newSignedOrderAsync({
|
buyOrder = await buyerOrderFactory.newSignedOrderAsync({
|
||||||
makerAssetAmount: sellOrder.takerAssetAmount,
|
makerAssetAmount: sellOrder.takerAssetAmount,
|
||||||
});
|
});
|
||||||
return expectTransactionFailedAsync(
|
const tx = dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress);
|
||||||
dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress),
|
return expect(tx).to.revertWith(RevertReason.AuctionInvalidAmount);
|
||||||
RevertReason.AuctionInvalidAmount,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('auction begin amount must be higher than final amount ', async () => {
|
it('auction begin amount must be higher than final amount ', async () => {
|
||||||
sellOrder = await sellerOrderFactory.newSignedOrderAsync({
|
sellOrder = await sellerOrderFactory.newSignedOrderAsync({
|
||||||
takerAssetAmount: auctionBeginAmount.plus(1),
|
takerAssetAmount: auctionBeginAmount.plus(1),
|
||||||
});
|
});
|
||||||
return expectTransactionFailedAsync(
|
const tx = dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress);
|
||||||
dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress),
|
return expect(tx).to.revertWith(RevertReason.AuctionInvalidAmount);
|
||||||
RevertReason.AuctionInvalidAmount,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('begin time is less than end time', async () => {
|
it('begin time is less than end time', async () => {
|
||||||
auctionBeginTimeSeconds = new BigNumber(auctionEndTimeSeconds).plus(tenMinutesInSeconds);
|
auctionBeginTimeSeconds = new BigNumber(auctionEndTimeSeconds).plus(tenMinutesInSeconds);
|
||||||
@ -321,19 +314,15 @@ describe(ContractName.DutchAuction, () => {
|
|||||||
expirationTimeSeconds: auctionEndTimeSeconds,
|
expirationTimeSeconds: auctionEndTimeSeconds,
|
||||||
makerAssetData,
|
makerAssetData,
|
||||||
});
|
});
|
||||||
return expectTransactionFailedAsync(
|
const tx = dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress);
|
||||||
dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress),
|
return expect(tx).to.revertWith(RevertReason.AuctionInvalidBeginTime);
|
||||||
RevertReason.AuctionInvalidBeginTime,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('asset data contains auction parameters', async () => {
|
it('asset data contains auction parameters', async () => {
|
||||||
sellOrder = await sellerOrderFactory.newSignedOrderAsync({
|
sellOrder = await sellerOrderFactory.newSignedOrderAsync({
|
||||||
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
makerAssetData: assetDataUtils.encodeERC20AssetData(defaultMakerAssetAddress),
|
||||||
});
|
});
|
||||||
return expectTransactionFailedAsync(
|
const tx = dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress);
|
||||||
dutchAuctionTestWrapper.matchOrdersAsync(buyOrder, sellOrder, takerAddress),
|
return expect(tx).to.revertWith(RevertReason.InvalidAssetData);
|
||||||
RevertReason.InvalidAssetData,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ERC721', () => {
|
describe('ERC721', () => {
|
||||||
|
@ -21,7 +21,7 @@ import {
|
|||||||
web3Wrapper,
|
web3Wrapper,
|
||||||
} from '@0x/contracts-test-utils';
|
} from '@0x/contracts-test-utils';
|
||||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||||
import { assetDataUtils } from '@0x/order-utils';
|
import { assetDataUtils, ExchangeRevertErrors } from '@0x/order-utils';
|
||||||
import { RevertReason } from '@0x/types';
|
import { RevertReason } from '@0x/types';
|
||||||
import { BigNumber, providerUtils } from '@0x/utils';
|
import { BigNumber, providerUtils } from '@0x/utils';
|
||||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||||
@ -241,15 +241,13 @@ describe('OrderMatcher', () => {
|
|||||||
signedOrderLeft.signature,
|
signedOrderLeft.signature,
|
||||||
signedOrderRight.signature,
|
signedOrderRight.signature,
|
||||||
);
|
);
|
||||||
await expectTransactionFailedAsync(
|
const tx = web3Wrapper.sendTransactionAsync({
|
||||||
web3Wrapper.sendTransactionAsync({
|
data,
|
||||||
data,
|
to: orderMatcher.address,
|
||||||
to: orderMatcher.address,
|
from: takerAddress,
|
||||||
from: takerAddress,
|
gas: constants.MAX_MATCH_ORDERS_GAS,
|
||||||
gas: constants.MAX_MATCH_ORDERS_GAS,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.OnlyContractOwner);
|
||||||
RevertReason.OnlyContractOwner,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('should transfer the correct amounts when orders completely fill each other', async () => {
|
it('should transfer the correct amounts when orders completely fill each other', async () => {
|
||||||
// Create orders to match
|
// Create orders to match
|
||||||
@ -676,15 +674,14 @@ describe('OrderMatcher', () => {
|
|||||||
signedOrderLeft.signature,
|
signedOrderLeft.signature,
|
||||||
signedOrderRight.signature,
|
signedOrderRight.signature,
|
||||||
);
|
);
|
||||||
await expectTransactionFailedAsync(
|
const expectedError = new ExchangeRevertErrors.SignatureError();
|
||||||
web3Wrapper.sendTransactionAsync({
|
const tx = web3Wrapper.sendTransactionAsync({
|
||||||
data,
|
data,
|
||||||
to: orderMatcher.address,
|
to: orderMatcher.address,
|
||||||
from: owner,
|
from: owner,
|
||||||
gas: constants.MAX_MATCH_ORDERS_GAS,
|
gas: constants.MAX_MATCH_ORDERS_GAS,
|
||||||
}),
|
});
|
||||||
RevertReason.InvalidOrderSignature,
|
return expect(tx).to.revertWith(expectedError);
|
||||||
);
|
|
||||||
});
|
});
|
||||||
it('should revert with the correct reason if fillOrder call reverts', async () => {
|
it('should revert with the correct reason if fillOrder call reverts', async () => {
|
||||||
// Create orders to match
|
// Create orders to match
|
||||||
@ -709,15 +706,14 @@ describe('OrderMatcher', () => {
|
|||||||
signedOrderLeft.signature,
|
signedOrderLeft.signature,
|
||||||
signedOrderRight.signature,
|
signedOrderRight.signature,
|
||||||
);
|
);
|
||||||
await expectTransactionFailedAsync(
|
const expectedError = new ExchangeRevertErrors.AssetProxyTransferError();
|
||||||
web3Wrapper.sendTransactionAsync({
|
const tx = web3Wrapper.sendTransactionAsync({
|
||||||
data,
|
data,
|
||||||
to: orderMatcher.address,
|
to: orderMatcher.address,
|
||||||
from: owner,
|
from: owner,
|
||||||
gas: constants.MAX_MATCH_ORDERS_GAS,
|
gas: constants.MAX_MATCH_ORDERS_GAS,
|
||||||
}),
|
});
|
||||||
RevertReason.TransferFailed,
|
return expect(tx).to.revertWith(expectedError);
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('withdrawAsset', () => {
|
describe('withdrawAsset', () => {
|
||||||
@ -757,12 +753,10 @@ describe('OrderMatcher', () => {
|
|||||||
it('should revert if not called by owner', async () => {
|
it('should revert if not called by owner', async () => {
|
||||||
const erc20AWithdrawAmount = await erc20TokenA.balanceOf.callAsync(orderMatcher.address);
|
const erc20AWithdrawAmount = await erc20TokenA.balanceOf.callAsync(orderMatcher.address);
|
||||||
expect(erc20AWithdrawAmount).to.be.bignumber.gt(constants.ZERO_AMOUNT);
|
expect(erc20AWithdrawAmount).to.be.bignumber.gt(constants.ZERO_AMOUNT);
|
||||||
await expectTransactionFailedAsync(
|
const tx = orderMatcher.withdrawAsset.sendTransactionAsync(leftMakerAssetData, erc20AWithdrawAmount, {
|
||||||
orderMatcher.withdrawAsset.sendTransactionAsync(leftMakerAssetData, erc20AWithdrawAmount, {
|
from: takerAddress,
|
||||||
from: takerAddress,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.OnlyContractOwner);
|
||||||
RevertReason.OnlyContractOwner,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('approveAssetProxy', () => {
|
describe('approveAssetProxy', () => {
|
||||||
@ -813,12 +807,10 @@ describe('OrderMatcher', () => {
|
|||||||
});
|
});
|
||||||
it('should revert if not called by owner', async () => {
|
it('should revert if not called by owner', async () => {
|
||||||
const approval = new BigNumber(1);
|
const approval = new BigNumber(1);
|
||||||
await expectTransactionFailedAsync(
|
const tx = orderMatcher.approveAssetProxy.sendTransactionAsync(leftMakerAssetData, approval, {
|
||||||
orderMatcher.approveAssetProxy.sendTransactionAsync(leftMakerAssetData, approval, {
|
from: takerAddress,
|
||||||
from: takerAddress,
|
});
|
||||||
}),
|
return expect(tx).to.revertWith(RevertReason.OnlyContractOwner);
|
||||||
RevertReason.OnlyContractOwner,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user