aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/exchange
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-27 16:59:37 +0800
committerFabio Berger <me@fabioberger.com>2018-06-27 16:59:37 +0800
commitc308359f59cc24510ff3d42ae777226a599db376 (patch)
tree1b5523e4fbc3434abd4f66f87a6bb5b59ca7c52b /packages/contracts/test/exchange
parent375d667144e26253f8ff6b0ad1beb45d5b3ef228 (diff)
parent84bd54ba4025a33f4e311ec66d81d58b45e54d6b (diff)
downloaddexon-sol-tools-c308359f59cc24510ff3d42ae777226a599db376.tar
dexon-sol-tools-c308359f59cc24510ff3d42ae777226a599db376.tar.gz
dexon-sol-tools-c308359f59cc24510ff3d42ae777226a599db376.tar.bz2
dexon-sol-tools-c308359f59cc24510ff3d42ae777226a599db376.tar.lz
dexon-sol-tools-c308359f59cc24510ff3d42ae777226a599db376.tar.xz
dexon-sol-tools-c308359f59cc24510ff3d42ae777226a599db376.tar.zst
dexon-sol-tools-c308359f59cc24510ff3d42ae777226a599db376.zip
Merge branch 'v2-prototype' into feature/combinatorial-testing
* v2-prototype: Improve 'web3-provider-engine' typings Fix build Update artifacts Add more revert reasons to tests Make dispatchTransferFrom revert with reason from AssetProxy on failure Remove redundant files, hard code function selector in dispatchTransferFrom, and modify revert reason Updated offset of receiverData length to reflect new assetData encoding. ERC20 Custom storage layout Golf the authorization check ERC20 manual memory layout ERC20 inline return ERC721 inline return Golf ERC721 transferFrom Inline ERC20 tranferFrom selector constant Optimize ERC20 transferFrom Polish asset picker layout Update relayer grid fallback icon Change metamask install link based on browser Use ethereumjs-tx@1.3.5 instead of our fork # Conflicts: # packages/contracts/test/asset_proxy/proxies.ts # packages/contracts/test/exchange/core.ts # packages/migrations/artifacts/2.0.0/DummyERC721Token.json
Diffstat (limited to 'packages/contracts/test/exchange')
-rw-r--r--packages/contracts/test/exchange/core.ts41
1 files changed, 33 insertions, 8 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index b3c3a891c..76d8063f8 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -13,10 +13,7 @@ import { ERC20ProxyContract } from '../../src/generated_contract_wrappers/e_r_c2
import { ERC721ProxyContract } from '../../src/generated_contract_wrappers/e_r_c721_proxy';
import { CancelContractEventArgs, ExchangeContract } from '../../src/generated_contract_wrappers/exchange';
import { artifacts } from '../../src/utils/artifacts';
-import {
- expectRevertOrAlwaysFailingTransactionAsync,
- expectRevertReasonOrAlwaysFailingTransactionAsync,
-} from '../../src/utils/assertions';
+import { expectRevertReasonOrAlwaysFailingTransactionAsync } from '../../src/utils/assertions';
import { chaiSetup } from '../../src/utils/chai_setup';
import { constants } from '../../src/utils/constants';
import { ERC20Wrapper } from '../../src/utils/erc20_wrapper';
@@ -364,8 +361,9 @@ describe('Exchange core', () => {
expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
// Call Exchange
const takerAssetFillAmount = signedOrder.takerAssetAmount;
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectRevertReasonOrAlwaysFailingTransactionAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
+ RevertReason.TransferFailed,
);
});
@@ -386,8 +384,9 @@ describe('Exchange core', () => {
expect(initialOwnerTakerAsset).to.be.bignumber.not.equal(takerAddress);
// Call Exchange
const takerAssetFillAmount = signedOrder.takerAssetAmount;
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectRevertReasonOrAlwaysFailingTransactionAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
+ RevertReason.TransferFailed,
);
});
@@ -410,7 +409,7 @@ describe('Exchange core', () => {
const takerAssetFillAmount = signedOrder.takerAssetAmount;
return expectRevertReasonOrAlwaysFailingTransactionAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
- RevertReason.TransferFailed,
+ RevertReason.InvalidAmount,
);
});
@@ -433,7 +432,7 @@ describe('Exchange core', () => {
const takerAssetFillAmount = signedOrder.takerAssetAmount;
return expectRevertReasonOrAlwaysFailingTransactionAsync(
exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
- RevertReason.TransferFailed,
+ RevertReason.InvalidAmount,
);
});
@@ -453,6 +452,32 @@ describe('Exchange core', () => {
RevertReason.RoundingError,
);
});
+
+ it('should throw if assetData has a length < 132', async () => {
+ // Construct Exchange parameters
+ const makerAssetId = erc721MakerAssetIds[0];
+ const takerAssetId = erc721TakerAssetIds[0];
+ const makerAssetData = assetProxyUtils
+ .encodeERC721AssetData(erc721Token.address, makerAssetId)
+ .slice(0, -2);
+ signedOrder = orderFactory.newSignedOrder({
+ makerAssetAmount: new BigNumber(1),
+ takerAssetAmount: new BigNumber(1),
+ makerAssetData,
+ takerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
+ });
+ // Verify pre-conditions
+ const initialOwnerMakerAsset = await erc721Token.ownerOf.callAsync(makerAssetId);
+ expect(initialOwnerMakerAsset).to.be.bignumber.equal(makerAddress);
+ const initialOwnerTakerAsset = await erc721Token.ownerOf.callAsync(takerAssetId);
+ expect(initialOwnerTakerAsset).to.be.bignumber.equal(takerAddress);
+ // Call Exchange
+ const takerAssetFillAmount = signedOrder.takerAssetAmount;
+ return expectRevertReasonOrAlwaysFailingTransactionAsync(
+ exchangeWrapper.fillOrderAsync(signedOrder, takerAddress, { takerAssetFillAmount }),
+ RevertReason.LengthGreaterThan131Required,
+ );
+ });
});
});
// tslint:disable:max-file-line-count