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

Commit

Permalink
Merge pull request #100 from Xcrux/develop
Browse files Browse the repository at this point in the history
fix (most) global leaks
  • Loading branch information
benjamincburns authored Apr 12, 2018
2 parents 762e882 + ce0c1af commit 8681e43
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions lib/blockchain_double.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ BlockchainDouble.prototype.sortByPriceAndNonce = function() {

// Now reorder our transactions. Compare the next transactions from each account, and choose
// the one with the highest gas price.
sorted_transactions = [];
const sorted_transactions = [];
while (heap.size()>0){
best = heap.pop();
const best = heap.pop();
let address = to.hex(best.from)
if (sortedByNonce[address].length>0){
//Push on the next transaction from this account
Expand Down Expand Up @@ -840,7 +840,7 @@ BlockchainDouble.prototype.processStorageTrace = function(structLog, storageStac
var key;
var value;
switch(name) {
case 'SSTORE':
case 'SSTORE':
key = to.rpcDataHexString(args[1], 64).replace('0x','')
value = to.rpcDataHexString(args[0], 64).replace('0x','')
// use Object.assign to prevent future steps from overwriting this step's storage values
Expand Down
5 changes: 2 additions & 3 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ module.exports = {

var server = httpServer(provider, logger);

connectionCounter = 0;
connections = {};
let connectionCounter = 0;
const connections = {};
server.on('connection', conn => {
let key = connectionCounter++;
connections[key] = conn;
Expand Down Expand Up @@ -80,4 +80,3 @@ const defaultOptions = {
var _applyDefaultOptions = function(options) {
return _.merge({}, defaultOptions, options)
}

2 changes: 1 addition & 1 deletion lib/utils/to.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = {

hexWithZeroPadding: function(val) {
val = this.hex(val);
digits = val.replace("0x", "");
const digits = val.replace("0x", "");
if (digits.length & 0x1) {
return "0x0" + digits;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"lib": "./lib"
},
"scripts": {
"test": "mocha"
"test": "mocha --check-leaks --globals _scratch"
},
"dependencies": {
"abstract-leveldown": "^3.0.0",
Expand Down
6 changes: 3 additions & 3 deletions test/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var tests = function(web3, EventTest) {
var result = solc.compile(source, 1);

if (result.errors != null) {
done(result.errors[0])
done(result.errors[0])
}

var abi = JSON.parse(result.contracts[":EventTest"].interface);
Expand Down Expand Up @@ -110,7 +110,7 @@ var tests = function(web3, EventTest) {
var waitingFor = {}
waitingFor[expectedValueA] = true
waitingFor[expectedValueB] = true

var listener = function(result) {
assert(waitingFor.hasOwnProperty(result.returnValues.first))
delete waitingFor[result.returnValues.first]
Expand Down Expand Up @@ -179,7 +179,7 @@ var tests = function(web3, EventTest) {

let listener = function (err, result) {
if (err) return done(err);
first_changes = result.params.result.hash;
const first_changes = result.params.result.hash;
assert.equal(first_changes.length, 66); // Ensure we have a hash
provider.removeAllListeners('data')
done();
Expand Down
2 changes: 1 addition & 1 deletion test/forking.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ describe("Forking", function() {
var solcResult = solc.compile(oracleSol);
var oracleOutput = solcResult.contracts[":Oracle"];

return oracleContract = new mainWeb3.eth.Contract(JSON.parse(oracleOutput.interface))
return new mainWeb3.eth.Contract(JSON.parse(oracleOutput.interface))
.deploy({ data: oracleOutput.bytecode })
.send({ from: mainAccounts[0], gas: 3141592 })
.then(function(oracle){
Expand Down
3 changes: 2 additions & 1 deletion test/persistence.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ process.removeAllListeners("uncaughtException");

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

// Note: Certain properties of the following contract data are hardcoded to
// maintain repeatable tests. If you significantly change the solidity code,
Expand Down Expand Up @@ -83,7 +84,7 @@ var runTests = function(providerInit) {
provider.close(done);
});
});

it("should reopen the provider", function (done) {
providerInit(function(p) {
provider = p;
Expand Down
4 changes: 2 additions & 2 deletions test/transaction_rejection.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe("Transaction rejection", function() {
var EstimateGasContractAddress;
var estimateGasInstance;
var deploymentReceipt;
var estimateGasContractAddress;
var source = fs.readFileSync(path.join(__dirname, "EstimateGas.sol"), "utf8");

before("get accounts", function(done) {
Expand Down Expand Up @@ -144,7 +145,7 @@ describe("Transaction rejection", function() {
} else if (response.result) {
web3.eth.getTransactionReceipt(response.result)
.then((result) => {
if (to.number(result.status) == 0) {
if (to.number(result.status) == 0) {
return done(new Error('TX rejections should return error, but returned receipt with zero status instead'))
} else {
return done(new Error(`TX should have rejected prior to running. Instead transaction ran successfully (receipt.status == ${to.number(result.status)})`))
Expand All @@ -158,4 +159,3 @@ describe("Transaction rejection", function() {
})
}
})

0 comments on commit 8681e43

Please sign in to comment.