diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-19 20:27:15 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-30 23:01:35 +0800 |
commit | 6463cda2045fe9caca3cb3908aa0c66f0bfe683a (patch) | |
tree | 6ac6826c29b8d85c226487239ea253aaa2d60f4c /packages/contracts | |
parent | d004df56e38726ed7f1b775da33d8f37aae270db (diff) | |
download | dexon-0x-contracts-6463cda2045fe9caca3cb3908aa0c66f0bfe683a.tar dexon-0x-contracts-6463cda2045fe9caca3cb3908aa0c66f0bfe683a.tar.gz dexon-0x-contracts-6463cda2045fe9caca3cb3908aa0c66f0bfe683a.tar.bz2 dexon-0x-contracts-6463cda2045fe9caca3cb3908aa0c66f0bfe683a.tar.lz dexon-0x-contracts-6463cda2045fe9caca3cb3908aa0c66f0bfe683a.tar.xz dexon-0x-contracts-6463cda2045fe9caca3cb3908aa0c66f0bfe683a.tar.zst dexon-0x-contracts-6463cda2045fe9caca3cb3908aa0c66f0bfe683a.zip |
Remove truffle from tokenTransferProxy tests
Diffstat (limited to 'packages/contracts')
-rw-r--r-- | packages/contracts/test/ether_token.ts (renamed from packages/contracts/test/ts/ether_token.ts) | 4 | ||||
-rw-r--r-- | packages/contracts/test/exchange/core.ts (renamed from packages/contracts/test/ts/exchange/core.ts) | 16 | ||||
-rw-r--r-- | packages/contracts/test/exchange/helpers.ts (renamed from packages/contracts/test/ts/exchange/helpers.ts) | 8 | ||||
-rw-r--r-- | packages/contracts/test/exchange/wrapper.ts (renamed from packages/contracts/test/ts/exchange/wrapper.ts) | 14 | ||||
-rw-r--r-- | packages/contracts/test/multi_sig_with_time_lock.ts (renamed from packages/contracts/test/ts/multi_sig_with_time_lock.ts) | 10 | ||||
-rw-r--r-- | packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts (renamed from packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts) | 10 | ||||
-rw-r--r-- | packages/contracts/test/token_registry.ts (renamed from packages/contracts/test/ts/token_registry.ts) | 8 | ||||
-rw-r--r-- | packages/contracts/test/token_transfer_proxy/auth.ts (renamed from packages/contracts/test/ts/token_transfer_proxy/auth.ts) | 4 | ||||
-rw-r--r-- | packages/contracts/test/token_transfer_proxy/transfer_from.ts (renamed from packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts) | 37 | ||||
-rw-r--r-- | packages/contracts/test/unlimited_allowance_token.ts (renamed from packages/contracts/test/ts/unlimited_allowance_token.ts) | 6 | ||||
-rw-r--r-- | packages/contracts/test/unlimited_allowance_token_v2.ts (renamed from packages/contracts/test/ts/unlimited_allowance_token_v2.ts) | 6 | ||||
-rw-r--r-- | packages/contracts/test/utils/chai_setup.ts (renamed from packages/contracts/test/ts/utils/chai_setup.ts) | 0 | ||||
-rw-r--r-- | packages/contracts/test/zrx_token.ts (renamed from packages/contracts/test/ts/zrx_token.ts) | 6 | ||||
-rw-r--r-- | packages/contracts/util/constants.ts | 1 |
14 files changed, 76 insertions, 54 deletions
diff --git a/packages/contracts/test/ts/ether_token.ts b/packages/contracts/test/ether_token.ts index f807cdaa3..cce11812b 100644 --- a/packages/contracts/test/ts/ether_token.ts +++ b/packages/contracts/test/ether_token.ts @@ -3,8 +3,8 @@ import { BigNumber, promisify } from '@0xproject/utils'; import * as chai from 'chai'; import Web3 = require('web3'); -import { Artifacts } from '../../util/artifacts'; -import { constants } from '../../util/constants'; +import { Artifacts } from '../util/artifacts'; +import { constants } from '../util/constants'; import { chaiSetup } from './utils/chai_setup'; diff --git a/packages/contracts/test/ts/exchange/core.ts b/packages/contracts/test/exchange/core.ts index 770ef0c43..0e94fcc34 100644 --- a/packages/contracts/test/ts/exchange/core.ts +++ b/packages/contracts/test/exchange/core.ts @@ -4,14 +4,14 @@ import * as chai from 'chai'; import ethUtil = require('ethereumjs-util'); import * as Web3 from 'web3'; -import { Artifacts } from '../../../util/artifacts'; -import { Balances } from '../../../util/balances'; -import { constants } from '../../../util/constants'; -import { crypto } from '../../../util/crypto'; -import { ExchangeWrapper } from '../../../util/exchange_wrapper'; -import { Order } from '../../../util/order'; -import { OrderFactory } from '../../../util/order_factory'; -import { BalancesByOwner, ContractInstance, ExchangeContractErrs } from '../../../util/types'; +import { Artifacts } from '../../util/artifacts'; +import { Balances } from '../../util/balances'; +import { constants } from '../../util/constants'; +import { crypto } from '../../util/crypto'; +import { ExchangeWrapper } from '../../util/exchange_wrapper'; +import { Order } from '../../util/order'; +import { OrderFactory } from '../../util/order_factory'; +import { BalancesByOwner, ContractInstance, ExchangeContractErrs } from '../../util/types'; import { chaiSetup } from '../utils/chai_setup'; chaiSetup.configure(); diff --git a/packages/contracts/test/ts/exchange/helpers.ts b/packages/contracts/test/exchange/helpers.ts index 95f68e419..830af44d1 100644 --- a/packages/contracts/test/ts/exchange/helpers.ts +++ b/packages/contracts/test/exchange/helpers.ts @@ -3,10 +3,10 @@ import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; import ethUtil = require('ethereumjs-util'); -import { Artifacts } from '../../../util/artifacts'; -import { ExchangeWrapper } from '../../../util/exchange_wrapper'; -import { Order } from '../../../util/order'; -import { OrderFactory } from '../../../util/order_factory'; +import { Artifacts } from '../../util/artifacts'; +import { ExchangeWrapper } from '../../util/exchange_wrapper'; +import { Order } from '../../util/order'; +import { OrderFactory } from '../../util/order_factory'; import { chaiSetup } from '../utils/chai_setup'; chaiSetup.configure(); diff --git a/packages/contracts/test/ts/exchange/wrapper.ts b/packages/contracts/test/exchange/wrapper.ts index e69e08bcf..91807fc37 100644 --- a/packages/contracts/test/ts/exchange/wrapper.ts +++ b/packages/contracts/test/exchange/wrapper.ts @@ -3,13 +3,13 @@ import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; import * as _ from 'lodash'; -import { Artifacts } from '../../../util/artifacts'; -import { Balances } from '../../../util/balances'; -import { constants } from '../../../util/constants'; -import { ExchangeWrapper } from '../../../util/exchange_wrapper'; -import { Order } from '../../../util/order'; -import { OrderFactory } from '../../../util/order_factory'; -import { BalancesByOwner, ContractInstance } from '../../../util/types'; +import { Artifacts } from '../../util/artifacts'; +import { Balances } from '../../util/balances'; +import { constants } from '../../util/constants'; +import { ExchangeWrapper } from '../../util/exchange_wrapper'; +import { Order } from '../../util/order'; +import { OrderFactory } from '../../util/order_factory'; +import { BalancesByOwner, ContractInstance } from '../../util/types'; import { chaiSetup } from '../utils/chai_setup'; chaiSetup.configure(); diff --git a/packages/contracts/test/ts/multi_sig_with_time_lock.ts b/packages/contracts/test/multi_sig_with_time_lock.ts index ea939a758..5cd4dba3d 100644 --- a/packages/contracts/test/ts/multi_sig_with_time_lock.ts +++ b/packages/contracts/test/multi_sig_with_time_lock.ts @@ -4,11 +4,11 @@ import * as chai from 'chai'; import Web3 = require('web3'); import * as multiSigWalletJSON from '../../build/contracts/MultiSigWalletWithTimeLock.json'; -import * as truffleConf from '../../truffle.js'; -import { Artifacts } from '../../util/artifacts'; -import { constants } from '../../util/constants'; -import { MultiSigWrapper } from '../../util/multi_sig_wrapper'; -import { ContractInstance } from '../../util/types'; +import * as truffleConf from '../truffle.js'; +import { Artifacts } from '../util/artifacts'; +import { constants } from '../util/constants'; +import { MultiSigWrapper } from '../util/multi_sig_wrapper'; +import { ContractInstance } from '../util/types'; import { chaiSetup } from './utils/chai_setup'; diff --git a/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts b/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts index 62aa625fe..82115418e 100644 --- a/packages/contracts/test/ts/multi_sig_with_time_lock_except_remove_auth_addr.ts +++ b/packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts @@ -1,11 +1,11 @@ import * as chai from 'chai'; import * as tokenTransferProxyJSON from '../../build/contracts/TokenTransferProxy.json'; -import { Artifacts } from '../../util/artifacts'; -import { constants } from '../../util/constants'; -import { crypto } from '../../util/crypto'; -import { MultiSigWrapper } from '../../util/multi_sig_wrapper'; -import { ContractInstance, TransactionDataParams } from '../../util/types'; +import { Artifacts } from '../util/artifacts'; +import { constants } from '../util/constants'; +import { crypto } from '../util/crypto'; +import { MultiSigWrapper } from '../util/multi_sig_wrapper'; +import { ContractInstance, TransactionDataParams } from '../util/types'; import { chaiSetup } from './utils/chai_setup'; const { TokenTransferProxy, MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress } = new Artifacts(artifacts); diff --git a/packages/contracts/test/ts/token_registry.ts b/packages/contracts/test/token_registry.ts index d1c551565..9ca18202f 100644 --- a/packages/contracts/test/ts/token_registry.ts +++ b/packages/contracts/test/token_registry.ts @@ -3,10 +3,10 @@ import * as chai from 'chai'; import ethUtil = require('ethereumjs-util'); import * as _ from 'lodash'; -import { Artifacts } from '../../util/artifacts'; -import { constants } from '../../util/constants'; -import { TokenRegWrapper } from '../../util/token_registry_wrapper'; -import { ContractInstance } from '../../util/types'; +import { Artifacts } from '../util/artifacts'; +import { constants } from '../util/constants'; +import { TokenRegWrapper } from '../util/token_registry_wrapper'; +import { ContractInstance } from '../util/types'; import { chaiSetup } from './utils/chai_setup'; diff --git a/packages/contracts/test/ts/token_transfer_proxy/auth.ts b/packages/contracts/test/token_transfer_proxy/auth.ts index 9ae0a8fc3..aa0ad2fc5 100644 --- a/packages/contracts/test/ts/token_transfer_proxy/auth.ts +++ b/packages/contracts/test/token_transfer_proxy/auth.ts @@ -1,7 +1,7 @@ import * as chai from 'chai'; -import { constants } from '../../../util/constants'; -import { ContractInstance } from '../../../util/types'; +import { constants } from '../../util/constants'; +import { ContractInstance } from '../../util/types'; import { chaiSetup } from '../utils/chai_setup'; chaiSetup.configure(); diff --git a/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts b/packages/contracts/test/token_transfer_proxy/transfer_from.ts index e1aff6dae..b5e1c7017 100644 --- a/packages/contracts/test/ts/token_transfer_proxy/transfer_from.ts +++ b/packages/contracts/test/token_transfer_proxy/transfer_from.ts @@ -1,22 +1,37 @@ +import { BlockchainLifecycle } from '@0xproject/dev-utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; +import * as Web3 from 'web3'; -import { Artifacts } from '../../../util/artifacts'; -import { Balances } from '../../../util/balances'; -import { constants } from '../../../util/constants'; -import { ContractInstance } from '../../../util/types'; +import { Artifacts } from '../../util/artifacts'; +import { Balances } from '../../util/balances'; +import { constants } from '../../util/constants'; +import { ContractInstance } from '../../util/types'; import { chaiSetup } from '../utils/chai_setup'; chaiSetup.configure(); const expect = chai.expect; const { TokenTransferProxy, DummyToken, TokenRegistry } = new Artifacts(artifacts); +// In order to benefit from type-safety, we re-assign the global web3 instance injected by Truffle +// with type `any` to a variable of type `Web3`. +const web3: Web3 = (global as any).web3; +const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL); -contract('TokenTransferProxy', (accounts: string[]) => { +describe('TokenTransferProxy', () => { + const web3Wrapper = new Web3Wrapper(web3.currentProvider); + let accounts: string[]; + let owner: string; + let notAuthorized: string; + const config = { + networkId: constants.TESTRPC_NETWORK_ID, + }; + before(async () => { + accounts = await web3Wrapper.getAvailableAddressesAsync(); + owner = notAuthorized = accounts[0]; + }); const INIT_BAL = 100000000; const INIT_ALLOW = 100000000; - const owner = accounts[0]; - const notAuthorized = owner; - let tokenTransferProxy: ContractInstance; let tokenRegistry: ContractInstance; let rep: ContractInstance; @@ -42,6 +57,12 @@ contract('TokenTransferProxy', (accounts: string[]) => { rep.setBalance(accounts[1], INIT_BAL, { from: owner }), ]); }); + beforeEach(async () => { + await blockchainLifecycle.startAsync(); + }); + afterEach(async () => { + await blockchainLifecycle.revertAsync(); + }); describe('transferFrom', () => { it('should throw when called by an unauthorized address', async () => { diff --git a/packages/contracts/test/ts/unlimited_allowance_token.ts b/packages/contracts/test/unlimited_allowance_token.ts index c90a52095..1b8abd510 100644 --- a/packages/contracts/test/ts/unlimited_allowance_token.ts +++ b/packages/contracts/test/unlimited_allowance_token.ts @@ -3,9 +3,9 @@ import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; import * as Web3 from 'web3'; -import { Artifacts } from '../../util/artifacts'; -import { constants } from '../../util/constants'; -import { ContractInstance } from '../../util/types'; +import { Artifacts } from '../util/artifacts'; +import { constants } from '../util/constants'; +import { ContractInstance } from '../util/types'; import { chaiSetup } from './utils/chai_setup'; diff --git a/packages/contracts/test/ts/unlimited_allowance_token_v2.ts b/packages/contracts/test/unlimited_allowance_token_v2.ts index 1b29a02ba..47927b913 100644 --- a/packages/contracts/test/ts/unlimited_allowance_token_v2.ts +++ b/packages/contracts/test/unlimited_allowance_token_v2.ts @@ -3,9 +3,9 @@ import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; import * as Web3 from 'web3'; -import { Artifacts } from '../../util/artifacts'; -import { constants } from '../../util/constants'; -import { ContractInstance } from '../../util/types'; +import { Artifacts } from '../util/artifacts'; +import { constants } from '../util/constants'; +import { ContractInstance } from '../util/types'; import { chaiSetup } from './utils/chai_setup'; diff --git a/packages/contracts/test/ts/utils/chai_setup.ts b/packages/contracts/test/utils/chai_setup.ts index 078edd309..078edd309 100644 --- a/packages/contracts/test/ts/utils/chai_setup.ts +++ b/packages/contracts/test/utils/chai_setup.ts diff --git a/packages/contracts/test/ts/zrx_token.ts b/packages/contracts/test/zrx_token.ts index 766c94c2a..60ce5487e 100644 --- a/packages/contracts/test/ts/zrx_token.ts +++ b/packages/contracts/test/zrx_token.ts @@ -3,9 +3,9 @@ import { BigNumber } from '@0xproject/utils'; import * as chai from 'chai'; import Web3 = require('web3'); -import { Artifacts } from '../../util/artifacts'; -import { constants } from '../../util/constants'; -import { ContractInstance } from '../../util/types'; +import { Artifacts } from '../util/artifacts'; +import { constants } from '../util/constants'; +import { ContractInstance } from '../util/types'; import { chaiSetup } from './utils/chai_setup'; diff --git a/packages/contracts/util/constants.ts b/packages/contracts/util/constants.ts index e61b2f802..d2a6352ed 100644 --- a/packages/contracts/util/constants.ts +++ b/packages/contracts/util/constants.ts @@ -3,6 +3,7 @@ export const constants = { INVALID_OPCODE: 'invalid opcode', REVERT: 'revert', TESTRPC_NETWORK_ID: 50, + RPC_URL: 'http://localhost:8545', MAX_ETHERTOKEN_WITHDRAW_GAS: 43000, MAX_TOKEN_TRANSFERFROM_GAS: 80000, MAX_TOKEN_APPROVE_GAS: 60000, |