You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
715 B
34 lines
715 B
const ganache = require('ganache');
|
|
|
|
const defaultOptions = {
|
|
blockTime: 2,
|
|
network_id: 1337,
|
|
mnemonic:
|
|
'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent',
|
|
port: 8545,
|
|
vmErrorsOnRPCResponse: false,
|
|
hardfork: 'muirGlacier',
|
|
quiet: true,
|
|
};
|
|
|
|
class Ganache {
|
|
async start(opts) {
|
|
const options = { ...defaultOptions, ...opts };
|
|
const { port } = options;
|
|
this._server = ganache.server(options);
|
|
await this._server.listen(port);
|
|
}
|
|
|
|
getProvider() {
|
|
return this._server.provider;
|
|
}
|
|
|
|
async quit() {
|
|
if (!this._server) {
|
|
throw new Error('Server not running yet');
|
|
}
|
|
await this._server.close();
|
|
}
|
|
}
|
|
|
|
module.exports = Ganache;
|
|
|