aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/exchange/wrapper.ts
diff options
context:
space:
mode:
authorfragosti <francesco.agosti93@gmail.com>2018-06-07 07:36:11 +0800
committerfragosti <francesco.agosti93@gmail.com>2018-06-07 07:36:11 +0800
commite0d5b9daf84cba31bbbcd2cfbe1f64623eace61a (patch)
tree84929c7ae4e95896dacfb69517aaaba97ec8ad85 /packages/contracts/test/exchange/wrapper.ts
parenta97d77064aacda3de74b04894f110b05298c5ca8 (diff)
parent785b9811f30869f01242ce9ff81c282bf7f5352f (diff)
downloaddexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.gz
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.bz2
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.lz
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.xz
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.tar.zst
dexon-sol-tools-e0d5b9daf84cba31bbbcd2cfbe1f64623eace61a.zip
Merge branch 'v2-prototype' of https://github.com/0xProject/0x-monorepo into feature/improve-linting
Diffstat (limited to 'packages/contracts/test/exchange/wrapper.ts')
-rw-r--r--packages/contracts/test/exchange/wrapper.ts60
1 files changed, 44 insertions, 16 deletions
diff --git a/packages/contracts/test/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts
index 9bc85c8b9..6a522e50e 100644
--- a/packages/contracts/test/exchange/wrapper.ts
+++ b/packages/contracts/test/exchange/wrapper.ts
@@ -13,6 +13,7 @@ import { ERC20ProxyContract } from '../../src/contract_wrappers/generated/e_r_c2
import { ERC721ProxyContract } from '../../src/contract_wrappers/generated/e_r_c721_proxy';
import { ExchangeContract } from '../../src/contract_wrappers/generated/exchange';
import { artifacts } from '../../src/utils/artifacts';
+import { expectRevertOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions';
import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
@@ -170,8 +171,8 @@ describe('Exchange wrappers', () => {
expirationTimeSeconds: new BigNumber(Math.floor((Date.now() - 10000) / 1000)),
});
- return expect(exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
- constants.REVERT,
+ return expectRevertOrAlwaysFailingTransactionAsync(
+ exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress),
);
});
@@ -182,8 +183,8 @@ describe('Exchange wrappers', () => {
takerAssetFillAmount: signedOrder.takerAssetAmount.div(2),
});
- return expect(exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress)).to.be.rejectedWith(
- constants.REVERT,
+ return expectRevertOrAlwaysFailingTransactionAsync(
+ exchangeWrapper.fillOrKillOrderAsync(signedOrder, takerAddress),
);
});
});
@@ -195,12 +196,16 @@ describe('Exchange wrappers', () => {
takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(200), 18),
});
const takerAssetFillAmount = signedOrder.takerAssetAmount.div(2);
+
await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress, {
takerAssetFillAmount,
+ // HACK(albrow): We need to hardcode the gas estimate here because
+ // the Geth gas estimator doesn't work with the way we use
+ // delegatecall and swallow errors.
+ gas: 250000,
});
const newBalances = await erc20Wrapper.getBalancesAsync();
-
const makerAssetFilledAmount = takerAssetFillAmount
.times(signedOrder.makerAssetAmount)
.dividedToIntegerBy(signedOrder.takerAssetAmount);
@@ -210,6 +215,7 @@ describe('Exchange wrappers', () => {
const takerFee = signedOrder.takerFee
.times(makerAssetFilledAmount)
.dividedToIntegerBy(signedOrder.makerAssetAmount);
+
expect(newBalances[makerAddress][defaultMakerAssetAddress]).to.be.bignumber.equal(
erc20Balances[makerAddress][defaultMakerAssetAddress].minus(makerAssetFilledAmount),
);
@@ -358,7 +364,13 @@ describe('Exchange wrappers', () => {
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
// Call Exchange
const takerAssetFillAmount = signedOrder.takerAssetAmount;
- await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress, { takerAssetFillAmount });
+ await exchangeWrapper.fillOrderNoThrowAsync(signedOrder, takerAddress, {
+ takerAssetFillAmount,
+ // HACK(albrow): We need to hardcode the gas estimate here because
+ // the Geth gas estimator doesn't work with the way we use
+ // delegatecall and swallow errors.
+ gas: 270000,
+ });
// Verify post-conditions
const newOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId);
expect(newOwnerMakerAsset).to.be.bignumber.equal(takerAddress);
@@ -483,11 +495,11 @@ describe('Exchange wrappers', () => {
await exchangeWrapper.fillOrKillOrderAsync(signedOrders[0], takerAddress);
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
exchangeWrapper.batchFillOrKillOrdersAsync(signedOrders, takerAddress, {
takerAssetFillAmounts,
}),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});
@@ -533,6 +545,10 @@ describe('Exchange wrappers', () => {
await exchangeWrapper.batchFillOrdersNoThrowAsync(signedOrders, takerAddress, {
takerAssetFillAmounts,
+ // HACK(albrow): We need to hardcode the gas estimate here because
+ // the Geth gas estimator doesn't work with the way we use
+ // delegatecall and swallow errors.
+ gas: 600000,
});
const newBalances = await erc20Wrapper.getBalancesAsync();
@@ -589,6 +605,10 @@ describe('Exchange wrappers', () => {
const newOrders = [invalidOrder, ...validOrders];
await exchangeWrapper.batchFillOrdersNoThrowAsync(newOrders, takerAddress, {
takerAssetFillAmounts,
+ // HACK(albrow): We need to hardcode the gas estimate here because
+ // the Geth gas estimator doesn't work with the way we use
+ // delegatecall and swallow errors.
+ gas: 450000,
});
const newBalances = await erc20Wrapper.getBalancesAsync();
@@ -677,11 +697,11 @@ describe('Exchange wrappers', () => {
orderFactory.newSignedOrder(),
];
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
exchangeWrapper.marketSellOrdersAsync(signedOrders, takerAddress, {
takerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
}),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});
@@ -751,6 +771,10 @@ describe('Exchange wrappers', () => {
});
await exchangeWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, {
takerAssetFillAmount,
+ // HACK(albrow): We need to hardcode the gas estimate here because
+ // the Geth gas estimator doesn't work with the way we use
+ // delegatecall and swallow errors.
+ gas: 600000,
});
const newBalances = await erc20Wrapper.getBalancesAsync();
@@ -766,11 +790,11 @@ describe('Exchange wrappers', () => {
orderFactory.newSignedOrder(),
];
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
exchangeWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, {
takerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
}),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});
@@ -855,11 +879,11 @@ describe('Exchange wrappers', () => {
orderFactory.newSignedOrder(),
];
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
exchangeWrapper.marketBuyOrdersAsync(signedOrders, takerAddress, {
makerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
}),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});
@@ -929,6 +953,10 @@ describe('Exchange wrappers', () => {
});
await exchangeWrapper.marketSellOrdersNoThrowAsync(signedOrders, takerAddress, {
takerAssetFillAmount,
+ // HACK(albrow): We need to hardcode the gas estimate here because
+ // the Geth gas estimator doesn't work with the way we use
+ // delegatecall and swallow errors.
+ gas: 600000,
});
const newBalances = await erc20Wrapper.getBalancesAsync();
@@ -944,11 +972,11 @@ describe('Exchange wrappers', () => {
orderFactory.newSignedOrder(),
];
- return expect(
+ return expectRevertOrAlwaysFailingTransactionAsync(
exchangeWrapper.marketBuyOrdersNoThrowAsync(signedOrders, takerAddress, {
makerAssetFillAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(1000), 18),
}),
- ).to.be.rejectedWith(constants.REVERT);
+ );
});
});