From 236d13733566be4b96ae61b16037b477eeb72cea Mon Sep 17 00:00:00 2001 From: Dimitri Stallenberg Date: Mon, 16 Jan 2023 15:31:03 +0100 Subject: [PATCH 1/4] Lock and update some dependencies --- package.json | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index 749fceb..5448347 100644 --- a/package.json +++ b/package.json @@ -53,16 +53,16 @@ "@truffle/config": "^1.2.44", "@truffle/provider": "^0.1.17", "bignumber.js": "9.0.1", - "chalk": "^2.4.2", - "clear": "^0.1.0", + "chalk": "4.1.1", + "clear": "0.1.0", "detect-port": "^1.3.0", - "figlet": "^1.5.0", + "figlet": "1.5.2", "fs-extra": "^8.1.0", "ganache-cli": "^6.12.2", "global-modules": "^2.0.0", - "globby": "^10.0.1", + "globby": "^11.0.4", "lodash": "^4.17.15", - "mocha": "^8.3.1", + "mocha": "10.2.0", "pify": "^4.0.1", "recursive-readdir": "^2.2.2", "sc-istanbul": "^0.4.5", @@ -73,20 +73,20 @@ "web3-utils": "^1.5.2" }, "devDependencies": { - "@types/chai": "^4.2.15", - "@types/chai-as-promised": "^7.1.4", - "@types/mocha": "^8.2.2", - "@types/node": "^14.17.4", - "@types/sinon": "^9.0.11", - "@typescript-eslint/eslint-plugin": "^4.28.1", - "@typescript-eslint/parser": "^4.28.1", - "chai": "^4.3.3", - "eslint": "^7.30.0", - "eslint-config-prettier": "^8.1.0", + "@types/chai": "4.3.4", + "@types/chai-as-promised": "7.1.1", + "@types/mocha": "10.0.1", + "@types/node": "18.11.17", + "@types/sinon": "10.0.13", + "@typescript-eslint/eslint-plugin": "5.45.1", + "@typescript-eslint/parser": "5.45.1", + "chai": "4.3.7", + "eslint": "8.29.0", + "eslint-config-prettier": "8.5.0", "mocha": "10.2.0", - "nyc": "^15.1.0", - "prettier": "^2.3.2", - "sinon": "^9.2.4", + "nyc": "15.1.0", + "prettier": "2.8.1", + "sinon": "15.0.1", "ts-node": "10.9.1", "typescript": "4.9.4" }, From 256ea27e0760b95d55fcabd4ea9bce7bcaaf4412 Mon Sep 17 00:00:00 2001 From: Dimitri Stallenberg Date: Mon, 16 Jan 2023 17:08:59 +0100 Subject: [PATCH 2/4] Remove ganache dependency --- package.json | 5 ++--- src/SolidityLauncher.ts | 1 + src/api.js | 9 +-------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 5448347..ad2c2a8 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ "detect-port": "^1.3.0", "figlet": "1.5.2", "fs-extra": "^8.1.0", - "ganache-cli": "^6.12.2", "global-modules": "^2.0.0", "globby": "^11.0.4", "lodash": "^4.17.15", @@ -69,8 +68,8 @@ "semver": "^7.3.5", "solidity-coverage": "^0.7.16", "truffle": "5.1.65", - "web3": "^1.3.4", - "web3-utils": "^1.5.2" + "web3": "1.8.1", + "web3-utils": "1.8.1" }, "devDependencies": { "@types/chai": "4.3.4", diff --git a/src/SolidityLauncher.ts b/src/SolidityLauncher.ts index 357f34a..1a35121 100644 --- a/src/SolidityLauncher.ts +++ b/src/SolidityLauncher.ts @@ -219,6 +219,7 @@ export class SolidityLauncher { const client = this.api.client || this.truffle.ganache; const address = await this.api.ganache(client); + console.log(client) const web3 = new Web3(address); const accounts = await web3.eth.getAccounts(); const nodeInfo = await web3.eth.getNodeInfo(); diff --git a/src/api.js b/src/api.js index 4cb8f64..4df1225 100644 --- a/src/api.js +++ b/src/api.js @@ -125,14 +125,7 @@ class API { : true; // Attach to vm step of supplied client - try { - if (this.config.forceBackupServer) throw new Error(); - await this.attachToVM(client); - } catch (err) { - // Fallback to ganache-cli) - const _ganache = require("ganache-cli"); - await this.attachToVM(_ganache); - } + await this.attachToVM(client); if (autoLaunchServer === false || this.autoLaunchServer === false) { return this.server; From 4b703814bc9157f0d0dbdca17c3d9fa9d59ca68d Mon Sep 17 00:00:00 2001 From: Dimitri Stallenberg Date: Tue, 17 Jan 2023 10:57:59 +0100 Subject: [PATCH 3/4] Update or remove old packages --- api.js | 1 - package.json | 11 +++++------ src/SolidityLauncher.ts | 12 ------------ src/api.js | 17 ++++++++++++++--- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/api.js b/api.js index e6ce964..cbb87ff 100644 --- a/api.js +++ b/api.js @@ -1,4 +1,3 @@ -// For require('solidity-coverage/api'); const api = require("./src/api"); module.exports = api; diff --git a/package.json b/package.json index ad2c2a8..c88f7c6 100644 --- a/package.json +++ b/package.json @@ -50,19 +50,18 @@ "dependencies": { "@solidity-parser/parser": "0.14.5", "@syntest/core": "0.2.0", - "@truffle/config": "^1.2.44", - "@truffle/provider": "^0.1.17", + "@truffle/config": "1.3.49", + "@truffle/provider": "0.3.3", "bignumber.js": "9.0.1", "chalk": "4.1.1", "clear": "0.1.0", - "detect-port": "^1.3.0", + "detect-port": "1.3.0", "figlet": "1.5.2", - "fs-extra": "^8.1.0", + "fs-extra": "11.1.0", "global-modules": "^2.0.0", "globby": "^11.0.4", - "lodash": "^4.17.15", + "lodash.clonedeep": "4.5.0", "mocha": "10.2.0", - "pify": "^4.0.1", "recursive-readdir": "^2.2.2", "sc-istanbul": "^0.4.5", "semver": "^7.3.5", diff --git a/src/SolidityLauncher.ts b/src/SolidityLauncher.ts index 1a35121..910d996 100644 --- a/src/SolidityLauncher.ts +++ b/src/SolidityLauncher.ts @@ -91,7 +91,6 @@ import { const pkg = require("../package.json"); const Web3 = require("web3"); -const { outputFileSync } = require("fs-extra"); export class SolidityLauncher { private readonly _program = "syntest-solidity"; @@ -341,17 +340,6 @@ export class SolidityLauncher { // Instrument await targetPool.prepareAndInstrument(this.api); - // const instrumented = this.api.instrument(targetPool, targetPaths); - - // for (const instrumentedTarget of instrumented) { - // const _path = path - // .normalize(instrumentedTarget.canonicalPath) - // .replace( - // this.config.contracts_directory, - // Properties.temp_instrumented_directory - // ); - // await outputFileSync(_path, instrumentedTarget.source); - // } this.config.contracts_directory = Properties.temp_instrumented_directory; this.config.build_directory = this.tempArtifactsDir; diff --git a/src/api.js b/src/api.js index 4df1225..d1a8dee 100644 --- a/src/api.js +++ b/src/api.js @@ -1,4 +1,3 @@ -const pify = require("pify"); const fs = require("fs"); const path = require("path"); const istanbul = require("sc-istanbul"); @@ -12,6 +11,7 @@ const Instrumenter = require("./instrumentation/instrumenter"); // Local version const Coverage = require("solidity-coverage/lib/coverage"); const DataCollector = require("./instrumentation/collector"); // Local version const { AppUI } = require("solidity-coverage/lib/ui"); +const { reject } = require("lodash"); /** * Coverage Runner @@ -131,7 +131,14 @@ class API { return this.server; } - await pify(this.server.listen)(this.port); + await new Promise((resolve, reject) => { + this.server.listen(this.port, (err) => { + if (err) { + return reject() + } + resolve() + }) + }) return `http://${this.host}:${this.port}`; } @@ -183,7 +190,11 @@ class API { */ async finish() { if (this.server && this.server.close) { - await pify(this.server.close)(); + await new Promise((resolve) => { + this.server.close(() => { + resolve() + }) + }) } } // ------------------------------------------ Utils ---------------------------------------------- From f217042d2167fe36c74fbb348565a3d81457be4c Mon Sep 17 00:00:00 2001 From: Dimitri Stallenberg Date: Tue, 17 Jan 2023 11:22:05 +0100 Subject: [PATCH 4/4] Remove console.log --- src/SolidityLauncher.ts | 1 - src/api.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/SolidityLauncher.ts b/src/SolidityLauncher.ts index 910d996..c9d05c7 100644 --- a/src/SolidityLauncher.ts +++ b/src/SolidityLauncher.ts @@ -218,7 +218,6 @@ export class SolidityLauncher { const client = this.api.client || this.truffle.ganache; const address = await this.api.ganache(client); - console.log(client) const web3 = new Web3(address); const accounts = await web3.eth.getAccounts(); const nodeInfo = await web3.eth.getNodeInfo(); diff --git a/src/api.js b/src/api.js index d1a8dee..3308c39 100644 --- a/src/api.js +++ b/src/api.js @@ -11,7 +11,6 @@ const Instrumenter = require("./instrumentation/instrumenter"); // Local version const Coverage = require("solidity-coverage/lib/coverage"); const DataCollector = require("./instrumentation/collector"); // Local version const { AppUI } = require("solidity-coverage/lib/ui"); -const { reject } = require("lodash"); /** * Coverage Runner