Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmurdoch committed Feb 18, 2019
1 parent 8a030f4 commit 74d8e76
Show file tree
Hide file tree
Showing 47 changed files with 1,732 additions and 2,071 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ TODO
build
npm-shrinkwrap.json.bak
test/testdb
.nyc_output/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ The RPC methods currently implemented are:

There’s also special non-standard methods that aren’t included within the original RPC specification:

* `evm_snapshot` : Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the integer id of the snapshot created.
* `evm_snapshot` : Snapshot the state of the blockchain at the current block. Takes no parameters. Returns the integer id of the snapshot created. A snapshot can only be used once. After a successful `evm_revert`, the same snapshot id cannot be used again. Consider creating a new snapshot after each `evm_revert` if you need to revert to the same point multiple times.
* `evm_revert` : Revert the state of the blockchain to a previous snapshot. Takes a single parameter, which is the snapshot id to revert to. If no snapshot id is passed it will revert to the latest snapshot. Returns `true`.
* `evm_increaseTime` : Jump forward in time. Takes one parameter, which is the amount of time to increase in seconds. Returns the total time adjustment, in seconds.
* `evm_mine` : Force a block to be mined. Takes one optional parameter, which is the timestamp a block should setup as the mining time. Mines a block independent of whether or not mining is started or stopped.
Expand Down
2 changes: 1 addition & 1 deletion lib/provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Provider.prototype.send = function(payload, callback) {
.join("\n < ")
);
}
callback(response.error ? err : null, response);
process.nextTick(() => callback(response.error ? err : null, response));
};

