aboutsummaryrefslogtreecommitdiffstats
path: root/contracts/core/test
diff options
context:
space:
mode:
Diffstat (limited to 'contracts/core/test')
-rw-r--r--contracts/core/test/asset_proxy/proxies.ts21
-rw-r--r--contracts/core/test/exchange/core.ts16
-rw-r--r--contracts/core/test/exchange/dispatcher.ts2
-rw-r--r--contracts/core/test/exchange/match_orders.ts11
-rw-r--r--contracts/core/test/exchange/signature_validator.ts13
-rw-r--r--contracts/core/test/exchange/transactions.ts2
-rw-r--r--contracts/core/test/exchange/wrapper.ts11
-rw-r--r--contracts/core/test/extensions/dutch_auction.ts11
-rw-r--r--contracts/core/test/extensions/forwarder.ts11
-rw-r--r--contracts/core/test/extensions/order_validator.ts3
-rw-r--r--contracts/core/test/tokens/erc721_token.ts284
-rw-r--r--contracts/core/test/tokens/unlimited_allowance_token.ts195
-rw-r--r--contracts/core/test/tokens/weth9.ts143
-rw-r--r--contracts/core/test/tokens/zrx_token.ts204
-rw-r--r--contracts/core/test/utils/asset_proxy_owner_wrapper.ts3
-rw-r--r--contracts/core/test/utils/erc20_wrapper.ts4
-rw-r--r--contracts/core/test/utils/erc721_wrapper.ts4
-rw-r--r--contracts/core/test/utils/exchange_wrapper.ts3
-rw-r--r--contracts/core/test/utils/forwarder_wrapper.ts3
-rw-r--r--contracts/core/test/utils/order_factory_from_scenario.ts3
20 files changed, 71 insertions, 876 deletions
diff --git a/contracts/core/test/asset_proxy/proxies.ts b/contracts/core/test/asset_proxy/proxies.ts
index faa643924..c4bd95905 100644
--- a/contracts/core/test/asset_proxy/proxies.ts
+++ b/contracts/core/test/asset_proxy/proxies.ts
@@ -9,6 +9,14 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
+import {
+ artifacts as tokensArtifacts,
+ DummyERC20TokenContract,
+ DummyERC721ReceiverContract,
+ DummyERC721TokenContract,
+ DummyMultipleReturnERC20TokenContract,
+ DummyNoReturnERC20TokenContract,
+} from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { RevertReason } from '@0x/types';
@@ -16,11 +24,6 @@ import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
-import { DummyERC721ReceiverContract } from '../../generated-wrappers/dummy_erc721_receiver';
-import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
-import { DummyMultipleReturnERC20TokenContract } from '../../generated-wrappers/dummy_multiple_return_erc20_token';
-import { DummyNoReturnERC20TokenContract } from '../../generated-wrappers/dummy_no_return_erc20_token';
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
import { MultiAssetProxyContract } from '../../generated-wrappers/multi_asset_proxy';
@@ -143,7 +146,7 @@ describe('Asset Transfer Proxies', () => {
constants.DUMMY_TOKEN_DECIMALS,
);
noReturnErc20Token = await DummyNoReturnERC20TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyNoReturnERC20Token,
+ tokensArtifacts.DummyNoReturnERC20Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
@@ -152,7 +155,7 @@ describe('Asset Transfer Proxies', () => {
constants.DUMMY_TOKEN_TOTAL_SUPPLY,
);
multipleReturnErc20Token = await DummyMultipleReturnERC20TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyMultipleReturnERC20Token,
+ tokensArtifacts.DummyMultipleReturnERC20Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
@@ -193,7 +196,7 @@ describe('Asset Transfer Proxies', () => {
// Deploy and configure ERC721 tokens and receiver
[erc721TokenA, erc721TokenB] = await erc721Wrapper.deployDummyTokensAsync();
erc721Receiver = await DummyERC721ReceiverContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC721Receiver,
+ tokensArtifacts.DummyERC721Receiver,
provider,
txDefaults,
);
@@ -557,7 +560,7 @@ describe('Asset Transfer Proxies', () => {
erc721Receiver.address,
amount,
);
- const logDecoder = new LogDecoder(web3Wrapper, artifacts);
+ const logDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...tokensArtifacts });
const tx = await logDecoder.getTxWithDecodedLogsAsync(
await web3Wrapper.sendTransactionAsync({
to: erc721Proxy.address,
diff --git a/contracts/core/test/exchange/core.ts b/contracts/core/test/exchange/core.ts
index 45eae0f22..9b948f991 100644
--- a/contracts/core/test/exchange/core.ts
+++ b/contracts/core/test/exchange/core.ts
@@ -12,6 +12,14 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
+import {
+ artifacts as tokensArtifacts,
+ DummyERC20TokenContract,
+ DummyERC20TokenTransferEventArgs,
+ DummyERC721TokenContract,
+ DummyNoReturnERC20TokenContract,
+ ReentrantERC20TokenContract,
+} from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
import { RevertReason, SignatureType, SignedOrder } from '@0x/types';
@@ -22,14 +30,10 @@ import { LogWithDecodedArgs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
-import { DummyERC20TokenContract, DummyERC20TokenTransferEventArgs } from '../../generated-wrappers/dummy_erc20_token';
-import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
-import { DummyNoReturnERC20TokenContract } from '../../generated-wrappers/dummy_no_return_erc20_token';
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
import { ExchangeCancelEventArgs, ExchangeContract } from '../../generated-wrappers/exchange';
import { MultiAssetProxyContract } from '../../generated-wrappers/multi_asset_proxy';
-import { ReentrantERC20TokenContract } from '../../generated-wrappers/reentrant_erc20_token';
import { TestStaticCallReceiverContract } from '../../generated-wrappers/test_static_call_receiver';
import { artifacts } from '../../src/artifacts';
import { ERC20Wrapper } from '../utils/erc20_wrapper';
@@ -116,7 +120,7 @@ describe('Exchange core', () => {
txDefaults,
);
reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync(
- artifacts.ReentrantERC20Token,
+ tokensArtifacts.ReentrantERC20Token,
provider,
txDefaults,
exchange.address,
@@ -341,7 +345,7 @@ describe('Exchange core', () => {
describe('Testing exchange of ERC20 tokens with no return values', () => {
before(async () => {
noReturnErc20Token = await DummyNoReturnERC20TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyNoReturnERC20Token,
+ tokensArtifacts.DummyNoReturnERC20Token,
provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
diff --git a/contracts/core/test/exchange/dispatcher.ts b/contracts/core/test/exchange/dispatcher.ts
index 9bc5cbcce..5b1ac1e20 100644
--- a/contracts/core/test/exchange/dispatcher.ts
+++ b/contracts/core/test/exchange/dispatcher.ts
@@ -7,6 +7,7 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
+import { DummyERC20TokenContract } from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { AssetProxyId, RevertReason } from '@0x/types';
@@ -15,7 +16,6 @@ import * as chai from 'chai';
import { LogWithDecodedArgs } from 'ethereum-types';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
import {
diff --git a/contracts/core/test/exchange/match_orders.ts b/contracts/core/test/exchange/match_orders.ts
index 0e841b359..8e943c237 100644
--- a/contracts/core/test/exchange/match_orders.ts
+++ b/contracts/core/test/exchange/match_orders.ts
@@ -9,6 +9,12 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
+import {
+ artifacts as tokensArtifacts,
+ DummyERC20TokenContract,
+ DummyERC721TokenContract,
+ ReentrantERC20TokenContract,
+} from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { RevertReason } from '@0x/types';
@@ -17,12 +23,9 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
-import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
import { ExchangeContract } from '../../generated-wrappers/exchange';
-import { ReentrantERC20TokenContract } from '../../generated-wrappers/reentrant_erc20_token';
import { TestExchangeInternalsContract } from '../../generated-wrappers/test_exchange_internals';
import { artifacts } from '../../src/artifacts';
import { ERC20Wrapper } from '../utils/erc20_wrapper';
@@ -139,7 +142,7 @@ describe('matchOrders', () => {
);
reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync(
- artifacts.ReentrantERC20Token,
+ tokensArtifacts.ReentrantERC20Token,
provider,
txDefaults,
exchange.address,
diff --git a/contracts/core/test/exchange/signature_validator.ts b/contracts/core/test/exchange/signature_validator.ts
index b84a488a1..ae372d677 100644
--- a/contracts/core/test/exchange/signature_validator.ts
+++ b/contracts/core/test/exchange/signature_validator.ts
@@ -9,6 +9,7 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
+import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils, orderHashUtils, signatureUtils } from '@0x/order-utils';
import { RevertReason, SignatureType, SignedOrder } from '@0x/types';
@@ -17,13 +18,13 @@ import { LogWithDecodedArgs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
import {
+ artifacts,
TestSignatureValidatorContract,
TestSignatureValidatorSignatureValidatorApprovalEventArgs,
-} from '../../generated-wrappers/test_signature_validator';
-import { TestStaticCallReceiverContract } from '../../generated-wrappers/test_static_call_receiver';
-import { ValidatorContract } from '../../generated-wrappers/validator';
-import { WalletContract } from '../../generated-wrappers/wallet';
-import { artifacts } from '../../src/artifacts';
+ TestStaticCallReceiverContract,
+ ValidatorContract,
+ WalletContract,
+} from '../../src';
chaiSetup.configure();
const expect = chai.expect;
@@ -77,7 +78,7 @@ describe('MixinSignatureValidator', () => {
provider,
txDefaults,
);
- signatureValidatorLogDecoder = new LogDecoder(web3Wrapper, artifacts);
+ signatureValidatorLogDecoder = new LogDecoder(web3Wrapper, { ...artifacts, ...tokensArtifacts });
await web3Wrapper.awaitTransactionSuccessAsync(
await signatureValidator.setSignatureValidatorApproval.sendTransactionAsync(testValidator.address, true, {
from: signerAddress,
diff --git a/contracts/core/test/exchange/transactions.ts b/contracts/core/test/exchange/transactions.ts
index c4086d9be..ad0ca41c2 100644
--- a/contracts/core/test/exchange/transactions.ts
+++ b/contracts/core/test/exchange/transactions.ts
@@ -11,6 +11,7 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
+import { DummyERC20TokenContract } from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils';
import { OrderWithoutExchangeAddress, RevertReason, SignedOrder } from '@0x/types';
@@ -18,7 +19,6 @@ import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
import { ExchangeContract } from '../../generated-wrappers/exchange';
import { ExchangeWrapperContract } from '../../generated-wrappers/exchange_wrapper';
diff --git a/contracts/core/test/exchange/wrapper.ts b/contracts/core/test/exchange/wrapper.ts
index 17cb7a3bb..c9efb0c9d 100644
--- a/contracts/core/test/exchange/wrapper.ts
+++ b/contracts/core/test/exchange/wrapper.ts
@@ -11,6 +11,12 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
+import {
+ artifacts as tokensArtifacts,
+ DummyERC20TokenContract,
+ DummyERC721TokenContract,
+ ReentrantERC20TokenContract,
+} from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
import { RevertReason, SignedOrder } from '@0x/types';
@@ -19,12 +25,9 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
-import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
import { ExchangeContract } from '../../generated-wrappers/exchange';
-import { ReentrantERC20TokenContract } from '../../generated-wrappers/reentrant_erc20_token';
import { artifacts } from '../../src/artifacts';
import { ERC20Wrapper } from '../utils/erc20_wrapper';
import { ERC721Wrapper } from '../utils/erc721_wrapper';
@@ -113,7 +116,7 @@ describe('Exchange wrappers', () => {
);
reentrantErc20Token = await ReentrantERC20TokenContract.deployFrom0xArtifactAsync(
- artifacts.ReentrantERC20Token,
+ tokensArtifacts.ReentrantERC20Token,
provider,
txDefaults,
exchange.address,
diff --git a/contracts/core/test/extensions/dutch_auction.ts b/contracts/core/test/extensions/dutch_auction.ts
index 54e6092d7..b396d4206 100644
--- a/contracts/core/test/extensions/dutch_auction.ts
+++ b/contracts/core/test/extensions/dutch_auction.ts
@@ -10,6 +10,12 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
+import {
+ artifacts as tokensArtifacts,
+ DummyERC20TokenContract,
+ DummyERC721TokenContract,
+ WETH9Contract,
+} from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils';
import { RevertReason, SignedOrder } from '@0x/types';
@@ -20,11 +26,8 @@ import ethAbi = require('ethereumjs-abi');
import * as ethUtil from 'ethereumjs-util';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
-import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
import { DutchAuctionContract } from '../../generated-wrappers/dutch_auction';
import { ExchangeContract } from '../../generated-wrappers/exchange';
-import { WETH9Contract } from '../../generated-wrappers/weth9';
import { artifacts } from '../../src/artifacts';
import { ERC20Wrapper } from '../utils/erc20_wrapper';
import { ERC721Wrapper } from '../utils/erc721_wrapper';
@@ -98,7 +101,7 @@ describe(ContractName.DutchAuction, () => {
const erc721Balances = await erc721Wrapper.getBalancesAsync();
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
- wethContract = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults);
+ wethContract = await WETH9Contract.deployFrom0xArtifactAsync(tokensArtifacts.WETH9, provider, txDefaults);
erc20Wrapper.addDummyTokenContract(wethContract as any);
const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address);
diff --git a/contracts/core/test/extensions/forwarder.ts b/contracts/core/test/extensions/forwarder.ts
index 44ad4d6ff..ffa015dd2 100644
--- a/contracts/core/test/extensions/forwarder.ts
+++ b/contracts/core/test/extensions/forwarder.ts
@@ -11,6 +11,12 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
+import {
+ artifacts as tokenArtifacts,
+ DummyERC20TokenContract,
+ DummyERC721TokenContract,
+ WETH9Contract,
+} from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils } from '@0x/order-utils';
import { RevertReason, SignedOrder } from '@0x/types';
@@ -19,11 +25,8 @@ import { Web3Wrapper } from '@0x/web3-wrapper';
import * as chai from 'chai';
import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
-import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
-import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
import { ExchangeContract } from '../../generated-wrappers/exchange';
import { ForwarderContract } from '../../generated-wrappers/forwarder';
-import { WETH9Contract } from '../../generated-wrappers/weth9';
import { artifacts } from '../../src/artifacts';
import { ERC20Wrapper } from '../utils/erc20_wrapper';
import { ERC721Wrapper } from '../utils/erc721_wrapper';
@@ -94,7 +97,7 @@ describe(ContractName.Forwarder, () => {
const erc721Balances = await erc721Wrapper.getBalancesAsync();
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
- wethContract = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, txDefaults);
+ wethContract = await WETH9Contract.deployFrom0xArtifactAsync(tokenArtifacts.WETH9, provider, txDefaults);
weth = new DummyERC20TokenContract(wethContract.abi, wethContract.address, provider);
erc20Wrapper.addDummyTokenContract(weth);
diff --git a/contracts/core/test/extensions/order_validator.ts b/contracts/core/test/extensions/order_validator.ts
index 3dbe76f6e..622710c98 100644
--- a/contracts/core/test/extensions/order_validator.ts
+++ b/contracts/core/test/extensions/order_validator.ts
@@ -7,6 +7,7 @@ import {
txDefaults,
web3Wrapper,
} from '@0x/contracts-test-utils';
+import { DummyERC20TokenContract, DummyERC721TokenContract } from '@0x/contracts-tokens';
import { BlockchainLifecycle } from '@0x/dev-utils';
import { assetDataUtils, orderHashUtils } from '@0x/order-utils';
import { SignedOrder } from '@0x/types';
@@ -14,8 +15,6 @@ import { BigNumber } from '@0x/utils';
import * as chai from 'chai';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
-import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
import { ExchangeContract } from '../../generated-wrappers/exchange';
diff --git a/contracts/core/test/tokens/erc721_token.ts b/contracts/core/test/tokens/erc721_token.ts
deleted file mode 100644
index 3b0a5f001..000000000
--- a/contracts/core/test/tokens/erc721_token.ts
+++ /dev/null
@@ -1,284 +0,0 @@
-import {
- chaiSetup,
- constants,
- expectTransactionFailedAsync,
- expectTransactionFailedWithoutReasonAsync,
- LogDecoder,
- provider,
- txDefaults,
- web3Wrapper,
-} from '@0x/contracts-test-utils';
-import { BlockchainLifecycle } from '@0x/dev-utils';
-import { RevertReason } from '@0x/types';
-import { BigNumber } from '@0x/utils';
-import * as chai from 'chai';
-import { LogWithDecodedArgs } from 'ethereum-types';
-
-import {
- DummyERC721ReceiverContract,
- DummyERC721ReceiverTokenReceivedEventArgs,
-} from '../../generated-wrappers/dummy_erc721_receiver';
-import {
- DummyERC721TokenContract,
- DummyERC721TokenTransferEventArgs,
-} from '../../generated-wrappers/dummy_erc721_token';
-import { InvalidERC721ReceiverContract } from '../../generated-wrappers/invalid_erc721_receiver';
-import { artifacts } from '../../src/artifacts';
-
-chaiSetup.configure();
-const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
-// tslint:disable:no-unnecessary-type-assertion
-describe('ERC721Token', () => {
- let owner: string;
- let spender: string;
- let token: DummyERC721TokenContract;
- let erc721Receiver: DummyERC721ReceiverContract;
- let logDecoder: LogDecoder;
- const tokenId = new BigNumber(1);
- before(async () => {
- await blockchainLifecycle.startAsync();
- });
- after(async () => {
- await blockchainLifecycle.revertAsync();
- });
- before(async () => {
- const accounts = await web3Wrapper.getAvailableAddressesAsync();
- owner = accounts[0];
- spender = accounts[1];
- token = await DummyERC721TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC721Token,
- provider,
- txDefaults,
- constants.DUMMY_TOKEN_NAME,
- constants.DUMMY_TOKEN_SYMBOL,
- );
- erc721Receiver = await DummyERC721ReceiverContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC721Receiver,
- provider,
- txDefaults,
- );
- logDecoder = new LogDecoder(web3Wrapper, artifacts);
- await web3Wrapper.awaitTransactionSuccessAsync(
- await token.mint.sendTransactionAsync(owner, tokenId, { from: owner }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- });
- beforeEach(async () => {
- await blockchainLifecycle.startAsync();
- });
- afterEach(async () => {
- await blockchainLifecycle.revertAsync();
- });
-
- describe('transferFrom', () => {
- it('should revert if the tokenId is not owner', async () => {
- const from = owner;
- const to = erc721Receiver.address;
- const unownedTokenId = new BigNumber(2);
- await expectTransactionFailedAsync(
- token.transferFrom.sendTransactionAsync(from, to, unownedTokenId),
- RevertReason.Erc721ZeroOwner,
- );
- });
- it('should revert if transferring to a null address', async () => {
- const from = owner;
- const to = constants.NULL_ADDRESS;
- await expectTransactionFailedAsync(
- token.transferFrom.sendTransactionAsync(from, to, tokenId),
- RevertReason.Erc721ZeroToAddress,
- );
- });
- it('should revert if the from address does not own the token', async () => {
- const from = spender;
- const to = erc721Receiver.address;
- await expectTransactionFailedAsync(
- token.transferFrom.sendTransactionAsync(from, to, tokenId),
- RevertReason.Erc721OwnerMismatch,
- );
- });
- it('should revert if spender does not own the token, is not approved, and is not approved for all', async () => {
- const from = owner;
- const to = erc721Receiver.address;
- await expectTransactionFailedAsync(
- token.transferFrom.sendTransactionAsync(from, to, tokenId, { from: spender }),
- RevertReason.Erc721InvalidSpender,
- );
- });
- it('should transfer the token if called by owner', async () => {
- const from = owner;
- const to = erc721Receiver.address;
- const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
- await token.transferFrom.sendTransactionAsync(from, to, tokenId),
- );
- const newOwner = await token.ownerOf.callAsync(tokenId);
- expect(newOwner).to.be.equal(to);
- const log = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>;
- expect(log.args._from).to.be.equal(from);
- expect(log.args._to).to.be.equal(to);
- expect(log.args._tokenId).to.be.bignumber.equal(tokenId);
- });
- it('should transfer the token if spender is approved for all', async () => {
- const isApproved = true;
- await web3Wrapper.awaitTransactionSuccessAsync(
- await token.setApprovalForAll.sendTransactionAsync(spender, isApproved),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
-
- const from = owner;
- const to = erc721Receiver.address;
- const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
- await token.transferFrom.sendTransactionAsync(from, to, tokenId),
- );
- const newOwner = await token.ownerOf.callAsync(tokenId);
- expect(newOwner).to.be.equal(to);
- const log = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>;
- expect(log.args._from).to.be.equal(from);
- expect(log.args._to).to.be.equal(to);
- expect(log.args._tokenId).to.be.bignumber.equal(tokenId);
- });
- it('should transfer the token if spender is individually approved', async () => {
- await web3Wrapper.awaitTransactionSuccessAsync(
- await token.approve.sendTransactionAsync(spender, tokenId),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
-
- const from = owner;
- const to = erc721Receiver.address;
- const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
- await token.transferFrom.sendTransactionAsync(from, to, tokenId),
- );
- const newOwner = await token.ownerOf.callAsync(tokenId);
- expect(newOwner).to.be.equal(to);
-
- const approvedAddress = await token.getApproved.callAsync(tokenId);
- expect(approvedAddress).to.be.equal(constants.NULL_ADDRESS);
- const log = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>;
- expect(log.args._from).to.be.equal(from);
- expect(log.args._to).to.be.equal(to);
- expect(log.args._tokenId).to.be.bignumber.equal(tokenId);
- });
- });
- describe('safeTransferFrom without data', () => {
- it('should transfer token to a non-contract address if called by owner', async () => {
- const from = owner;
- const to = spender;
- const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
- await token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId),
- );
- const newOwner = await token.ownerOf.callAsync(tokenId);
- expect(newOwner).to.be.equal(to);
- const log = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>;
- expect(log.args._from).to.be.equal(from);
- expect(log.args._to).to.be.equal(to);
- expect(log.args._tokenId).to.be.bignumber.equal(tokenId);
- });
- it('should revert if transferring to a contract address without onERC721Received', async () => {
- const contract = await DummyERC721TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC721Token,
- provider,
- txDefaults,
- constants.DUMMY_TOKEN_NAME,
- constants.DUMMY_TOKEN_SYMBOL,
- );
- const from = owner;
- const to = contract.address;
- await expectTransactionFailedWithoutReasonAsync(
- token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId),
- );
- });
- it('should revert if onERC721Received does not return the correct value', async () => {
- const invalidErc721Receiver = await InvalidERC721ReceiverContract.deployFrom0xArtifactAsync(
- artifacts.InvalidERC721Receiver,
- provider,
- txDefaults,
- );
- const from = owner;
- const to = invalidErc721Receiver.address;
- await expectTransactionFailedAsync(
- token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId),
- RevertReason.Erc721InvalidSelector,
- );
- });
- it('should transfer to contract and call onERC721Received with correct return value', async () => {
- const from = owner;
- const to = erc721Receiver.address;
- const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
- await token.safeTransferFrom1.sendTransactionAsync(from, to, tokenId),
- );
- const newOwner = await token.ownerOf.callAsync(tokenId);
- expect(newOwner).to.be.equal(to);
- const transferLog = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>;
- const receiverLog = txReceipt.logs[1] as LogWithDecodedArgs<DummyERC721ReceiverTokenReceivedEventArgs>;
- expect(transferLog.args._from).to.be.equal(from);
- expect(transferLog.args._to).to.be.equal(to);
- expect(transferLog.args._tokenId).to.be.bignumber.equal(tokenId);
- expect(receiverLog.args.operator).to.be.equal(owner);
- expect(receiverLog.args.from).to.be.equal(from);
- expect(receiverLog.args.tokenId).to.be.bignumber.equal(tokenId);
- expect(receiverLog.args.data).to.be.equal(constants.NULL_BYTES);
- });
- });
- describe('safeTransferFrom with data', () => {
- const data = '0x0102030405060708090a0b0c0d0e0f';
- it('should transfer token to a non-contract address if called by owner', async () => {
- const from = owner;
- const to = spender;
- const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
- await token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data),
- );
- const newOwner = await token.ownerOf.callAsync(tokenId);
- expect(newOwner).to.be.equal(to);
- const log = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>;
- expect(log.args._from).to.be.equal(from);
- expect(log.args._to).to.be.equal(to);
- expect(log.args._tokenId).to.be.bignumber.equal(tokenId);
- });
- it('should revert if transferring to a contract address without onERC721Received', async () => {
- const contract = await DummyERC721TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC721Token,
- provider,
- txDefaults,
- constants.DUMMY_TOKEN_NAME,
- constants.DUMMY_TOKEN_SYMBOL,
- );
- const from = owner;
- const to = contract.address;
- await expectTransactionFailedWithoutReasonAsync(
- token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data),
- );
- });
- it('should revert if onERC721Received does not return the correct value', async () => {
- const invalidErc721Receiver = await InvalidERC721ReceiverContract.deployFrom0xArtifactAsync(
- artifacts.InvalidERC721Receiver,
- provider,
- txDefaults,
- );
- const from = owner;
- const to = invalidErc721Receiver.address;
- await expectTransactionFailedAsync(
- token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data),
- RevertReason.Erc721InvalidSelector,
- );
- });
- it('should transfer to contract and call onERC721Received with correct return value', async () => {
- const from = owner;
- const to = erc721Receiver.address;
- const txReceipt = await logDecoder.getTxWithDecodedLogsAsync(
- await token.safeTransferFrom2.sendTransactionAsync(from, to, tokenId, data),
- );
- const newOwner = await token.ownerOf.callAsync(tokenId);
- expect(newOwner).to.be.equal(to);
- const transferLog = txReceipt.logs[0] as LogWithDecodedArgs<DummyERC721TokenTransferEventArgs>;
- const receiverLog = txReceipt.logs[1] as LogWithDecodedArgs<DummyERC721ReceiverTokenReceivedEventArgs>;
- expect(transferLog.args._from).to.be.equal(from);
- expect(transferLog.args._to).to.be.equal(to);
- expect(transferLog.args._tokenId).to.be.bignumber.equal(tokenId);
- expect(receiverLog.args.operator).to.be.equal(owner);
- expect(receiverLog.args.from).to.be.equal(from);
- expect(receiverLog.args.tokenId).to.be.bignumber.equal(tokenId);
- expect(receiverLog.args.data).to.be.equal(data);
- });
- });
-});
-// tslint:enable:no-unnecessary-type-assertion
diff --git a/contracts/core/test/tokens/unlimited_allowance_token.ts b/contracts/core/test/tokens/unlimited_allowance_token.ts
deleted file mode 100644
index c3e4072c5..000000000
--- a/contracts/core/test/tokens/unlimited_allowance_token.ts
+++ /dev/null
@@ -1,195 +0,0 @@
-import {
- chaiSetup,
- constants,
- expectContractCallFailedAsync,
- provider,
- txDefaults,
- web3Wrapper,
-} from '@0x/contracts-test-utils';
-import { BlockchainLifecycle } from '@0x/dev-utils';
-import { RevertReason } from '@0x/types';
-import { BigNumber } from '@0x/utils';
-import * as chai from 'chai';
-
-import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
-import { artifacts } from '../../src/artifacts';
-
-chaiSetup.configure();
-const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
-
-describe('UnlimitedAllowanceToken', () => {
- let owner: string;
- let spender: string;
- const MAX_MINT_VALUE = new BigNumber(10000000000000000000000);
- let token: DummyERC20TokenContract;
-
- before(async () => {
- await blockchainLifecycle.startAsync();
- });
- after(async () => {
- await blockchainLifecycle.revertAsync();
- });
- before(async () => {
- const accounts = await web3Wrapper.getAvailableAddressesAsync();
- owner = accounts[0];
- spender = accounts[1];
- token = await DummyERC20TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC20Token,
- provider,
- txDefaults,
- constants.DUMMY_TOKEN_NAME,
- constants.DUMMY_TOKEN_SYMBOL,
- constants.DUMMY_TOKEN_DECIMALS,
- constants.DUMMY_TOKEN_TOTAL_SUPPLY,
- );
- await web3Wrapper.awaitTransactionSuccessAsync(
- await token.mint.sendTransactionAsync(MAX_MINT_VALUE, { from: owner }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- });
- beforeEach(async () => {
- await blockchainLifecycle.startAsync();
- });
- afterEach(async () => {
- await blockchainLifecycle.revertAsync();
- });
- describe('transfer', () => {
- it('should throw if owner has insufficient balance', async () => {
- const ownerBalance = await token.balanceOf.callAsync(owner);
- const amountToTransfer = ownerBalance.plus(1);
- return expectContractCallFailedAsync(
- token.transfer.callAsync(spender, amountToTransfer, { from: owner }),
- RevertReason.Erc20InsufficientBalance,
- );
- });
-
- it('should transfer balance from sender to receiver', async () => {
- const receiver = spender;
- const initOwnerBalance = await token.balanceOf.callAsync(owner);
- const amountToTransfer = new BigNumber(1);
- await web3Wrapper.awaitTransactionSuccessAsync(
- await token.transfer.sendTransactionAsync(receiver, amountToTransfer, { from: owner }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- const finalOwnerBalance = await token.balanceOf.callAsync(owner);
- const finalReceiverBalance = await token.balanceOf.callAsync(receiver);
-
- const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer);
- const expectedFinalReceiverBalance = amountToTransfer;
- expect(finalOwnerBalance).to.be.bignumber.equal(expectedFinalOwnerBalance);
- expect(finalReceiverBalance).to.be.bignumber.equal(expectedFinalReceiverBalance);
- });
-
- it('should return true on a 0 value transfer', async () => {
- const didReturnTrue = await token.transfer.callAsync(spender, new BigNumber(0), {
- from: owner,
- });
- expect(didReturnTrue).to.be.true();
- });
- });
-
- describe('transferFrom', () => {
- it('should throw if owner has insufficient balance', async () => {
- const ownerBalance = await token.balanceOf.callAsync(owner);
- const amountToTransfer = ownerBalance.plus(1);
- await web3Wrapper.awaitTransactionSuccessAsync(
- await token.approve.sendTransactionAsync(spender, amountToTransfer, { from: owner }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- return expectContractCallFailedAsync(
- token.transferFrom.callAsync(owner, spender, amountToTransfer, {
- from: spender,
- }),
- RevertReason.Erc20InsufficientBalance,
- );
- });
-
- it('should throw if spender has insufficient allowance', async () => {
- const ownerBalance = await token.balanceOf.callAsync(owner);
- const amountToTransfer = ownerBalance;
-
- const spenderAllowance = await token.allowance.callAsync(owner, spender);
- const isSpenderAllowanceInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
- expect(isSpenderAllowanceInsufficient).to.be.true();
-
- return expectContractCallFailedAsync(
- token.transferFrom.callAsync(owner, spender, amountToTransfer, {
- from: spender,
- }),
- RevertReason.Erc20InsufficientAllowance,
- );
- });
-
- it('should return true on a 0 value transfer', async () => {
- const amountToTransfer = new BigNumber(0);
- const didReturnTrue = await token.transferFrom.callAsync(owner, spender, amountToTransfer, {
- from: spender,
- });
- expect(didReturnTrue).to.be.true();
- });
-
- it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => {
- const initOwnerBalance = await token.balanceOf.callAsync(owner);
- const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
- await web3Wrapper.awaitTransactionSuccessAsync(
- await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- await web3Wrapper.awaitTransactionSuccessAsync(
- await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, {
- from: spender,
- gas: constants.MAX_TOKEN_TRANSFERFROM_GAS,
- }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
-
- const newSpenderAllowance = await token.allowance.callAsync(owner, spender);
- expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance);
- });
-
- it('should transfer the correct balances if spender has sufficient allowance', async () => {
- const initOwnerBalance = await token.balanceOf.callAsync(owner);
- const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = initOwnerBalance;
- await web3Wrapper.awaitTransactionSuccessAsync(
- await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- await web3Wrapper.awaitTransactionSuccessAsync(
- await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, {
- from: spender,
- gas: constants.MAX_TOKEN_TRANSFERFROM_GAS,
- }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
-
- const newOwnerBalance = await token.balanceOf.callAsync(owner);
- const newSpenderBalance = await token.balanceOf.callAsync(spender);
-
- expect(newOwnerBalance).to.be.bignumber.equal(0);
- expect(newSpenderBalance).to.be.bignumber.equal(initOwnerBalance);
- });
-
- it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => {
- const initOwnerBalance = await token.balanceOf.callAsync(owner);
- const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = initOwnerBalance;
- await web3Wrapper.awaitTransactionSuccessAsync(
- await token.approve.sendTransactionAsync(spender, initSpenderAllowance, { from: owner }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- await web3Wrapper.awaitTransactionSuccessAsync(
- await token.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, {
- from: spender,
- gas: constants.MAX_TOKEN_TRANSFERFROM_GAS,
- }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
-
- const newSpenderAllowance = await token.allowance.callAsync(owner, spender);
- expect(newSpenderAllowance).to.be.bignumber.equal(0);
- });
- });
-});
diff --git a/contracts/core/test/tokens/weth9.ts b/contracts/core/test/tokens/weth9.ts
deleted file mode 100644
index 225481904..000000000
--- a/contracts/core/test/tokens/weth9.ts
+++ /dev/null
@@ -1,143 +0,0 @@
-import {
- chaiSetup,
- constants,
- expectInsufficientFundsAsync,
- expectTransactionFailedWithoutReasonAsync,
- provider,
- txDefaults,
- web3Wrapper,
-} from '@0x/contracts-test-utils';
-import { BlockchainLifecycle } from '@0x/dev-utils';
-import { BigNumber } from '@0x/utils';
-import { Web3Wrapper } from '@0x/web3-wrapper';
-import * as chai from 'chai';
-
-import { WETH9Contract } from '../../generated-wrappers/weth9';
-import { artifacts } from '../../src/artifacts';
-
-chaiSetup.configure();
-const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
-
-describe('EtherToken', () => {
- let account: string;
- const gasPrice = Web3Wrapper.toBaseUnitAmount(new BigNumber(20), 9);
- let etherToken: WETH9Contract;
-
- before(async () => {
- await blockchainLifecycle.startAsync();
- });
- after(async () => {
- await blockchainLifecycle.revertAsync();
- });
- before(async () => {
- const accounts = await web3Wrapper.getAvailableAddressesAsync();
- account = accounts[0];
-
- etherToken = await WETH9Contract.deployFrom0xArtifactAsync(artifacts.WETH9, provider, {
- gasPrice,
- ...txDefaults,
- });
- });
- beforeEach(async () => {
- await blockchainLifecycle.startAsync();
- });
- afterEach(async () => {
- await blockchainLifecycle.revertAsync();
- });
- describe('deposit', () => {
- it('should throw if caller attempts to deposit more Ether than caller balance', async () => {
- const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const ethToDeposit = initEthBalance.plus(1);
-
- return expectInsufficientFundsAsync(etherToken.deposit.sendTransactionAsync({ value: ethToDeposit }));
- });
-
- it('should convert deposited Ether to wrapped Ether tokens', async () => {
- const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const initEthTokenBalance = await etherToken.balanceOf.callAsync(account);
-
- const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1)));
-
- const txHash = await etherToken.deposit.sendTransactionAsync({ value: ethToDeposit });
- const receipt = await web3Wrapper.awaitTransactionSuccessAsync(
- txHash,
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
-
- const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
- const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account);
-
- expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas)));
- expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit));
- });
- });
-
- describe('withdraw', () => {
- it('should throw if caller attempts to withdraw greater than caller balance', async () => {
- const initEthTokenBalance = await etherToken.balanceOf.callAsync(account);
- const ethTokensToWithdraw = initEthTokenBalance.plus(1);
-
- return expectTransactionFailedWithoutReasonAsync(
- etherToken.withdraw.sendTransactionAsync(ethTokensToWithdraw),
- );
- });
-
- it('should convert ether tokens to ether with sufficient balance', async () => {
- const ethToDeposit = new BigNumber(Web3Wrapper.toWei(new BigNumber(1)));
- await web3Wrapper.awaitTransactionSuccessAsync(
- await etherToken.deposit.sendTransactionAsync({ value: ethToDeposit }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- const initEthTokenBalance = await etherToken.balanceOf.callAsync(account);
- const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const ethTokensToWithdraw = initEthTokenBalance;
- expect(ethTokensToWithdraw).to.not.be.bignumber.equal(0);
- const txHash = await etherToken.withdraw.sendTransactionAsync(ethTokensToWithdraw, {
- gas: constants.MAX_ETHERTOKEN_WITHDRAW_GAS,
- });
- const receipt = await web3Wrapper.awaitTransactionSuccessAsync(
- txHash,
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
-
- const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
- const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account);
-
- expect(finalEthBalance).to.be.bignumber.equal(
- initEthBalance.plus(ethTokensToWithdraw.minus(ethSpentOnGas)),
- );
- expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.minus(ethTokensToWithdraw));
- });
- });
-
- describe('fallback', () => {
- it('should convert sent ether to ether tokens', async () => {
- const initEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const initEthTokenBalance = await etherToken.balanceOf.callAsync(account);
-
- const ethToDeposit = Web3Wrapper.toBaseUnitAmount(new BigNumber(1), 18);
-
- const txHash = await web3Wrapper.sendTransactionAsync({
- from: account,
- to: etherToken.address,
- value: ethToDeposit,
- gasPrice,
- });
-
- const receipt = await web3Wrapper.awaitTransactionSuccessAsync(
- txHash,
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
-
- const ethSpentOnGas = gasPrice.times(receipt.gasUsed);
- const finalEthBalance = await web3Wrapper.getBalanceInWeiAsync(account);
- const finalEthTokenBalance = await etherToken.balanceOf.callAsync(account);
-
- expect(finalEthBalance).to.be.bignumber.equal(initEthBalance.minus(ethToDeposit.plus(ethSpentOnGas)));
- expect(finalEthTokenBalance).to.be.bignumber.equal(initEthTokenBalance.plus(ethToDeposit));
- });
- });
-});
diff --git a/contracts/core/test/tokens/zrx_token.ts b/contracts/core/test/tokens/zrx_token.ts
deleted file mode 100644
index 6bc5e164c..000000000
--- a/contracts/core/test/tokens/zrx_token.ts
+++ /dev/null
@@ -1,204 +0,0 @@
-import { chaiSetup, constants, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
-import { BlockchainLifecycle } from '@0x/dev-utils';
-import { BigNumber } from '@0x/utils';
-import { Web3Wrapper } from '@0x/web3-wrapper';
-import * as chai from 'chai';
-
-import { ZRXTokenContract } from '../../generated-wrappers/zrx_token';
-import { artifacts } from '../../src/artifacts';
-
-chaiSetup.configure();
-const expect = chai.expect;
-const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
-
-describe('ZRXToken', () => {
- let owner: string;
- let spender: string;
- let MAX_UINT: BigNumber;
- let zrxToken: ZRXTokenContract;
-
- before(async () => {
- await blockchainLifecycle.startAsync();
- });
- after(async () => {
- await blockchainLifecycle.revertAsync();
- });
- before(async () => {
- const accounts = await web3Wrapper.getAvailableAddressesAsync();
- owner = accounts[0];
- spender = accounts[1];
- zrxToken = await ZRXTokenContract.deployFrom0xArtifactAsync(artifacts.ZRXToken, provider, txDefaults);
- MAX_UINT = constants.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
- });
- beforeEach(async () => {
- await blockchainLifecycle.startAsync();
- });
- afterEach(async () => {
- await blockchainLifecycle.revertAsync();
- });
- describe('constants', () => {
- it('should have 18 decimals', async () => {
- const decimals = new BigNumber(await zrxToken.decimals.callAsync());
- const expectedDecimals = 18;
- expect(decimals).to.be.bignumber.equal(expectedDecimals);
- });
-
- it('should have a total supply of 1 billion tokens', async () => {
- const totalSupply = new BigNumber(await zrxToken.totalSupply.callAsync());
- const expectedTotalSupply = 1000000000;
- expect(Web3Wrapper.toUnitAmount(totalSupply, 18)).to.be.bignumber.equal(expectedTotalSupply);
- });
-
- it('should be named 0x Protocol Token', async () => {
- const name = await zrxToken.name.callAsync();
- const expectedName = '0x Protocol Token';
- expect(name).to.be.equal(expectedName);
- });
-
- it('should have the symbol ZRX', async () => {
- const symbol = await zrxToken.symbol.callAsync();
- const expectedSymbol = 'ZRX';
- expect(symbol).to.be.equal(expectedSymbol);
- });
- });
-
- describe('constructor', () => {
- it('should initialize owner balance to totalSupply', async () => {
- const ownerBalance = await zrxToken.balanceOf.callAsync(owner);
- const totalSupply = new BigNumber(await zrxToken.totalSupply.callAsync());
- expect(totalSupply).to.be.bignumber.equal(ownerBalance);
- });
- });
-
- describe('transfer', () => {
- it('should transfer balance from sender to receiver', async () => {
- const receiver = spender;
- const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner);
- const amountToTransfer = new BigNumber(1);
- await web3Wrapper.awaitTransactionSuccessAsync(
- await zrxToken.transfer.sendTransactionAsync(receiver, amountToTransfer, { from: owner }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- const finalOwnerBalance = await zrxToken.balanceOf.callAsync(owner);
- const finalReceiverBalance = await zrxToken.balanceOf.callAsync(receiver);
-
- const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer);
- const expectedFinalReceiverBalance = amountToTransfer;
- expect(finalOwnerBalance).to.be.bignumber.equal(expectedFinalOwnerBalance);
- expect(finalReceiverBalance).to.be.bignumber.equal(expectedFinalReceiverBalance);
- });
-
- it('should return true on a 0 value transfer', async () => {
- const didReturnTrue = await zrxToken.transfer.callAsync(spender, new BigNumber(0), {
- from: owner,
- });
- expect(didReturnTrue).to.be.true();
- });
- });
-
- describe('transferFrom', () => {
- it('should return false if owner has insufficient balance', async () => {
- const ownerBalance = await zrxToken.balanceOf.callAsync(owner);
- const amountToTransfer = ownerBalance.plus(1);
- await web3Wrapper.awaitTransactionSuccessAsync(
- await zrxToken.approve.sendTransactionAsync(spender, amountToTransfer, {
- from: owner,
- gas: constants.MAX_TOKEN_APPROVE_GAS,
- }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, {
- from: spender,
- });
- expect(didReturnTrue).to.be.false();
- });
-
- it('should return false if spender has insufficient allowance', async () => {
- const ownerBalance = await zrxToken.balanceOf.callAsync(owner);
- const amountToTransfer = ownerBalance;
-
- const spenderAllowance = await zrxToken.allowance.callAsync(owner, spender);
- const isSpenderAllowanceInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
- expect(isSpenderAllowanceInsufficient).to.be.true();
-
- const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, {
- from: spender,
- });
- expect(didReturnTrue).to.be.false();
- });
-
- it('should return true on a 0 value transfer', async () => {
- const amountToTransfer = new BigNumber(0);
- const didReturnTrue = await zrxToken.transferFrom.callAsync(owner, spender, amountToTransfer, {
- from: spender,
- });
- expect(didReturnTrue).to.be.true();
- });
-
- it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => {
- const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner);
- const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = MAX_UINT;
- await web3Wrapper.awaitTransactionSuccessAsync(
- await zrxToken.approve.sendTransactionAsync(spender, initSpenderAllowance, {
- from: owner,
- gas: constants.MAX_TOKEN_APPROVE_GAS,
- }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- await web3Wrapper.awaitTransactionSuccessAsync(
- await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, {
- from: spender,
- gas: constants.MAX_TOKEN_TRANSFERFROM_GAS,
- }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
-
- const newSpenderAllowance = await zrxToken.allowance.callAsync(owner, spender);
- expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance);
- });
-
- it('should transfer the correct balances if spender has sufficient allowance', async () => {
- const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner);
- const initSpenderBalance = await zrxToken.balanceOf.callAsync(spender);
- const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = initOwnerBalance;
- await web3Wrapper.awaitTransactionSuccessAsync(
- await zrxToken.approve.sendTransactionAsync(spender, initSpenderAllowance),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- await web3Wrapper.awaitTransactionSuccessAsync(
- await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, {
- from: spender,
- gas: constants.MAX_TOKEN_TRANSFERFROM_GAS,
- }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
-
- const newOwnerBalance = await zrxToken.balanceOf.callAsync(owner);
- const newSpenderBalance = await zrxToken.balanceOf.callAsync(spender);
-
- expect(newOwnerBalance).to.be.bignumber.equal(0);
- expect(newSpenderBalance).to.be.bignumber.equal(initSpenderBalance.plus(initOwnerBalance));
- });
-
- it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => {
- const initOwnerBalance = await zrxToken.balanceOf.callAsync(owner);
- const amountToTransfer = initOwnerBalance;
- await web3Wrapper.awaitTransactionSuccessAsync(
- await zrxToken.approve.sendTransactionAsync(spender, amountToTransfer),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
- await web3Wrapper.awaitTransactionSuccessAsync(
- await zrxToken.transferFrom.sendTransactionAsync(owner, spender, amountToTransfer, {
- from: spender,
- gas: constants.MAX_TOKEN_TRANSFERFROM_GAS,
- }),
- constants.AWAIT_TRANSACTION_MINED_MS,
- );
-
- const newSpenderAllowance = await zrxToken.allowance.callAsync(owner, spender);
- expect(newSpenderAllowance).to.be.bignumber.equal(0);
- });
- });
-});
diff --git a/contracts/core/test/utils/asset_proxy_owner_wrapper.ts b/contracts/core/test/utils/asset_proxy_owner_wrapper.ts
index d5aaaf519..df23658d8 100644
--- a/contracts/core/test/utils/asset_proxy_owner_wrapper.ts
+++ b/contracts/core/test/utils/asset_proxy_owner_wrapper.ts
@@ -1,4 +1,5 @@
import { LogDecoder } from '@0x/contracts-test-utils';
+import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
@@ -14,7 +15,7 @@ export class AssetProxyOwnerWrapper {
constructor(assetproxyOwnerContract: AssetProxyOwnerContract, provider: Provider) {
this._assetProxyOwner = assetproxyOwnerContract;
this._web3Wrapper = new Web3Wrapper(provider);
- this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
+ this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...tokensArtifacts });
}
public async submitTransactionAsync(
destination: string,
diff --git a/contracts/core/test/utils/erc20_wrapper.ts b/contracts/core/test/utils/erc20_wrapper.ts
index d6210646c..e5ab0e36c 100644
--- a/contracts/core/test/utils/erc20_wrapper.ts
+++ b/contracts/core/test/utils/erc20_wrapper.ts
@@ -1,11 +1,11 @@
import { constants, ERC20BalancesByOwner, txDefaults } from '@0x/contracts-test-utils';
+import { artifacts as tokensArtifacts, DummyERC20TokenContract } from '@0x/contracts-tokens';
import { assetDataUtils } from '@0x/order-utils';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated-wrappers/dummy_erc20_token';
import { ERC20ProxyContract } from '../../generated-wrappers/erc20_proxy';
import { artifacts } from '../../src/artifacts';
@@ -38,7 +38,7 @@ export class ERC20Wrapper {
for (let i = 0; i < numberToDeploy; i++) {
this._dummyTokenContracts.push(
await DummyERC20TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC20Token,
+ tokensArtifacts.DummyERC20Token,
this._provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
diff --git a/contracts/core/test/utils/erc721_wrapper.ts b/contracts/core/test/utils/erc721_wrapper.ts
index b5ae34e60..1f658ce86 100644
--- a/contracts/core/test/utils/erc721_wrapper.ts
+++ b/contracts/core/test/utils/erc721_wrapper.ts
@@ -1,11 +1,11 @@
import { constants, ERC721TokenIdsByOwner, txDefaults } from '@0x/contracts-test-utils';
+import { artifacts as tokensArtifacts, DummyERC721TokenContract } from '@0x/contracts-tokens';
import { generatePseudoRandomSalt } from '@0x/order-utils';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
import { Provider } from 'ethereum-types';
import * as _ from 'lodash';
-import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
import { ERC721ProxyContract } from '../../generated-wrappers/erc721_proxy';
import { artifacts } from '../../src/artifacts';
@@ -30,7 +30,7 @@ export class ERC721Wrapper {
for (const i of _.times(constants.NUM_DUMMY_ERC721_TO_DEPLOY)) {
this._dummyTokenContracts.push(
await DummyERC721TokenContract.deployFrom0xArtifactAsync(
- artifacts.DummyERC721Token,
+ tokensArtifacts.DummyERC721Token,
this._provider,
txDefaults,
constants.DUMMY_TOKEN_NAME,
diff --git a/contracts/core/test/utils/exchange_wrapper.ts b/contracts/core/test/utils/exchange_wrapper.ts
index 2a24b880f..075d2cb96 100644
--- a/contracts/core/test/utils/exchange_wrapper.ts
+++ b/contracts/core/test/utils/exchange_wrapper.ts
@@ -6,6 +6,7 @@ import {
orderUtils,
SignedTransaction,
} from '@0x/contracts-test-utils';
+import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
@@ -21,7 +22,7 @@ export class ExchangeWrapper {
constructor(exchangeContract: ExchangeContract, provider: Provider) {
this._exchange = exchangeContract;
this._web3Wrapper = new Web3Wrapper(provider);
- this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
+ this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...tokensArtifacts });
}
public async fillOrderAsync(
signedOrder: SignedOrder,
diff --git a/contracts/core/test/utils/forwarder_wrapper.ts b/contracts/core/test/utils/forwarder_wrapper.ts
index 9c5560381..4c78ecd79 100644
--- a/contracts/core/test/utils/forwarder_wrapper.ts
+++ b/contracts/core/test/utils/forwarder_wrapper.ts
@@ -1,4 +1,5 @@
import { constants, formatters, LogDecoder, MarketSellOrders } from '@0x/contracts-test-utils';
+import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
import { SignedOrder } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
@@ -58,7 +59,7 @@ export class ForwarderWrapper {
constructor(contractInstance: ForwarderContract, provider: Provider) {
this._forwarderContract = contractInstance;
this._web3Wrapper = new Web3Wrapper(provider);
- this._logDecoder = new LogDecoder(this._web3Wrapper, artifacts);
+ this._logDecoder = new LogDecoder(this._web3Wrapper, { ...artifacts, ...tokensArtifacts });
}
public async marketSellOrdersWithEthAsync(
orders: SignedOrder[],
diff --git a/contracts/core/test/utils/order_factory_from_scenario.ts b/contracts/core/test/utils/order_factory_from_scenario.ts
index 1cc962020..ecb4b2e28 100644
--- a/contracts/core/test/utils/order_factory_from_scenario.ts
+++ b/contracts/core/test/utils/order_factory_from_scenario.ts
@@ -8,12 +8,11 @@ import {
OrderScenario,
TakerScenario,
} from '@0x/contracts-test-utils';
+import { DummyERC721TokenContract } from '@0x/contracts-tokens';
import { assetDataUtils, generatePseudoRandomSalt } from '@0x/order-utils';
import { Order } from '@0x/types';
import { BigNumber, errorUtils } from '@0x/utils';
-import { DummyERC721TokenContract } from '../../generated-wrappers/dummy_erc721_token';
-
const TEN_UNITS_EIGHTEEN_DECIMALS = new BigNumber(10_000_000_000_000_000_000);
const FIVE_UNITS_EIGHTEEN_DECIMALS = new BigNumber(5_000_000_000_000_000_000);
const POINT_ONE_UNITS_EIGHTEEN_DECIMALS = new BigNumber(100_000_000_000_000_000);