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

Commit

Permalink
Fix a messy merge
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmurdoch committed Jul 15, 2019
1 parent 852278d commit 82acc5f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
21 changes: 13 additions & 8 deletions lib/blockchain_double.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,16 +533,21 @@ BlockchainDouble.prototype.processCall = function(tx, blockNumber, callback) {
return;
}

// create a fake block with this fake transaction
self.createBlock(parentBlock, false, function(err, newBlock) {
if (err) {
callback(err);
return;
vm.runTx(runArgs, function(vmerr, result) {
// This is a check that has been in there for awhile. I'm unsure if it's required, but it can't hurt.
if (vmerr && vmerr instanceof Error === false) {
vmerr = new Error("VM error: " + vmerr);
}

// If no vm error, check for a runtime error. This can return null if no runtime error.
const runtimeErr = RuntimeError.fromResults([tx], { results: [result] });
callback(runtimeErr, result);
// If we're given an error back directly, it's worse than a runtime error. Expose it and get out.
if (vmerr) {
return callback(vmerr, err);
}

// If no error, check for a runtime error. This can return null if no runtime error.
vmerr = RuntimeError.fromResults([tx], { results: [result] });

callback(vmerr, result);
});
});
};
Expand Down
4 changes: 2 additions & 2 deletions lib/subproviders/geth_api_double.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { BlockOutOfRangeError } = require("../utils/errorhelper");

var Subprovider = require("web3-provider-engine/subproviders/subprovider.js");

const maxUInt64 = "0x" + Number.MAX_SAFE_INTEGER.toString(16);
const maxSafeInt = "0x" + Number.MAX_SAFE_INTEGER.toString(16);

inherits(GethApiDouble, Subprovider);

Expand Down Expand Up @@ -346,7 +346,7 @@ GethApiDouble.prototype._setCallGasLimit = function(txData) {
// otherwise, set a very high gas limit. We'd use Infinity, or some VM flag to ignore gasLimit checks like
// geth does, but the VM doesn't currently support that for `runTx`.
// https://github.com/ethereumjs/ethereumjs-vm/blob/4bbb6e394a344717890d618a6be1cf67b8e5b74d/lib/runTx.ts#L71
txData.gas = maxUInt64;
txData.gas = maxSafeInt;
}
}
};
Expand Down
21 changes: 10 additions & 11 deletions test/call.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ const assert = require("assert");
const bootstrap = require("./helpers/contract/bootstrap");

describe("eth_call", function() {
it("should use the call gas limit if no call gas limit is specified in the call", async function() {
const contractRef = {
contractFiles: ["EstimateGas"],
contractSubdirectory: "gas"
};
let context;
const contractRef = {
contractFiles: ["EstimateGas"],
contractSubdirectory: "gas"
};

context = await bootstrap(contractRef, {
it("should use the call gas limit if no call gas limit is specified in the call", async function() {
const context = await bootstrap(contractRef, {
callGasLimit: "0x6691b7"
});
const { accounts, instance } = context;
Expand All @@ -25,14 +24,12 @@ describe("eth_call", function() {
assert.strictEqual(status, true);
});

it("should use maxUInt64 call gas limit if no gas limit is specified in the provider or the call", async function() {
it("should use max call gas limit if no gas limit is specified in the provider or the call", async function() {
const contractRef = {
contractFiles: ["EstimateGas"],
contractSubdirectory: "gas"
};
let context;

context = await bootstrap(contractRef);
const context = await bootstrap(contractRef);
const { accounts, instance } = context;

const name = "0x54696d"; // Byte code for "Tim"
Expand All @@ -47,6 +44,8 @@ describe("eth_call", function() {
});

it("should use the current block number via `eth_call`", async() => {
const context = await bootstrap(contractRef);

const actualBlockNumber = await context.web3.eth.getBlockNumber();
// should read the block number, too
const callBlockNumber = await context.instance.methods.currentBlock().call();
Expand Down
2 changes: 1 addition & 1 deletion test/contracts/gas/EstimateGas.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ contract EstimateGas {
return true;
}

function currentBlock() returns (uint) {
function currentBlock() public returns (uint) {
return block.number;
}
}
2 changes: 1 addition & 1 deletion test/debug/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function test(forked) {

assert.strictEqual(lastop.op, "STOP");
assert.strictEqual(lastop.gasCost, 1);
assert.strictEqual(lastop.pc, 208);
assert.strictEqual(lastop.pc, 235);
assert.strictEqual(
lastop.storage["0000000000000000000000000000000000000000000000000000000000000000"],
"000000000000000000000000000000000000000000000000000000000000001a"
Expand Down

0 comments on commit 82acc5f

Please sign in to comment.