From 8711b75462530b4ff876b2f7ac8201aa97c37584 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sun, 2 Oct 2016 18:45:55 -0400 Subject: [PATCH] add support for more simulators --- demo/chains.json | 34 ++++++++++++++++++++++++++++++++++ lib/cmd.js | 34 ++++++++++++++++++++++++---------- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/demo/chains.json b/demo/chains.json index 25955750..7de3c875 100644 --- a/demo/chains.json +++ b/demo/chains.json @@ -1,4 +1,38 @@ { + "0x4d12c61541655bbf65aea06b4813a7a0f3317cb470623258f4e3909746f23cd6": { + "name": "development", + "contracts": { + "2ac097aa929aece4724cc229cc7bd26c7dfa153f3274b5623936cb4a4dc12fa1": { + "address": "0x123", + "name": "token" + }, + "577bcb0c85129a6ff9e4dcde08f04e6f094e94c74a4423fc90e5947df9a21b82": { + "address": "0xaa5b04650f2705ef87d566cdfd0e45bfc19f43ce", + "name": "SimpleStorage" + }, + "e0d35d6564373021d9749a7a8815cf58cc5ca7b7edaf4740c1913898561531c3": { + "address": "0xdad08a3a58bb903ccebfbf1a4e55e45e7ec8d0e4", + "name": "SimpleStorage2" + } + } + }, + "0x8839bd592160ddb23170ad76688c12a73ce41d41a6437163de0fb080bbface0a": { + "name": "development", + "contracts": { + "2ac097aa929aece4724cc229cc7bd26c7dfa153f3274b5623936cb4a4dc12fa1": { + "address": "0x123", + "name": "token" + }, + "577bcb0c85129a6ff9e4dcde08f04e6f094e94c74a4423fc90e5947df9a21b82": { + "address": "0xc0008e20eb48abf2e3bacc3be0ee4f3b7ae42cfe", + "name": "SimpleStorage" + }, + "e0d35d6564373021d9749a7a8815cf58cc5ca7b7edaf4740c1913898561531c3": { + "address": "0x1246646162a64c6dbb6fd285a6bbffdfc093aa56", + "name": "SimpleStorage2" + } + } + }, "0xb6cfeab83614da04c03db0fb8a6787a45d0be8d576fcc6f8f457a5a816d22ab3": { "name": "development", "contracts": { diff --git a/lib/cmd.js b/lib/cmd.js index 781543ce..1c1598f5 100644 --- a/lib/cmd.js +++ b/lib/cmd.js @@ -88,17 +88,31 @@ Cmd.prototype.simulator = function() { program .command('simulator') .description('run a fast ethereum rpc simulator') - .option('--ethersim', 'use ethersim as the rpc simulator [default]') - .action(function() { - var EtherSim; - try { - EtherSim = require('ethersim'); - } catch(e) { - console.log('EtherSim not found; Please install it with "npm install ethersim --save"'); - console.log('For more information see https://github.com/iurimatias/ethersim'); - process.exit(1); + .option('--testrpc', 'use testrpc as the rpc simulator [default]') + .option('--ethersim', 'use ethersim as the rpc simulator') + .action(function(options) { + var Sim; + + if (options.ethersim) { + try { + Sim = require('ethersim'); + } catch(e) { + console.log('EtherSim not found; Please install it with "npm install ethersim --save"'); + console.log('For more information see https://github.com/iurimatias/ethersim'); + process.exit(1); + } + Sim.startServer(); + } + else { + try { + Sim = require('ethereumjs-testrpc'); + } catch(e) { + console.log('TestRPC not found; Please install it with "npm install -g ethereumjs-testrpc'); + console.log('For more information see https://github.com/ethereumjs/testrpc'); + process.exit(1); + } + exec('testrpc'); } - EtherSim.startServer(); }); };