1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 04:46:10 +01:00
metamask-extension/test/e2e/ganache.js
Erik Marks 76a2a9bb8b
@metamask/eslint config@5.0.0 (#10358)
* @metamask/eslint-config@5.0.0
* Update eslintrc and prettierrc
* yarn lint:fix
2021-02-04 10:15:23 -08:00

38 lines
846 B
JavaScript

const { promisify } = require('util');
const ganache = require('ganache-core');
const defaultOptions = {
blockTime: 2,
network_id: 1337,
mnemonic:
'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent',
port: 8545,
vmErrorsOnRPCResponse: false,
};
class Ganache {
async start(opts) {
const options = { ...defaultOptions, ...opts };
const { port } = options;
this._server = ganache.server(options);
const listen = promisify(this._server.listen).bind(this._server);
const blockchain = await listen(port);
return {
...blockchain,
port,
};
}
async quit() {
if (!this._server) {
throw new Error('Server not running yet');
}
const close = promisify(this._server.close).bind(this._server);
await close();
}
}
module.exports = Ganache;