if (self.options.verbose) {
Expand Down
1,826 changes: 733 additions & 1,093 deletions npm-shrinkwrap.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ganache-core",
"version": "2.4.0-beta.0",
"version": "2.4.0",
"main": "./index.js",
"engines": {
"node": ">=8.9.0"
Expand All @@ -10,17 +10,17 @@
},
"scripts": {
"_mocha": "mocha --check-leaks --recursive --globals _scratch,sanitizedData",
"nyc_mocha": "nyc mocha --check-leaks --recursive --globals _scratch,sanitizedData",
"_lint": "eslint --ignore-path .gitignore .",
"build": "webpack-cli --config ./webpack/node/core.webpack.config.js",
"build-web": "webpack-cli --config ./webpack/web-experimental/core.webpack.config.js",
"format": "prettier --write \"{lib,perf,test}/**/*.js\" && eslint --fix --ignore-path .gitignore .",
"prepublishOnly": "npm run test && npm run build && npm run test-build && mv npm-shrinkwrap.json npm-shrinkwrap.json.bak && npm prune --only=prod && npm shrinkwrap",
"postpublish": "rm npm-shrinkwrap.json && mv npm-shrinkwrap.json.bak npm-shrinkwrap.json && npm ci",
"test": "npm run _lint && npm run _mocha",
"test": "npm run _lint && npm run nyc_mocha",
"test-build": "cross-env TEST_BUILD=node npm run _mocha",
"test-web-experimental": "cross-env TEST_BUILD=web-experimental npm run _mocha",
"test-coverage": "nyc mocha --check-leaks --recursive --globals _scratch,sanitizedData",
"coverage": "npm run test-coverage && nyc report --reporter=text-lcov | coveralls"
"coverage": "nyc report --reporter=text-lcov | coveralls"
},
"dependencies": {
"abstract-leveldown": "3.0.0",
Expand All @@ -41,7 +41,7 @@
"heap": "0.2.6",
"level-sublevel": "6.6.4",
"levelup": "3.1.1",
"lodash": "4.17.10",
"lodash": "4.17.11",
"merkle-patricia-tree": "2.3.1",
"rlp": "2.1.0",
"seedrandom": "2.4.4",
Expand All @@ -62,12 +62,13 @@
"eslint-plugin-promise": "4.0.1",
"eslint-plugin-standard": "4.0.0",
"ethereumjs-wallet": "0.6.2",
"ethers": "^4.0.13",
"ethers": "4.0.23",
"husky": "^1.1.3",
"lint-staged": "^8.0.4",
"memdown": "^1.3.1",
"mocha": "5.2.0",
"mocha-lcov-reporter": "^1.3.0",
"number-to-bn": "1.7.0",
"nyc": "^13.1.0",
"pify": "4.0.0",
"portfinder": "^1.0.18",
Expand Down
9 changes: 2 additions & 7 deletions test/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,13 @@ describe("Accounts", function() {
value: web3.utils.toWei(new BN(1), "ether"),
gasLimit: 90000
},
function(err, tx) {
function(err) {
if (!err) {
return done(
new Error("We expected the account to be locked, which should throw an error when sending a transaction")
);
}
assert(
err.message.toLowerCase().indexOf("could not unlock signer account") >= 0,
"Expected error message containing \"could not unlock signer account\" " +
"(case insensitive check). Received the following error message, instead. " +
`"${err.message}"`
);
assert.strictEqual(err.message, "signer account is locked");
done();
}
);
Expand Down
4 changes: 0 additions & 4 deletions test/block_tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ var solc = require("solc");
var async = require("async");
var to = require("../lib/utils/to.js");

// Thanks solc. At least this works!
// This removes solc's overzealous uncaughtException event handler.
process.removeAllListeners("uncaughtException");

var source = fs.readFileSync("./test/contracts/examples/Example.sol", { encoding: "utf8" });
var result = solc.compile(source, 1);

Expand Down
18 changes: 3 additions & 15 deletions test/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ var Ganache = require(process.env.TEST_BUILD
var fs = require("fs");
var path = require("path");
var solc = require("solc");
var to = require("../lib/utils/to.js");

// Thanks solc. At least this works!
// This removes solc's overzealous uncaughtException event handler.
process.removeAllListeners("uncaughtException");
const toBytesHexString = require("./helpers/utils/toBytesHexString");

describe("eth_call", function() {
var web3 = new Web3(Ganache.provider({}));
Expand All @@ -19,7 +15,7 @@ describe("eth_call", function() {
var estimateGasContractAbi;
var EstimateGasContract;
var estimateGasInstance;
var source = fs.readFileSync(path.join(__dirname, "EstimateGas.sol"), "utf8");
var source = fs.readFileSync(path.join(__dirname, "contracts", "gas", "EstimateGas.sol"), "utf8");

before("get accounts", function(done) {
web3.eth.getAccounts(function(err, accs) {
Expand Down Expand Up @@ -54,18 +50,10 @@ describe("eth_call", function() {
// this call uses more than the default transaction gas limit and will
// therefore fail if the block gas limit isn't used for calls
return estimateGasInstance.methods
.add(toBytes("Tim"), toBytes("A great guy"), 5)
.add(toBytesHexString("Tim"), toBytesHexString("A great guy"), 5)
.call({ from: accounts[0] })
.then((result) => {
assert.strictEqual(result, true);
});
});

function toBytes(s) {
let bytes = Array.prototype.map.call(s, function(c) {
return c.codePointAt(0);
});

return to.hex(Buffer.from(bytes));
}
});
36 changes: 22 additions & 14 deletions test/call/undefined.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
const assert = require("assert");
const bootstrap = require("../helpers/bootstrap");
const bootstrap = require("../helpers/contract/bootstrap");

describe("Undefined", () => {
describe("Calls", () => {
const mainContract = "Call";
const contractFilenames = [];
const contractPath = "../contracts/call/";
const options = {
vmErrorsOnRPCResponse: false
};
let context;

const services = bootstrap(mainContract, contractFilenames, options, contractPath);
before("Setting up web3 and contract", async function() {
this.timeout(10000);

const contractRef = {
contractFiles: ["Call"],
contractSubdirectory: "call"
};

const ganacheProviderOptions = {
vmErrorsOnRPCResponse: false
};

context = await bootstrap(contractRef, ganacheProviderOptions);
});

it("should return `0x` when eth_call fails (web3.eth call)", async() => {
const { instance, web3 } = services;
const { instance, web3 } = context;

const signature = instance.methods.causeReturnValueOfUndefined()._method.signature;

Expand All @@ -26,7 +34,7 @@ describe("Undefined", () => {
});

it("should throw due to returned value of `0x` when eth_call fails (compiled contract call)", async() => {
const { instance } = services;
const { instance } = context;
try {
await instance.methods.causeReturnValueOfUndefined().call();
} catch (error) {
Expand All @@ -35,7 +43,7 @@ describe("Undefined", () => {
});

it("should return a value when contract and method exists at block (web3.eth.call)", async() => {
const { instance, web3 } = services;
const { instance, web3 } = context;

const signature = instance.methods.theAnswerToLifeTheUniverseAndEverything()._method.signature;
const params = {
Expand All @@ -52,13 +60,13 @@ describe("Undefined", () => {
});

it("should return a value when contract and method exists at block (compiled contract call)", async() => {
const { instance } = services;
const { instance } = context;
const result = await instance.methods.theAnswerToLifeTheUniverseAndEverything().call();
assert.strictEqual(result, "42");
});

it("should return 0x when contract doesn't exist at block", async() => {
const { instance, web3 } = services;
const { instance, web3 } = context;

const signature = instance.methods.theAnswerToLifeTheUniverseAndEverything()._method.signature;
const params = {
Expand All @@ -71,7 +79,7 @@ describe("Undefined", () => {
});

it("should return 0x when method doesn't exist at block", async() => {
const { instance, web3 } = services;
const { instance, web3 } = context;
const params = {
to: instance._address,
data: "0x01234567"
Expand Down
File renamed without changes.
29 changes: 0 additions & 29 deletions test/custom_gas_limit.js

This file was deleted.

37 changes: 0 additions & 37 deletions test/custom_gas_price.js

This file was deleted.

4 changes: 0 additions & 4 deletions test/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ var fs = require("fs");
var path = require("path");
var solc = require("solc");

// Thanks solc. At least this works!
// This removes solc's overzealous uncaughtException event handler.
process.removeAllListeners("uncaughtException");

describe("Debug", function() {
var provider;
var web3;
Expand Down
4 changes: 0 additions & 4 deletions test/enable_constantinople_hardfork.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ const fs = require("fs");
const path = require("path");
const solc = require("solc");

// Thanks solc. At least this works!
// This removes solc's overzealous uncaughtException event handler.
process.removeAllListeners("uncaughtException");

const mnemonic = "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";

describe("Constantinople Hardfork", function() {
Expand Down
4 changes: 0 additions & 4 deletions test/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ var source =
" } \n" +
"}";

// Thanks solc. At least this works!
// This removes solc's overzealous uncaughtException event handler.
process.removeAllListeners("uncaughtException");

var tests = function(web3, EventTest) {
var accounts;
var instance;
Expand Down
4 changes: 0 additions & 4 deletions test/forking.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ var solc = require("solc");
var to = require("../lib/utils/to.js");
var async = require("async");

// Thanks solc. At least this works!
// This removes solc's overzealous uncaughtException event handler.
process.removeAllListeners("uncaughtException");

var logger = {
log: function(msg) {
/* console.log(msg) */
Expand Down
4 changes: 0 additions & 4 deletions test/forking_deploy_after_fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ var Ganache = require(process.env.TEST_BUILD
var fs = require("fs");
var solc = require("solc");

// Thanks solc. At least this works!
// This removes solc's overzealous uncaughtException event handler.
process.removeAllListeners("uncaughtException");

var logger = {
log: function(msg) {
/* console.log(msg) */
Expand Down
4 changes: 0 additions & 4 deletions test/forkingasprovider.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ var Web3 = require("web3");
var fs = require("fs");
var assert = require("assert");

// Thanks solc. At least this works!
// This removes solc's overzealous uncaughtException event handler.
process.removeAllListeners("uncaughtException");

var logger = {
log: function(msg) {
/* noop */
Expand Down
Loading

0 comments on commit 74d8e76

Please sign in to comment.