2017-03-29 17:50:05 +00:00
|
|
|
let shelljs = require('shelljs');
|
2017-02-18 13:01:03 +00:00
|
|
|
|
2017-03-30 11:12:39 +00:00
|
|
|
class Simulator {
|
|
|
|
constructor(options) {
|
|
|
|
this.blockchainConfig = options.blockchainConfig;
|
|
|
|
}
|
2017-02-18 13:01:03 +00:00
|
|
|
|
2017-03-30 11:12:39 +00:00
|
|
|
run(options) {
|
|
|
|
let cmds = [];
|
2017-02-18 13:01:03 +00:00
|
|
|
|
2017-03-30 11:12:39 +00:00
|
|
|
cmds.push("-p " + (this.blockchainConfig.rpcPort || options.port || 8545));
|
|
|
|
cmds.push("-h " + (this.blockchainConfig.rpcHost || options.host || 'localhost'));
|
|
|
|
cmds.push("-a " + (options.num || 10));
|
2017-02-18 13:01:03 +00:00
|
|
|
|
2017-03-30 11:12:39 +00:00
|
|
|
shelljs.exec('testrpc ' + cmds.join(' '));
|
|
|
|
}
|
|
|
|
}
|
2017-02-18 13:01:03 +00:00
|
|
|
|
|
|
|
module.exports = Simulator;
|
|
|
|
|