How to use the ganache-core.server function in ganache-core

To help you get started, we’ve selected a few ganache-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brave / ethereum-remote-client / test / helper.js View on Github external
const Ganache = require('ganache-core')
const nock = require('nock')
import Enzyme from 'enzyme'
import Adapter from 'enzyme-adapter-react-15'

nock.disableNetConnect()
nock.enableNetConnect('localhost')

Enzyme.configure({ adapter: new Adapter() })
// disallow promises from swallowing errors
enableFailureOnUnhandledPromiseRejection()

// ganache server
const server = Ganache.server()
server.listen(8545, () => {
  console.log('Ganache Testrpc is running on "http://localhost:8545"')
})

// logging util
const log = require('loglevel')
log.setDefaultLevel(5)
global.log = log

//
// polyfills
//

// fetch
global.fetch = require('isomorphic-fetch')
require('abortcontroller-polyfill/dist/polyfill-patch-fetch')
github o2oprotocol / digital-identity / test / _helper.js View on Github external
async function server(web3, provider) {
  try {
    // Hack to prevent "connection not open on send" error when using websockets
    web3.setProvider(provider.replace(/^ws/, 'http'))
    await web3.eth.net.getId()
    web3.setProvider(provider)
    return
  } catch (e) {
    /* Ignore */
  }

  var port = '7545'
  if (String(provider).match(/:([0-9]+)$/)) {
    port = provider.match(/:([0-9]+)$/)[1]
  }
  var server = Ganache.server()
  await server.listen(port)
  return server
}
github OriginProtocol / origin / origin-contracts / test-alt / _helper.js View on Github external
async function server(web3, provider) {
  try {
    // Hack to prevent "connection not open on send" error when using websockets
    web3.setProvider(provider.replace(/^ws/, 'http'))
    await web3.eth.net.getId()
    web3.setProvider(provider)
    return
  } catch (e) {
    /* Ignore */
  }

  let port = '7545'
  if (String(provider).match(/:([0-9]+)$/)) {
    port = provider.match(/:([0-9]+)$/)[1]
  }
  const server = Ganache.server()
  await server.listen(port)
  return server
}
github trufflesuite / truffle-core / test / scenarios / debugging / debugging.js View on Github external
before("set up Ganache server", function(done) {
    var logger = {
      log: function(message) {
        //console.log(message);
      }
    };

    server = TestRPC.server({
      logger: logger
    });

    server.listen(port, function(err) {
      provider = new Web3.providers.HttpProvider("http://localhost:" + port);
      done();
    });
  });
github OpenZeppelin / openzeppelin-test-environment / src / ganache-server.ts View on Github external
function setupServer({ accountsConfig, gasLimit, gasPrice, coverage }: Options) {
  const ganacheOpts = {
    accounts: accountsConfig,
    gasLimit,
    gasPrice: `0x${gasPrice.toString(16)}`,
  };

  if (!coverage) {
    return ganache.server(ganacheOpts);
  } else {
    return require('ganache-core-coverage').server({
      ...ganacheOpts,
      emitFreeLogs: true,
      allowUnlimitedContractSize: true,
    });
  }
}
github trufflesuite / truffle / test / provider.js View on Github external
before(done => {
    server = Ganache.server();
    server.listen(port, done);
  });
github validitylabs / hopr / test / testnet.js View on Github external
'use strict'

const { privKeyToPeerId } = require('../src/utils')
const {HARDCODED_PRIV_KEY } = require('../src/constants')

const FUNDING_KEY = HARDCODED_PRIV_KEY

const Ganache = require('ganache-core')

const server = Ganache.server({
    accounts: [
        {
            balance: '0xd3c21bcecceda0000000',
            secretKey: FUNDING_KEY
        }
    ]
})

server.listen(8545, 'localhost')
github zapproject / zap-nodejs-api / test / server.js View on Github external
const { server } = require('ganache-core');


const ganacheServer = server(serverOptions);

module.exports.serverOptions = serverOptions;
module.exports.server = ganacheServer;
github OriginProtocol / origin / origin-contracts / scripts / start-ganache.js View on Github external
return new Promise((resolve, reject) => {
    const server = Ganache.server({
      total_accounts: 10,
      default_balance_ether: 100,
      network_id: 999,
      seed: 123,
      blockTime: 0,
      mnemonic:
        'candy maple cake sugar pudding cream honey rich smooth crumble sweet treat'
    })
    server.listen(PORT, err => {
      if (err) {
        return reject(err)
      }
      console.log(`Ganache listening on port ${PORT}`)
      resolve()
    })
  })
github 0xcert / framework / packages / 0xcert-ethereum-sandbox / src / core / sandbox.ts View on Github external
await new Promise((resolve, reject) => {
      this.server = ganache['server']();
      this.server.listen(options.port, (e) => e ? reject(e) : resolve());
    });

ganache-core

[![npm Version](https://img.shields.io/npm/v/ganache-core.svg)](https://www.npmjs.com/package/ganache-core) [![npm Downloads](https://img.shields.io/npm/dm/ganache-core.svg)](https://www.npmjs.com/package/ganache-core) [![Build Status](https://travis-ci.o

MIT
Latest version published 3 years ago

Package Health Score

55 / 100
Full package analysis