aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-06-02 05:17:13 +0800
committerGreg Hysen <greg.hysen@gmail.com>2018-06-08 06:38:48 +0800
commite4e36760952287a84f8991df8589c183036383db (patch)
tree83c5ba694848232f6d3b01a72dc8c3d94cb9d071 /packages/contracts/test
parent3ed13150e106c19563c8e9b06621be3d44d66b6c (diff)
downloaddexon-0x-contracts-e4e36760952287a84f8991df8589c183036383db.tar.gz
dexon-0x-contracts-e4e36760952287a84f8991df8589c183036383db.tar.zst
dexon-0x-contracts-e4e36760952287a84f8991df8589c183036383db.zip
Fixed up after rebasing. Contracts build and tests pass
Diffstat (limited to 'packages/contracts/test')
-rw-r--r--packages/contracts/test/asset_proxy/decoder.ts9
-rw-r--r--packages/contracts/test/asset_proxy/proxies.ts33
-rw-r--r--packages/contracts/test/exchange/core.ts4
-rw-r--r--packages/contracts/test/exchange/transactions.ts4
-rw-r--r--packages/contracts/test/libraries/lib_bytes.ts5
5 files changed, 21 insertions, 34 deletions
diff --git a/packages/contracts/test/asset_proxy/decoder.ts b/packages/contracts/test/asset_proxy/decoder.ts
index e395c04c1..6336f69ae 100644
--- a/packages/contracts/test/asset_proxy/decoder.ts
+++ b/packages/contracts/test/asset_proxy/decoder.ts
@@ -1,9 +1,10 @@
-import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs, ZeroEx } from '0x.js';
import { BlockchainLifecycle, devConstants, web3Factory } from '@0xproject/dev-utils';
+import { generatePseudoRandomSalt } from '@0xproject/order-utils';
import { BigNumber } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import BN = require('bn.js');
import * as chai from 'chai';
+import { LogWithDecodedArgs, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
import * as Web3 from 'web3';
@@ -57,7 +58,7 @@ describe('TestAssetDataDecoders', () => {
});
it('should correctly decode ERC721 asset data', async () => {
- const tokenId = ZeroEx.generatePseudoRandomSalt();
+ const tokenId = generatePseudoRandomSalt();
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(testAddress, tokenId);
const expectedDecodedAssetData = assetProxyUtils.decodeERC721AssetData(encodedAssetData);
let decodedAssetProxyId: number;
@@ -77,9 +78,9 @@ describe('TestAssetDataDecoders', () => {
});
it('should correctly decode ERC721 asset data with receiver data', async () => {
- const tokenId = ZeroEx.generatePseudoRandomSalt();
+ const tokenId = generatePseudoRandomSalt();
const receiverData =
- ethUtil.bufferToHex(assetProxyUtils.encodeUint256(ZeroEx.generatePseudoRandomSalt())) + 'FFFF';
+ ethUtil.bufferToHex(assetProxyUtils.encodeUint256(generatePseudoRandomSalt())) + 'FFFF';
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(testAddress, tokenId, receiverData);
const expectedDecodedAssetData = assetProxyUtils.decodeERC721AssetData(encodedAssetData);
let decodedAssetProxyId: number;
diff --git a/packages/contracts/test/asset_proxy/proxies.ts b/packages/contracts/test/asset_proxy/proxies.ts
index e8c598935..6dc652383 100644
--- a/packages/contracts/test/asset_proxy/proxies.ts
+++ b/packages/contracts/test/asset_proxy/proxies.ts
@@ -1,8 +1,10 @@
-import { LogWithDecodedArgs, ZeroEx } from '0x.js';
import { BlockchainLifecycle } from '@0xproject/dev-utils';
import { assetProxyUtils } from '@0xproject/order-utils';
+import { generatePseudoRandomSalt } from '@0xproject/order-utils';
+import { AssetProxyId } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import * as chai from 'chai';
+import { LogWithDecodedArgs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
@@ -82,20 +84,11 @@ describe('Asset Transfer Proxies', () => {
}),
constants.AWAIT_TRANSACTION_MINED_MS,
);
-
- await erc721Proxy.addAuthorizedAddress.sendTransactionAsync(exchangeAddress, {
- from: owner,
- });
-
erc721Receiver = await DummyERC721ReceiverContract.deployFrom0xArtifactAsync(
artifacts.DummyERC721Receiver,
provider,
txDefaults,
);
-
- zeroEx = new ZeroEx(provider, {
- networkId: constants.TESTRPC_NETWORK_ID,
- });
});
beforeEach(async () => {
await blockchainLifecycle.startAsync();
@@ -298,10 +291,8 @@ describe('Asset Transfer Proxies', () => {
);
// Parse transaction logs
- const tx = await zeroEx.awaitTransactionMinedAsync(txHash);
- tx.logs = _.filter(tx.logs, log => log.address === erc721Receiver.address);
- const logDecoder = new LogDecoder(constants.TESTRPC_NETWORK_ID);
- tx.logs = _.map(tx.logs, log => logDecoder.decodeLogOrThrow(log));
+ const logDecoder = new LogDecoder(web3Wrapper, erc721Receiver.address);
+ const tx = await logDecoder.getTxWithDecodedLogsAsync(txHash);
// Verify that no log was emitted by erc721 receiver
expect(tx.logs.length).to.be.equal(0);
// Verify transfer was successful
@@ -311,9 +302,7 @@ describe('Asset Transfer Proxies', () => {
it('should call onERC721Received when transferring to a smart contract with receiver data', async () => {
// Construct ERC721 asset data
- const receiverData = ethUtil.bufferToHex(
- assetProxyUtils.encodeUint256(ZeroEx.generatePseudoRandomSalt()),
- );
+ const receiverData = ethUtil.bufferToHex(assetProxyUtils.encodeUint256(generatePseudoRandomSalt()));
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(
erc721Token.address,
erc721MakerTokenId,
@@ -333,10 +322,8 @@ describe('Asset Transfer Proxies', () => {
{ from: exchangeAddress },
);
// Parse transaction logs
- const tx = await zeroEx.awaitTransactionMinedAsync(txHash);
- tx.logs = _.filter(tx.logs, log => log.address === erc721Receiver.address);
- const logDecoder = new LogDecoder(constants.TESTRPC_NETWORK_ID);
- tx.logs = _.map(tx.logs, log => logDecoder.decodeLogOrThrow(log));
+ const logDecoder = new LogDecoder(web3Wrapper, erc721Receiver.address);
+ const tx = await logDecoder.getTxWithDecodedLogsAsync(txHash);
// Validate log emitted by erc721 receiver
expect(tx.logs.length).to.be.equal(1);
const tokenReceivedLog = tx.logs[0] as LogWithDecodedArgs<TokenReceivedContractEventArgs>;
@@ -350,9 +337,7 @@ describe('Asset Transfer Proxies', () => {
it('should throw if there is receiver data but contract does not have onERC721Received', async () => {
// Construct ERC721 asset data
- const receiverData = ethUtil.bufferToHex(
- assetProxyUtils.encodeUint256(ZeroEx.generatePseudoRandomSalt()),
- );
+ const receiverData = ethUtil.bufferToHex(assetProxyUtils.encodeUint256(generatePseudoRandomSalt()));
const encodedAssetData = assetProxyUtils.encodeERC721AssetData(
erc721Token.address,
erc721MakerTokenId,
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 8d3c3a940..53b98c755 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -845,7 +845,7 @@ describe('Exchange core', () => {
const makerAssetId = erc721MakerAssetIds[0];
signedOrder = orderFactory.newSignedOrder({
makerAssetAmount: new BigNumber(1),
- takerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ takerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
makerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, makerAssetId),
takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultTakerAssetAddress),
});
@@ -885,7 +885,7 @@ describe('Exchange core', () => {
const takerAssetId = erc721TakerAssetIds[0];
signedOrder = orderFactory.newSignedOrder({
takerAssetAmount: new BigNumber(1),
- makerAssetAmount: ZeroEx.toBaseUnitAmount(new BigNumber(100), 18),
+ makerAssetAmount: Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18),
takerAssetData: assetProxyUtils.encodeERC721AssetData(erc721Token.address, takerAssetId),
makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultMakerAssetAddress),
});
diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts
index 8c5bc7bec..12390ce01 100644
--- a/packages/contracts/test/exchange/transactions.ts
+++ b/packages/contracts/test/exchange/transactions.ts
@@ -224,8 +224,8 @@ describe('Exchange transactions', () => {
exchangeAddress: exchange.address,
makerAddress,
feeRecipientAddress,
- makerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultMakerTokenAddress),
- takerAssetData: assetProxyUtils.encodeERC20ProxyData(defaultTakerTokenAddress),
+ makerAssetData: assetProxyUtils.encodeERC20AssetData(defaultMakerTokenAddress),
+ takerAssetData: assetProxyUtils.encodeERC20AssetData(defaultTakerTokenAddress),
};
whitelistOrderFactory = new OrderFactory(makerPrivateKey, defaultOrderParams);
});
diff --git a/packages/contracts/test/libraries/lib_bytes.ts b/packages/contracts/test/libraries/lib_bytes.ts
index 9fe3a1a57..1a23483ba 100644
--- a/packages/contracts/test/libraries/lib_bytes.ts
+++ b/packages/contracts/test/libraries/lib_bytes.ts
@@ -1,4 +1,6 @@
import { BlockchainLifecycle } from '@0xproject/dev-utils';
+import { generatePseudoRandomSalt } from '@0xproject/order-utils';
+import { AssetProxyId } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import BN = require('bn.js');
import * as chai from 'chai';
@@ -66,7 +68,7 @@ describe('LibBytes', () => {
shortTestBytesAsBuffer = Buffer.concat([encodedShortDataLength, encodedShortData]);
shortTestBytes = ethUtil.bufferToHex(shortTestBytesAsBuffer);
// Create test bytes one word in length
- wordOfData = ethUtil.bufferToHex(assetProxyUtils.encodeUint256(ZeroEx.generatePseudoRandomSalt()));
+ wordOfData = ethUtil.bufferToHex(assetProxyUtils.encodeUint256(generatePseudoRandomSalt()));
const encodedWordOfData = ethUtil.toBuffer(wordOfData);
const wordOfDataLength = new BigNumber(encodedWordOfData.byteLength);
const encodedWordOfDataLength = assetProxyUtils.encodeUint256(wordOfDataLength);
@@ -315,7 +317,6 @@ describe('LibBytes', () => {
});
*/
-=======
describe('readFirst4', () => {
// AssertionError: expected promise to be rejected with an error including 'revert' but it was fulfilled with '0x08c379a0'
it('should revert if byte array has a length < 4', async () => {