aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-04-04 10:35:58 +0800
committerFabio Berger <me@fabioberger.com>2018-04-04 10:35:58 +0800
commit5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a (patch)
treec6894bbd970482b111498827464f3930e501c212
parent6c02722f56dd37dd4237248e73d070755f86f318 (diff)
downloaddexon-sol-tools-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.tar
dexon-sol-tools-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.tar.gz
dexon-sol-tools-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.tar.bz2
dexon-sol-tools-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.tar.lz
dexon-sol-tools-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.tar.xz
dexon-sol-tools-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.tar.zst
dexon-sol-tools-5e4e27fed5b9b7c889e6e6e1805377b9eff31a3a.zip
Update dev-utils and subproviders tests to use ganache in-process provider
-rw-r--r--README.md22
-rw-r--r--packages/dev-utils/test/blockchain_lifecycle_test.ts2
-rw-r--r--packages/dev-utils/test/rpc_test.ts2
-rw-r--r--packages/subproviders/test/unit/ledger_subprovider_test.ts7
-rw-r--r--packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts9
-rw-r--r--packages/subproviders/test/utils/configs.ts5
-rw-r--r--packages/subproviders/test/utils/subprovider.ts18
7 files changed, 38 insertions, 27 deletions
diff --git a/README.md b/README.md
index 86e00bfd9..770f3440d 100644
--- a/README.md
+++ b/README.md
@@ -74,7 +74,7 @@ You can include those by prepending @0xproject/typescript-typings package to you
We strongly recommend that the community help us make improvements and determine the future direction of the protocol. To report bugs within this package, please create an issue in this repository.
-Please read our [contribution guidelines](./CONTRIBUTING.md) before getting started.
+#### Read our [contribution guidelines](./CONTRIBUTING.md).
### Install dependencies
@@ -118,24 +118,6 @@ yarn lerna:run lint
### Run Tests
-Before running the tests, you will need to spin up a [TestRPC](https://www.npmjs.com/package/ethereumjs-testrpc) instance and deploy all the 0x smart contracts.
-
-In a separate terminal, start TestRPC (a convenience command is provided as part of this repo)
-
-```bash
-yarn testrpc
-```
-
-Then in your main terminal run
-
-```
-cd packages/contracts
-yarn migrate
-cd ..
-```
-
-And finally from the root project directory run
-
```bash
-yarn lerna:run test
+yarn lerna:test
```
diff --git a/packages/dev-utils/test/blockchain_lifecycle_test.ts b/packages/dev-utils/test/blockchain_lifecycle_test.ts
index 5ed67e012..077f6f2f1 100644
--- a/packages/dev-utils/test/blockchain_lifecycle_test.ts
+++ b/packages/dev-utils/test/blockchain_lifecycle_test.ts
@@ -8,7 +8,7 @@ import { BlockchainLifecycle, web3Factory } from '../src';
const expect = chai.expect;
describe('BlockchainLifecycle tests', () => {
- const web3Provider = web3Factory.getRpcProvider();
+ const web3Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
const web3Wrapper = new Web3Wrapper(web3Provider);
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
describe('#startAsync/revertAsync', () => {
diff --git a/packages/dev-utils/test/rpc_test.ts b/packages/dev-utils/test/rpc_test.ts
index 1bdea3613..233d8035e 100644
--- a/packages/dev-utils/test/rpc_test.ts
+++ b/packages/dev-utils/test/rpc_test.ts
@@ -8,7 +8,7 @@ import { web3Factory } from '../src';
const expect = chai.expect;
describe('RPC tests', () => {
- const web3Provider = web3Factory.getRpcProvider();
+ const web3Provider = web3Factory.getRpcProvider({ shouldUseInProcessGanache: true });
const web3Wrapper = new Web3Wrapper(web3Provider);
describe('#mineBlockAsync', () => {
it('increases block number when called', async () => {
diff --git a/packages/subproviders/test/unit/ledger_subprovider_test.ts b/packages/subproviders/test/unit/ledger_subprovider_test.ts
index 3cb487f02..a3800434a 100644
--- a/packages/subproviders/test/unit/ledger_subprovider_test.ts
+++ b/packages/subproviders/test/unit/ledger_subprovider_test.ts
@@ -4,12 +4,12 @@ import * as ethUtils from 'ethereumjs-util';
import * as _ from 'lodash';
import Web3 = require('web3');
import Web3ProviderEngine = require('web3-provider-engine');
-import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
import { LedgerSubprovider } from '../../src';
import { DoneCallback, LedgerCommunicationClient, LedgerSubproviderErrors } from '../../src/types';
import { chaiSetup } from '../chai_setup';
import { reportCallbackErrors } from '../utils/report_callback_errors';
+import { subprovider as ganacheSubprovider } from '../utils/subprovider';
chaiSetup.configure();
const expect = chai.expect;
@@ -99,10 +99,7 @@ describe('LedgerSubprovider', () => {
before(() => {
provider = new Web3ProviderEngine();
provider.addProvider(ledgerSubprovider);
- const httpProvider = new RpcSubprovider({
- rpcUrl: 'http://localhost:8545',
- });
- provider.addProvider(httpProvider);
+ provider.addProvider(ganacheSubprovider);
provider.start();
});
describe('success cases', () => {
diff --git a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
index a347ab765..ab540e202 100644
--- a/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
+++ b/packages/subproviders/test/unit/redundant_rpc_subprovider_test.ts
@@ -3,11 +3,13 @@ import * as chai from 'chai';
import * as _ from 'lodash';
import Web3 = require('web3');
import Web3ProviderEngine = require('web3-provider-engine');
+import RpcSubprovider = require('web3-provider-engine/subproviders/rpc');
import { RedundantRPCSubprovider } from '../../src';
import { DoneCallback } from '../../src/types';
import { chaiSetup } from '../chai_setup';
import { reportCallbackErrors } from '../utils/report_callback_errors';
+import { subprovider as ganacheSubprovider } from '../utils/subprovider';
const expect = chai.expect;
chaiSetup.configure();
@@ -18,6 +20,8 @@ describe('RedundantRpcSubprovider', () => {
provider = new Web3ProviderEngine();
const endpoints = ['http://localhost:8545'];
const redundantSubprovider = new RedundantRPCSubprovider(endpoints);
+ // Hack: Hot-swap rpc with ganacheSubprovider
+ (redundantSubprovider as any)._rpcs = [ganacheSubprovider];
provider.addProvider(redundantSubprovider);
provider.start();
@@ -38,6 +42,11 @@ describe('RedundantRpcSubprovider', () => {
provider = new Web3ProviderEngine();
const endpoints = ['http://does-not-exist:3000', 'http://localhost:8545'];
const redundantSubprovider = new RedundantRPCSubprovider(endpoints);
+ // Hack: Hot-swap rpcs with [nonExistentSubprovider, ganacheSubprovider]
+ const nonExistentSubprovider = new RpcSubprovider({
+ rpcUrl: 'http://does-not-exist:3000',
+ });
+ (redundantSubprovider as any)._rpcs = [nonExistentSubprovider, ganacheSubprovider];
provider.addProvider(redundantSubprovider);
provider.start();
diff --git a/packages/subproviders/test/utils/configs.ts b/packages/subproviders/test/utils/configs.ts
new file mode 100644
index 000000000..341037e4f
--- /dev/null
+++ b/packages/subproviders/test/utils/configs.ts
@@ -0,0 +1,5 @@
+export const configs = {
+ port: 8545,
+ networkId: 50,
+ mnemonic: 'concert load couple harbor equip island argue ramp clarify fence smart topic',
+};
diff --git a/packages/subproviders/test/utils/subprovider.ts b/packages/subproviders/test/utils/subprovider.ts
new file mode 100644
index 000000000..b1c459746
--- /dev/null
+++ b/packages/subproviders/test/utils/subprovider.ts
@@ -0,0 +1,18 @@
+import * as fs from 'fs';
+
+import { GanacheSubprovider } from '../../src/subproviders/ganache';
+import { configs } from '../utils/configs';
+
+const logger = {
+ log: (arg: any) => {
+ fs.appendFileSync('ganache.log', `${arg}\n`);
+ },
+};
+
+export const subprovider = new GanacheSubprovider({
+ logger,
+ verbose: false,
+ port: configs.port,
+ networkId: configs.networkId,
+ mnemonic: configs.mnemonic,
+});