1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
metamask-extension/test/e2e/ganache.js
Whymarrh Whitby e803807dd9
Fix no-param-reassign issues (#9235)
See [`no-param-reassign`](https://eslint.org/docs/rules/no-param-reassign) for more information.

This change enables `no-param-reassign` and fixes the issues raised by the rule.
2020-08-15 09:28:11 -02:30

37 lines
832 B
JavaScript

const ganache = require('ganache-core')
const { promisify } = require('util')
const defaultOptions = {
blockTime: 2,
network_id: 5777,
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.port
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