diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-19 21:15:44 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-01-30 23:01:36 +0800 |
commit | 661029f7ccf8e28e87faf85bb451298b3b066bfa (patch) | |
tree | 2779a6eaaaa31407f13f537d5d6fdc9f6ab2b77c /packages/contracts/test/token_registry.ts | |
parent | 850d32d60ca4f6eb20b8b626d93c4786937e9309 (diff) | |
download | dexon-sol-tools-661029f7ccf8e28e87faf85bb451298b3b066bfa.tar dexon-sol-tools-661029f7ccf8e28e87faf85bb451298b3b066bfa.tar.gz dexon-sol-tools-661029f7ccf8e28e87faf85bb451298b3b066bfa.tar.bz2 dexon-sol-tools-661029f7ccf8e28e87faf85bb451298b3b066bfa.tar.lz dexon-sol-tools-661029f7ccf8e28e87faf85bb451298b3b066bfa.tar.xz dexon-sol-tools-661029f7ccf8e28e87faf85bb451298b3b066bfa.tar.zst dexon-sol-tools-661029f7ccf8e28e87faf85bb451298b3b066bfa.zip |
Remove truffle from TokenRegistry tests
Diffstat (limited to 'packages/contracts/test/token_registry.ts')
-rw-r--r-- | packages/contracts/test/token_registry.ts | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/packages/contracts/test/token_registry.ts b/packages/contracts/test/token_registry.ts index 9ca18202f..1e01dcb6d 100644 --- a/packages/contracts/test/token_registry.ts +++ b/packages/contracts/test/token_registry.ts @@ -1,7 +1,10 @@ import { ZeroEx } from '0x.js'; +import { BlockchainLifecycle } from '@0xproject/dev-utils'; +import { Web3Wrapper } from '@0xproject/web3-wrapper'; import * as chai from 'chai'; import ethUtil = require('ethereumjs-util'); import * as _ from 'lodash'; +import * as Web3 from 'web3'; import { Artifacts } from '../util/artifacts'; import { constants } from '../util/constants'; @@ -13,10 +16,31 @@ import { chaiSetup } from './utils/chai_setup'; const { TokenRegistry } = new Artifacts(artifacts); chaiSetup.configure(); const expect = chai.expect; - -contract('TokenRegistry', (accounts: string[]) => { - const owner = accounts[0]; - const notOwner = accounts[1]; +// 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); + +describe('TokenRegistry', () => { + const web3Wrapper = new Web3Wrapper(web3.currentProvider); + let accounts: string[]; + let owner: string; + let notOwner: string; + let tokenReg: ContractInstance; + let tokenRegWrapper: TokenRegWrapper; + before(async () => { + accounts = await web3Wrapper.getAvailableAddressesAsync(); + owner = accounts[0]; + notOwner = accounts[1]; + tokenReg = await TokenRegistry.new(); + tokenRegWrapper = new TokenRegWrapper(tokenReg); + }); + beforeEach(async () => { + await blockchainLifecycle.startAsync(); + }); + afterEach(async () => { + await blockchainLifecycle.revertAsync(); + }); const tokenAddress1 = `0x${ethUtil.setLength(ethUtil.toBuffer('0x1'), 20, false).toString('hex')}`; const tokenAddress2 = `0x${ethUtil.setLength(ethUtil.toBuffer('0x2'), 20, false).toString('hex')}`; @@ -48,14 +72,6 @@ contract('TokenRegistry', (accounts: string[]) => { swarmHash: constants.NULL_BYTES, }; - let tokenReg: ContractInstance; - let tokenRegWrapper: TokenRegWrapper; - - beforeEach(async () => { - tokenReg = await TokenRegistry.new(); - tokenRegWrapper = new TokenRegWrapper(tokenReg); - }); - describe('addToken', () => { it('should throw when not called by owner', async () => { return expect(tokenRegWrapper.addTokenAsync(token1, notOwner)).to.be.rejectedWith(constants.REVERT); |