2017-03-30 02:50:05 +09:00
|
|
|
let shelljs = require('shelljs');
|
2017-02-18 08:01:03 -05:00
|
|
|
|
2017-03-30 20:12:39 +09:00
|
|
|
class Simulator {
|
|
|
|
constructor(options) {
|
|
|
|
this.blockchainConfig = options.blockchainConfig;
|
|
|
|
}
|
2017-02-18 08:01:03 -05:00
|
|
|
|
2017-03-30 20:12:39 +09:00
|
|
|
run(options) {
|
|
|
|
let cmds = [];
|
2017-02-18 08:01:03 -05:00
|
|
|
|
2017-03-30 20:12:39 +09:00
|
|
|
cmds.push("-p " + (this.blockchainConfig.rpcPort || options.port || 8545));
|
|
|
|
cmds.push("-h " + (this.blockchainConfig.rpcHost || options.host || 'localhost'));
|
2017-12-27 17:48:33 -05:00
|
|
|
cmds.push("-a " + (options.numAccounts || 10));
|
|
|
|
cmds.push("-e " + (options.defaultBalance || 100));
|
|
|
|
cmds.push("-l " + (options.gasLimit || 8000000));
|
2017-02-18 08:01:03 -05:00
|
|
|
|
2017-03-30 20:26:03 +09:00
|
|
|
shelljs.exec('testrpc ' + cmds.join(' '), {async : true});
|
2017-03-30 20:12:39 +09:00
|
|
|
}
|
|
|
|
}
|
2017-02-18 08:01:03 -05:00
|
|
|
|
|
|
|
module.exports = Simulator;
|
|
|
|
|