How to use the ethereumjs-testrpc.provider function in ethereumjs-testrpc

To help you get started, we’ve selected a few ethereumjs-testrpc 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 ConsenSys / live-libs / test / suite.js View on Github external
var web3 = new Web3();

var TestRPC = require('ethereumjs-testrpc');
var fileUtils = require('../lib/file-utils');
var LiveLibs = require('../index.js');
var liveLibs; // we need to define this after deployment

var migration = require('../lib/migration');

var assert = require('chai').assert;

var accountConfig = [
  {balance: 20000000},
  {balance: 20000000}
];
web3.setProvider(TestRPC.provider({accounts: accountConfig}));

var accounts;

describe('Live Libs', function() {
  before(function(done) {
    setAccounts().then(function() {
      return migration.deploy(web3, true); // TODO: maybe silence these logs?
    }).then(function() {
      liveLibs = new LiveLibs(web3, fileUtils.config({testing:true}));
    }).then(done).catch(done);
  });

  var fakeAddress = '0xcd2a3d9f938e13cd947ec05abc7fe734df8dd826';
  var fakeAbi = '[]';

  it('detects when name is too long', function() {
github cartesi / arbitration-dlib / old_test / test-mm.js View on Github external
it('Checking functionalities', function*() {
    this.timeout(150000)
    // testrpc
    var testrpcParameters = {
      "accounts":
      [   { "balance": 100000000000000000000,
            "secretKey": aliceKey },
          { "balance": 100000000000000000000,
            "secretKey": machineKey }
      ]
    }
    web3 = new Web3(TestRPC.provider(testrpcParameters));

    // promisify jsonRPC direct call
    // sendRPC = function(param){
    //   return new Promise(function(resolve, reject){
    //     web3.currentProvider.sendAsync(param, function(err, data){
    //       if(err !== null) return reject(err);
    //       resolve(data);
    //     });
    //   });
    // }


    // create contract object
    mmLibContract = new web3.eth.Contract(mmLibAbi);
    // create contract object
    mmTestContract = new web3.eth.Contract(mmTestAbi);
github BANKEX / solidity-float-point-calculation / tests.js View on Github external
function startVM(){
    var provider = TestRPC.provider({
        total_accounts: 10,
        time:new Date(),
        verbose:false,
        gasPrice: 0,
      accounts:[
          {secretKey:"0x"+fromBtcWif("5JmrM8PB2d5XetmVUCErMZYazBotNzSeMrET26WK8y3m8XLJS98").toString('hex'), balance: 1e30},
          {secretKey:"0x"+fromBtcWif("5HtkDncwskEM5FiBQgU1wqLLbayBmfh5FSMYtLngedr6C6NhvWr").toString('hex'), balance: 1e30},
          {secretKey:"0x"+fromBtcWif("5JMneDeCfBBR1M6mX7SswZvC8axrfxNgoYKtu5DqVokdBwSn2oD").toString('hex'), balance: 1e30}    
      ],
        mnemonic: "42"
        // ,
        // logger: console
      });
      web3 = new Web3(provider);
      BigNumber = web3.BigNumber;
      sendAsyncPromisified = util.promisify(provider.sendAsync).bind(provider);
github BANKEX / FrozenTokenHolder / tests.js View on Github external
function startVM(){
    var provider = TestRPC.provider({
        total_accounts: 10,
        time:new Date(),
        verbose:false,
        gasPrice: 0,
      accounts:[
          {secretKey:"0x7231a774a538fce22a329729b03087de4cb4a1119494db1c10eae3bb491823e7", balance: 1e30},
          {secretKey:"0x"+fromBtcWif("5JmrM8PB2d5XetmVUCErMZYazBotNzSeMrET26WK8y3m8XLJS98").toString('hex'), balance: 1e30},
          {secretKey:"0x"+fromBtcWif("5HtkDncwskEM5FiBQgU1wqLLbayBmfh5FSMYtLngedr6C6NhvWr").toString('hex'), balance: 1e30},
          {secretKey:"0x"+fromBtcWif("5JMneDeCfBBR1M6mX7SswZvC8axrfxNgoYKtu5DqVokdBwSn2oD").toString('hex'), balance: 1e30}    
      ],
        mnemonic: "42"
        // ,
        // logger: console
      });
      web3 = new Web3(provider);
      BigNumber = web3.BigNumber;
github SilentCicero / ethdeploy / example / ethdeploy.testrpc.config.js View on Github external
module.exports = (options) => ({ // eslint-disable-line
  entry: [
    './environments.json',
    './contracts',
  ],
  output: {
    path: './',
    filename: 'environments.json',
    safe: true,
  },
  module: {
    environment: {
      name: 'testrpc',
      provider: TestRPC.provider(),
      defaultTxObject: {
        from: 1,
        gas: 3000001,
      },
    },
    preLoaders: [
      { test: /\.(json)$/, loader: 'ethdeploy-environment-loader', build: true },
    ],
    loaders: [
      { test: /\.(sol)$/, loader: 'ethdeploy-solc-loader' },
    ],
    deployment: (deploy, contracts, done) => {
      deploy(contracts['contracts/SimpleStore.sol:SimpleStore'], 458977, { from: 0 }).then(() => {
        done();
      });
    },
github cartesi / arbitration-dlib / old_test / test-hireCPU.js View on Github external
const hireBytecode = compiledContract.contracts['src/hireCPU.sol:hireCPU'].bytecode;
const hireAbi = JSON.parse(compiledContract.contracts['src/hireCPU.sol:hireCPU'].interface);


// testrpc
var testrpcParameters = {
  "accounts":
  [   { "balance": 100000000000000000000,
        "secretKey": aliceKey },
      { "balance": 100000000000000000000,
        "secretKey": bobKey },
      { "balance": 100000000000000000000,
        "secretKey": eveKey }
  ]
}
web3 = new Web3(TestRPC.provider(testrpcParameters));

// promisify jsonRPC direct call
sendRPC = function(param){
  return new Promise(function(resolve, reject){
    web3.currentProvider.sendAsync(param, function(err, data){
      if(err !== null) return reject(err);
      resolve(data);
    });
  });
}

// create contract object
tokenContract = new web3.eth.Contract(tokenAbi);

// another option is using a node serving in port 8545 with those users
// web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
github tcoulter / dao-truffle / index.js View on Github external
#!/usr/bin/env node

var TestRPC = require("ethereumjs-testrpc");
var Web3 = require("web3");
var async = require("async");
var moment = require("moment");
var align = require("./aligner.js");

var DAOContract = require("./build/contracts/DAO.sol.js");
var HackContract = require("./build/contracts/Hack.sol.js");

var block = 1599200;

console.log("Forking from block " + block + "...");

var web3 = new Web3(TestRPC.provider({
  fork: "http://localhost:8545@" + block
  //verbose: true,
  //logger: console
}));

web3.eth.getAccounts(function(err, accounts) {
  // Setup contract abstractions for ease of use.
  [DAOContract, HackContract].forEach(function(contract) {
    contract.setProvider(web3.currentProvider);
    contract.defaults({
      gas: 4e6,
      from: accounts[0]
    })
  });

  var DAO = DAOContract.at("0xbb9bc244d798123fde783fcc1c72d3bb8c189413");
github BANKEX / PlasmaETHexchange / server.js View on Github external
async function startVM(){
    if (config.testOnRinkeby) {
        web3 = new Web3(config.provider);
        let unlocked = await web3.eth.personal.unlockAccount(config.plasmaOperatorAddress, config.plasmaOperatorPassword, 0);
        let provider = web3.currentProvider;
        sendAsyncPromisified = util.promisify(provider.send).bind(provider);
        return;
    }
    let provider = TestRPC.provider({
        total_accounts: 10,
        time:new Date(),
        verbose:false,
        gasPrice: 0,
      accounts:[
          {secretKey:"0x" + plasmaOperatorPrivKey.toString('hex'), balance: 4.2e18},
          {secretKey:"0x" + testPrivKeys[0].toString('hex'), balance: 4.2e18},
          {secretKey:"0x" + testPrivKeys[1].toString('hex'), balance: 4.2e18}    
      ],
        mnemonic: "42"
        // ,
        // logger: console
      });
      web3 = new Web3(provider);

      sendAsyncPromisified = util.promisify(provider.sendAsync).bind(provider);
github trufflesuite / truffle-artifactor / test / networks.js View on Github external
it("deployed() used as a thennable will error if contract hasn't been deployed to the network detected", function(done) {
    var network_three = TestRPC.provider();

    var json = requireNoCache(built_file_path);
    var Example = contract(json);
    Example.setProvider(network_three);

    Example.deployed().then(function() {
      assert.fail("This function should never be run because there should have been an error.");
    }).catch(function(err) {
      if (err.message.indexOf("Example has not been deployed to detected network") < 0) return done(new Error("Unexpected error received: " + err.message));
      done();
    });
  });
github AKASHAorg / geth-connector / tests / index.js View on Github external
it('should change web3 provider', function () {
        index_1.GethConnector.getInstance().web3.setProvider(TestRPC.provider());
        chai_1.expect(index_1.GethConnector.getInstance().web3.currentProvider.manager).to.be.an('object');
    });
    it('should be able to call web3 methods', function (done) {

ethereumjs-testrpc

[![npm](https://img.shields.io/npm/v/ethereumjs-testrpc.svg)]() [![npm](https://img.shields.io/npm/dm/ethereumjs-testrpc.svg)]() [![Build Status](https://travis-ci.org/ethereumjs/testrpc.svg?branch=master)](https://travis-ci.org/ethereumjs/testrpc)

MIT
Latest version published 7 years ago

Package Health Score

47 / 100
Full package analysis

Popular ethereumjs-testrpc functions

Similar packages