aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-06-27 03:23:00 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-06-27 04:57:51 +0800
commit08ee1ab2e636099344cade1c8bff67e9b3da2bb4 (patch)
tree959483746372fddea09e74075ecdab58a0b98a73 /packages/contracts/test
parent873ec898d82f24ed4d9c46ce3f62b52bab31ff90 (diff)
downloaddexon-0x-contracts-08ee1ab2e636099344cade1c8bff67e9b3da2bb4.tar.gz
dexon-0x-contracts-08ee1ab2e636099344cade1c8bff67e9b3da2bb4.tar.zst
dexon-0x-contracts-08ee1ab2e636099344cade1c8bff67e9b3da2bb4.zip
Remove redundant files, hard code function selector in dispatchTransferFrom, and modify revert reason
Diffstat (limited to 'packages/contracts/test')
-rw-r--r--packages/contracts/test/asset_proxy/decoder.ts84
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts108
2 files changed, 0 insertions, 192 deletions
diff --git a/packages/contracts/test/asset_proxy/decoder.ts b/packages/contracts/test/asset_proxy/decoder.ts
deleted file mode 100644
index 902255caf..000000000
--- a/packages/contracts/test/asset_proxy/decoder.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-import { BlockchainLifecycle } from '@0xproject/dev-utils';
-import { assetProxyUtils, generatePseudoRandomSalt } from '@0xproject/order-utils';
-import { BigNumber } from '@0xproject/utils';
-import * as chai from 'chai';
-import ethUtil = require('ethereumjs-util');
-
-import { TestAssetDataDecodersContract } from '../../src/generated_contract_wrappers/test_asset_data_decoders';
-import { artifacts } from '../../src/utils/artifacts';
-import { chaiSetup } from '../../src/utils/chai_setup';
-import { provider, txDefaults, web3Wrapper } from '../../src/utils/web3_wrapper';
-
-chaiSetup.configure();
-const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
-
-describe('TestAssetDataDecoders', () => {
- let testAssetProxyDecoder: TestAssetDataDecodersContract;
- let testAddress: string;
-
- before(async () => {
- await blockchainLifecycle.startAsync();
- });
- after(async () => {
- await blockchainLifecycle.revertAsync();
- });
- before(async () => {
- // Setup accounts & addresses
- const accounts = await web3Wrapper.getAvailableAddressesAsync();
- testAddress = accounts[0];
- testAssetProxyDecoder = await TestAssetDataDecodersContract.deployFrom0xArtifactAsync(
- artifacts.TestAssetDataDecoders,
- provider,
- txDefaults,
- );
- });
- beforeEach(async () => {
- await blockchainLifecycle.startAsync();
- });
- afterEach(async () => {
- await blockchainLifecycle.revertAsync();
- });
-
- describe('Asset Data Decoders', () => {
- it('should correctly decode ERC721 asset data', async () => {
- const tokenId = generatePseudoRandomSalt();
- const encodedAssetData = assetProxyUtils.encodeERC721AssetData(testAddress, tokenId);
- const expectedDecodedAssetData = assetProxyUtils.decodeERC721AssetData(encodedAssetData);
- let decodedTokenAddress: string;
- let decodedTokenId: BigNumber;
- let decodedData: string;
- [
- decodedTokenAddress,
- decodedTokenId,
- decodedData,
- ] = await testAssetProxyDecoder.publicDecodeERC721Data.callAsync(encodedAssetData);
- expect(decodedTokenAddress).to.be.equal(expectedDecodedAssetData.tokenAddress);
- expect(decodedTokenId).to.be.bignumber.equal(expectedDecodedAssetData.tokenId);
- expect(decodedData).to.be.equal(expectedDecodedAssetData.receiverData);
- });
-
- it('should correctly decode ERC721 asset data with receiver data', async () => {
- const tokenId = generatePseudoRandomSalt();
- const receiverDataFirst32Bytes = ethUtil.bufferToHex(
- assetProxyUtils.encodeUint256(generatePseudoRandomSalt()),
- );
- const receiverDataExtraBytes = 'FFFF';
- // We add extra bytes to generate a value that doesn't fit perfectly into one word
- const receiverData = receiverDataFirst32Bytes + receiverDataExtraBytes;
- const encodedAssetData = assetProxyUtils.encodeERC721AssetData(testAddress, tokenId, receiverData);
- const expectedDecodedAssetData = assetProxyUtils.decodeERC721AssetData(encodedAssetData);
- let decodedTokenAddress: string;
- let decodedTokenId: BigNumber;
- let decodedReceiverData: string;
- [
- decodedTokenAddress,
- decodedTokenId,
- decodedReceiverData,
- ] = await testAssetProxyDecoder.publicDecodeERC721Data.callAsync(encodedAssetData);
- expect(decodedTokenAddress).to.be.equal(expectedDecodedAssetData.tokenAddress);
- expect(decodedTokenId).to.be.bignumber.equal(expectedDecodedAssetData.tokenId);
- expect(decodedReceiverData).to.be.equal(expectedDecodedAssetData.receiverData);
- });
- });
-});
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index 7960e46d2..5a5289508 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 {
@@ -189,58 +188,6 @@ describe('Asset Transfer Proxies', () => {
});
});
- describe('batchTransferFrom', () => {
- 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';
@@ -440,61 +387,6 @@ describe('Asset Transfer Proxies', () => {
});
});
- describe('batchTransferFrom', () => {
- 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,
- );
- expect(res.logs.length).to.equal(numTransfers);
-
- 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';