mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
5b8c07817a
* Delete localhost provider type * Use ganache-cli default chain ID for tests * Delete unused test firstTimeState variable * Migrate default ganache-cli network to frequentRpcListDetail * Add default test provider state * Add test functionality to createJsonRpcClient * Lint locales * Update test middleware creation * fixup! Update test middleware creation
37 lines
831 B
JavaScript
37 lines
831 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
|