aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/asset_proxy/proxies.ts
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/asset_proxy/proxies.ts
parent375d667144e26253f8ff6b0ad1beb45d5b3ef228 (diff)
parent84bd54ba4025a33f4e311ec66d81d58b45e54d6b (diff)
downloaddexon-0x-contracts-c308359f59cc24510ff3d42ae777226a599db376.tar.gz
dexon-0x-contracts-c308359f59cc24510ff3d42ae777226a599db376.tar.zst
dexon-0x-contracts-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/asset_proxy/proxies.ts')
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts119
1 files changed, 3 insertions, 116 deletions
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index 869ba4b2a..6303a50fa 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -5,7 +5,6 @@ import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
-import * as _ from 'lodash';
import { DummyERC20TokenContract } from '../../src/generated_contract_wrappers/dummy_e_r_c20_token';
import {
@@ -16,10 +15,7 @@ import { DummyERC721TokenContract } from '../../src/generated_contract_wrappers/
import { ERC20ProxyContract } from '../../src/generated_contract_wrappers/e_r_c20_proxy';
import { ERC721ProxyContract } from '../../src/generated_contract_wrappers/e_r_c721_proxy';
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';
@@ -192,58 +188,6 @@ describe('Asset Transfer Proxies', () => {
});
});
- describe('batchTransferFrom ERC20', () => {
- it('should succesfully make multiple token transfers', async () => {
- const erc20Balances = await erc20Wrapper.getBalancesAsync();
-
- const encodedAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
- const amount = new BigNumber(10);
- const numTransfers = 2;
- const assetData = _.times(numTransfers, () => encodedAssetData);
- const fromAddresses = _.times(numTransfers, () => makerAddress);
- const toAddresses = _.times(numTransfers, () => takerAddress);
- const amounts = _.times(numTransfers, () => amount);
-
- const txHash = await erc20Proxy.batchTransferFrom.sendTransactionAsync(
- assetData,
- fromAddresses,
- toAddresses,
- amounts,
- { from: exchangeAddress },
- );
- const res = await web3Wrapper.awaitTransactionSuccessAsync(
- txHash,
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- const newBalances = await erc20Wrapper.getBalancesAsync();
-
- expect(res.logs.length).to.equal(numTransfers);
- expect(newBalances[makerAddress][zrxToken.address]).to.be.bignumber.equal(
- erc20Balances[makerAddress][zrxToken.address].minus(amount.times(numTransfers)),
- );
- expect(newBalances[takerAddress][zrxToken.address]).to.be.bignumber.equal(
- erc20Balances[takerAddress][zrxToken.address].add(amount.times(numTransfers)),
- );
- });
-
- it('should throw if not called by an authorized address', async () => {
- const encodedAssetData = assetProxyUtils.encodeERC20AssetData(zrxToken.address);
- const amount = new BigNumber(10);
- const numTransfers = 2;
- const assetData = _.times(numTransfers, () => encodedAssetData);
- const fromAddresses = _.times(numTransfers, () => makerAddress);
- const toAddresses = _.times(numTransfers, () => takerAddress);
- const amounts = _.times(numTransfers, () => amount);
-
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- erc20Proxy.batchTransferFrom.sendTransactionAsync(assetData, fromAddresses, toAddresses, amounts, {
- from: notAuthorized,
- }),
- RevertReason.SenderNotAuthorized,
- );
- });
- });
-
it('should have an id of 0xf47261b0', async () => {
const proxyId = await erc20Proxy.getProxyId.callAsync();
const expectedProxyId = '0xf47261b0';
@@ -354,7 +298,7 @@ describe('Asset Transfer Proxies', () => {
expect(ownerMakerAsset).to.be.bignumber.equal(makerAddress);
// Perform a transfer from makerAddress to takerAddress
const amount = new BigNumber(1);
- return expectRevertOrAlwaysFailingTransactionAsync(
+ return expectRevertReasonOrAlwaysFailingTransactionAsync(
erc721Proxy.transferFrom.sendTransactionAsync(
encodedAssetData,
makerAddress,
@@ -362,6 +306,7 @@ describe('Asset Transfer Proxies', () => {
amount,
{ from: exchangeAddress },
),
+ RevertReason.TransferFailed,
);
});
@@ -443,64 +388,6 @@ describe('Asset Transfer Proxies', () => {
});
});
- describe('batchTransferFrom ERC721', () => {
- it('should succesfully make multiple token transfers', async () => {
- const erc721TokensById = await erc721Wrapper.getBalancesAsync();
- const [makerTokenIdA, makerTokenIdB] = erc721TokensById[makerAddress][erc721Token.address];
-
- const numTransfers = 2;
- const assetData = [
- assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerTokenIdA),
- assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerTokenIdB),
- ];
- const fromAddresses = _.times(numTransfers, () => makerAddress);
- const toAddresses = _.times(numTransfers, () => takerAddress);
- const amounts = _.times(numTransfers, () => new BigNumber(1));
-
- const txHash = await erc721Proxy.batchTransferFrom.sendTransactionAsync(
- assetData,
- fromAddresses,
- toAddresses,
- amounts,
- { from: exchangeAddress },
- );
- const res = await web3Wrapper.awaitTransactionSuccessAsync(
- txHash,
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- // During an ERC721 transfer enabled by a specific token approval,
- // the approval is cleared, emitting an event
- const numApprovals = 2;
- expect(res.logs.length).to.equal(numTransfers + numApprovals);
-
- const newOwnerMakerAssetA = await erc721Token.ownerOf.callAsync(makerTokenIdA);
- const newOwnerMakerAssetB = await erc721Token.ownerOf.callAsync(makerTokenIdB);
- expect(newOwnerMakerAssetA).to.be.bignumber.equal(takerAddress);
- expect(newOwnerMakerAssetB).to.be.bignumber.equal(takerAddress);
- });
-
- it('should throw if not called by an authorized address', async () => {
- const erc721TokensById = await erc721Wrapper.getBalancesAsync();
- const [makerTokenIdA, makerTokenIdB] = erc721TokensById[makerAddress][erc721Token.address];
-
- const numTransfers = 2;
- const assetData = [
- assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerTokenIdA).slice(0, -2),
- assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerTokenIdB).slice(0, -2),
- ];
- const fromAddresses = _.times(numTransfers, () => makerAddress);
- const toAddresses = _.times(numTransfers, () => takerAddress);
- const amounts = _.times(numTransfers, () => new BigNumber(1));
-
- return expectRevertReasonOrAlwaysFailingTransactionAsync(
- erc721Proxy.batchTransferFrom.sendTransactionAsync(assetData, fromAddresses, toAddresses, amounts, {
- from: notAuthorized,
- }),
- RevertReason.SenderNotAuthorized,
- );
- });
- });
-
it('should have an id of 0x08e937fa', async () => {
const proxyId = await erc721Proxy.getProxyId.callAsync();
const expectedProxyId = '0x08e937fa';