From 20c88a46d9d87835bd9ddc30374309d615a9cf9f Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 19 Jan 2018 14:21:50 +0100 Subject: Remove truffle from UnlimitedAllowanceTokenV2 tests --- .../contracts/test/unlimited_allowance_token_v2.ts | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'packages/contracts/test/unlimited_allowance_token_v2.ts') diff --git a/packages/contracts/test/unlimited_allowance_token_v2.ts b/packages/contracts/test/unlimited_allowance_token_v2.ts index 47927b913..ebdc3ba11 100644 --- a/packages/contracts/test/unlimited_allowance_token_v2.ts +++ b/packages/contracts/test/unlimited_allowance_token_v2.ts @@ -1,5 +1,7 @@ import { ZeroEx } from '0x.js'; +import { BlockchainLifecycle } from '@0xproject/dev-utils'; import { BigNumber } from '@0xproject/utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; import * as Web3 from 'web3'; @@ -10,28 +12,38 @@ import { ContractInstance } from '../util/types'; import { chaiSetup } from './utils/chai_setup'; const { DummyTokenV2 } = new Artifacts(artifacts); -const web3: Web3 = (global as any).web3; chaiSetup.configure(); const expect = chai.expect; +const web3: Web3 = (global as any).web3; +const blockchainLifecycle = new BlockchainLifecycle(constants.RPC_URL); -contract('UnlimitedAllowanceTokenV2', (accounts: string[]) => { +describe('UnlimitedAllowanceTokenV2', () => { + const web3Wrapper = new Web3Wrapper(web3.currentProvider); const config = { networkId: constants.TESTRPC_NETWORK_ID, }; const zeroEx = new ZeroEx(web3.currentProvider, config); - const owner = accounts[0]; - const spender = accounts[1]; + let owner: string; + let spender: string; const MAX_MINT_VALUE = new BigNumber(100000000000000000000); let tokenAddress: string; let token: ContractInstance; - beforeEach(async () => { + before(async () => { + const accounts = await web3Wrapper.getAvailableAddressesAsync(); + owner = accounts[0]; + spender = accounts[1]; token = await DummyTokenV2.new({ from: owner }); await token.mint(MAX_MINT_VALUE, { from: owner }); tokenAddress = token.address; }); - + beforeEach(async () => { + await blockchainLifecycle.startAsync(); + }); + afterEach(async () => { + await blockchainLifecycle.revertAsync(); + }); describe('transfer', () => { it('should throw if owner has insufficient balance', async () => { const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner); -- cgit v1.2.3