From dcd08e40e61f5d98f03d71dc588e379f44817758 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Thu, 22 Jun 2017 23:36:43 +0200 Subject: Add kovan integration tests --- test/artifacts_test.ts | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 test/artifacts_test.ts (limited to 'test') diff --git a/test/artifacts_test.ts b/test/artifacts_test.ts new file mode 100644 index 000000000..937d2674d --- /dev/null +++ b/test/artifacts_test.ts @@ -0,0 +1,54 @@ +import * as _ from 'lodash'; +import * as chai from 'chai'; +import * as BigNumber from 'bignumber.js'; +import HDWalletProvider = require('truffle-hdwallet-provider'); +import {chaiSetup} from './utils/chai_setup'; +import {ZeroEx, Order} from '../src'; +import {web3Factory} from './utils/web3_factory'; +import {FillScenarios} from './utils/fill_scenarios'; + +chaiSetup.configure(); +const expect = chai.expect; + +// Those tests are slower cause they're talking to a remote node +const TIMEOUT = 10000; + +describe('Artifacts', () => { + describe('contracts are deployed on kovan', () => { + const kovanRpcUrl = 'https://kovan.0xproject.com'; + const mnemonic = 'concert load couple harbor equip island argue ramp clarify fence smart topic'; + const web3Provider = new HDWalletProvider(mnemonic, kovanRpcUrl); + const zeroEx = new ZeroEx(web3Provider); + it('token registry contract is deployed', async () => { + const tokens = await zeroEx.tokenRegistry.getTokensAsync(); + }).timeout(TIMEOUT); + it('proxy contract is deployed', async () => { + const [token] = await zeroEx.tokenRegistry.getTokensAsync(); + const allowance = await zeroEx.token.getProxyAllowanceAsync(token.address, ZeroEx.NULL_ADDRESS); + expect(allowance).to.be.bignumber.equal(0); + }).timeout(TIMEOUT); + it('exchange contract is deployed', async () => { + const userAddreses = await zeroEx.getAvailableAddressesAsync(); + const tokens = await zeroEx.tokenRegistry.getTokensAsync(); + const makerTokenAddress = tokens[0].address; + const takerTokenAddress = tokens[1].address; + // Unused anyway + const zrxTokenAddress = ZeroEx.NULL_ADDRESS; + const fillScenarios = new FillScenarios(zeroEx, userAddreses, tokens, zrxTokenAddress); + const order: Order = { + maker: userAddreses[0], + taker: userAddreses[0], + makerFee: new BigNumber(0), + takerFee: new BigNumber(0), + makerTokenAmount: new BigNumber(0), + takerTokenAmount: new BigNumber(0), + makerTokenAddress, + takerTokenAddress, + salt: ZeroEx.generatePseudoRandomSalt(), + feeRecipient: ZeroEx.NULL_ADDRESS, + expirationUnixTimestampSec: new BigNumber(2524604400), + }; + const orderHash = await zeroEx.getOrderHashHexAsync(order); + }).timeout(TIMEOUT); + }); +}); -- cgit v1.2.3 From 3f962585e9924a88082e91153cf3347922046941 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 23 Jun 2017 12:03:40 +0200 Subject: Refactor KOVAN_URL to constants and fetch mnemonic from package.json --- test/artifacts_test.ts | 8 ++++++-- test/utils/constants.ts | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/artifacts_test.ts b/test/artifacts_test.ts index 937d2674d..74705a525 100644 --- a/test/artifacts_test.ts +++ b/test/artifacts_test.ts @@ -1,3 +1,4 @@ +import * as fs from 'fs'; import * as _ from 'lodash'; import * as chai from 'chai'; import * as BigNumber from 'bignumber.js'; @@ -6,6 +7,7 @@ import {chaiSetup} from './utils/chai_setup'; import {ZeroEx, Order} from '../src'; import {web3Factory} from './utils/web3_factory'; import {FillScenarios} from './utils/fill_scenarios'; +import {constants} from './utils/constants'; chaiSetup.configure(); const expect = chai.expect; @@ -15,8 +17,10 @@ const TIMEOUT = 10000; describe('Artifacts', () => { describe('contracts are deployed on kovan', () => { - const kovanRpcUrl = 'https://kovan.0xproject.com'; - const mnemonic = 'concert load couple harbor equip island argue ramp clarify fence smart topic'; + const kovanRpcUrl = constants.KOVAN_URL; + const packageJSONContent = fs.readFileSync('package.json', 'utf-8'); + const packageJSON = JSON.parse(packageJSONContent); + const mnemonic = packageJSON.config.mnemonic; const web3Provider = new HDWalletProvider(mnemonic, kovanRpcUrl); const zeroEx = new ZeroEx(web3Provider); it('token registry contract is deployed', async () => { diff --git a/test/utils/constants.ts b/test/utils/constants.ts index aa1967f88..8211eea00 100644 --- a/test/utils/constants.ts +++ b/test/utils/constants.ts @@ -2,4 +2,5 @@ export const constants = { NULL_ADDRESS: '0x0000000000000000000000000000000000000000', RPC_HOST: 'localhost', RPC_PORT: 8545, + KOVAN_URL: 'https://kovan.0xproject.com', }; -- cgit v1.2.3 From 845aee35d36a1c9031096738d6144045c32263cb Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 23 Jun 2017 12:12:16 +0200 Subject: Simplify integration tests --- test/artifacts_test.ts | 38 ++++---------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) (limited to 'test') diff --git a/test/artifacts_test.ts b/test/artifacts_test.ts index 74705a525..1121ef951 100644 --- a/test/artifacts_test.ts +++ b/test/artifacts_test.ts @@ -1,17 +1,9 @@ import * as fs from 'fs'; -import * as _ from 'lodash'; -import * as chai from 'chai'; -import * as BigNumber from 'bignumber.js'; import HDWalletProvider = require('truffle-hdwallet-provider'); -import {chaiSetup} from './utils/chai_setup'; -import {ZeroEx, Order} from '../src'; +import {ZeroEx} from '../src'; import {web3Factory} from './utils/web3_factory'; -import {FillScenarios} from './utils/fill_scenarios'; import {constants} from './utils/constants'; -chaiSetup.configure(); -const expect = chai.expect; - // Those tests are slower cause they're talking to a remote node const TIMEOUT = 10000; @@ -24,35 +16,13 @@ describe('Artifacts', () => { const web3Provider = new HDWalletProvider(mnemonic, kovanRpcUrl); const zeroEx = new ZeroEx(web3Provider); it('token registry contract is deployed', async () => { - const tokens = await zeroEx.tokenRegistry.getTokensAsync(); + await (zeroEx.tokenRegistry as any)._getTokenRegistryContractAsync(); }).timeout(TIMEOUT); it('proxy contract is deployed', async () => { - const [token] = await zeroEx.tokenRegistry.getTokensAsync(); - const allowance = await zeroEx.token.getProxyAllowanceAsync(token.address, ZeroEx.NULL_ADDRESS); - expect(allowance).to.be.bignumber.equal(0); + await (zeroEx.token as any)._getProxyAddressAsync(); }).timeout(TIMEOUT); it('exchange contract is deployed', async () => { - const userAddreses = await zeroEx.getAvailableAddressesAsync(); - const tokens = await zeroEx.tokenRegistry.getTokensAsync(); - const makerTokenAddress = tokens[0].address; - const takerTokenAddress = tokens[1].address; - // Unused anyway - const zrxTokenAddress = ZeroEx.NULL_ADDRESS; - const fillScenarios = new FillScenarios(zeroEx, userAddreses, tokens, zrxTokenAddress); - const order: Order = { - maker: userAddreses[0], - taker: userAddreses[0], - makerFee: new BigNumber(0), - takerFee: new BigNumber(0), - makerTokenAmount: new BigNumber(0), - takerTokenAmount: new BigNumber(0), - makerTokenAddress, - takerTokenAddress, - salt: ZeroEx.generatePseudoRandomSalt(), - feeRecipient: ZeroEx.NULL_ADDRESS, - expirationUnixTimestampSec: new BigNumber(2524604400), - }; - const orderHash = await zeroEx.getOrderHashHexAsync(order); + await (zeroEx.exchange as any)._getExchangeContractAsync(); }).timeout(TIMEOUT); }); }); -- cgit v1.2.3 From 75ae305a6e95a775497c971b4d40c1757abba25f Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 23 Jun 2017 17:10:43 +0200 Subject: Rename KOVAN_URL to KOVAN_RPC_URL --- test/artifacts_test.ts | 2 +- test/utils/constants.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/artifacts_test.ts b/test/artifacts_test.ts index 1121ef951..d71b45567 100644 --- a/test/artifacts_test.ts +++ b/test/artifacts_test.ts @@ -9,7 +9,7 @@ const TIMEOUT = 10000; describe('Artifacts', () => { describe('contracts are deployed on kovan', () => { - const kovanRpcUrl = constants.KOVAN_URL; + const kovanRpcUrl = constants.KOVAN_RPC_URL; const packageJSONContent = fs.readFileSync('package.json', 'utf-8'); const packageJSON = JSON.parse(packageJSONContent); const mnemonic = packageJSON.config.mnemonic; diff --git a/test/utils/constants.ts b/test/utils/constants.ts index 8211eea00..9b150b5c1 100644 --- a/test/utils/constants.ts +++ b/test/utils/constants.ts @@ -2,5 +2,5 @@ export const constants = { NULL_ADDRESS: '0x0000000000000000000000000000000000000000', RPC_HOST: 'localhost', RPC_PORT: 8545, - KOVAN_URL: 'https://kovan.0xproject.com', + KOVAN_RPC_URL: 'https://kovan.0xproject.com', }; -- cgit v1.2.3