From fcef8e08610df2c6686f2f5f056370a03edc5039 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 14 Oct 2018 05:15:09 -0700 Subject: [PATCH 1/9] Truffle config rename --- truffle.js => truffle-config.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename truffle.js => truffle-config.js (100%) diff --git a/truffle.js b/truffle-config.js similarity index 100% rename from truffle.js rename to truffle-config.js From 752f7c7d899500b4bbdf397011b37db86dcdecd1 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 14 Oct 2018 05:16:20 -0700 Subject: [PATCH 2/9] Windows support added --- .gitignore | 4 +++- README.md | 14 +++++++++++--- package.json | 1 + scripts/wintest.cmd | 13 +++++++++++++ 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 scripts/wintest.cmd diff --git a/.gitignore b/.gitignore index 5e131eaba..2859aef3d 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,6 @@ coverageEnv /flat /tempPoly .eslintrc.js -package-lock.json \ No newline at end of file +package-lock.json +bridge.log +.node-xml* \ No newline at end of file diff --git a/README.md b/README.md index 88f2407ec..91e1dd73d 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,7 @@ node CLI/polymath-cli dividends_manager - Homebrew v1.6.7 - node v8.x.x or v9.x.x +- npm v6.x.x or newer - Yarn v1.3 or newer - Truffle v4.1.11 (core: 4.1.11) - Solidity v0.4.24 (solc-js) @@ -221,10 +222,13 @@ The smart contracts are written in [Solidity](https://github.com/ethereum/solidi ```bash # Install Truffle package globally: -$ yarn global add truffle +$ npm install --global truffle + +# (Only for windows) set up build tools for node-gyp by running below command in powershell: +$ npm install --global --production windows-build-tools # Install local node dependencies: -$ yarn install +$ yarn ``` ## Testing @@ -232,7 +236,11 @@ $ yarn install To test the code simply run: ```bash -$ yarn run test +# on *nix systems +$ npm run test + +# on windows systems +$ npm run wintest ``` diff --git a/package.json b/package.json index f0d2f5ceb..43583a7f9 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "scripts": { "test": "scripts/test.sh 2> /dev/null", + "wintest": "scripts\\wintest.cmd", "docs": "scripts/docs.sh", "lint": "eslint .", "lint:fix": "eslint . --fix", diff --git a/scripts/wintest.cmd b/scripts/wintest.cmd new file mode 100644 index 000000000..0d0fe6b25 --- /dev/null +++ b/scripts/wintest.cmd @@ -0,0 +1,13 @@ +@echo off +@START /b node_modules\.bin\ganache-cli.cmd --gasLimit 8000000 --defaultBalanceEther 1000000000 --gasPrice 1 > %temp%\nul +@SET var=truffle test + +for %%i in (test\*.js) do call :PushTest %%i +%var% + +:PushTest +if NOT "%1" == "test\a_poly_oracle.js" ( + if NOT "%1" == "test\s_v130_to_v140_upgrade.js" ( + set var=%var% %1 + ) +) From 2dc8fbd19e413290039a8db3d0349b5ce18b0fbd Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Sun, 14 Oct 2018 20:39:01 +0530 Subject: [PATCH 3/9] Windows test accounts fixed --- scripts/wintest.cmd | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/wintest.cmd b/scripts/wintest.cmd index 0d0fe6b25..e5a2a6a61 100644 --- a/scripts/wintest.cmd +++ b/scripts/wintest.cmd @@ -1,5 +1,16 @@ @echo off -@START /b node_modules\.bin\ganache-cli.cmd --gasLimit 8000000 --defaultBalanceEther 1000000000 --gasPrice 1 > %temp%\nul + +@SET accounts=--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501203,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501204,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501205,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501206,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501207,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209,1000000000000000000000000" +@START /b node_modules\.bin\ganache-cli.cmd --gasLimit 8000000 --defaultBalanceEther 1000000000 --gasPrice 1 %accounts%> %temp%\nul @SET var=truffle test for %%i in (test\*.js) do call :PushTest %%i From 2bb13fa64823f0818f531299a73c9e38839a3d67 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Tue, 16 Oct 2018 10:35:07 +0530 Subject: [PATCH 4/9] Added coverage support on windows --- package.json | 1 + scripts/patch.js | 3 +++ scripts/wincov.cmd | 16 ++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 scripts/patch.js create mode 100644 scripts/wincov.cmd diff --git a/package.json b/package.json index 43583a7f9..8c322e8c0 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "scripts": { "test": "scripts/test.sh 2> /dev/null", "wintest": "scripts\\wintest.cmd", + "wincov": "scripts\\wincov.cmd", "docs": "scripts/docs.sh", "lint": "eslint .", "lint:fix": "eslint . --fix", diff --git a/scripts/patch.js b/scripts/patch.js new file mode 100644 index 000000000..c0a5bbc17 --- /dev/null +++ b/scripts/patch.js @@ -0,0 +1,3 @@ +const fs = require('fs'); +const request = require('request'); +request('https://raw.githubusercontent.com/maxsam4/solidity-coverage/relative-path/lib/app.js').pipe(fs.createWriteStream('node_modules\\solidity-coverage\\lib\\app.js')); \ No newline at end of file diff --git a/scripts/wincov.cmd b/scripts/wincov.cmd new file mode 100644 index 000000000..b2a433450 --- /dev/null +++ b/scripts/wincov.cmd @@ -0,0 +1,16 @@ +@echo off + +@SET accounts=--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501203,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501204,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501205,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501206,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501207,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208,1000000000000000000000000" ^ +--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209,1000000000000000000000000" +@START /b node_modules\.bin\ganache-cli.cmd --gasLimit 0xfffffffffff --defaultBalanceEther 1000000000 --gasPrice 1 %accounts%> %temp%\nul +node scripts\patch.js +node_modules\.bin\solidity-coverage.cmd + From 0451458f5465bb62ee0904c17d974a7a5682a3e3 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Tue, 16 Oct 2018 11:12:23 +0530 Subject: [PATCH 5/9] patch for solcover solcover --- .gitignore | 3 ++- scripts/patch.js | 23 ++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2859aef3d..f8c1da1e4 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ coverageEnv .eslintrc.js package-lock.json bridge.log -.node-xml* \ No newline at end of file +.node-xml* +.solcover.js \ No newline at end of file diff --git a/scripts/patch.js b/scripts/patch.js index c0a5bbc17..98bcec627 100644 --- a/scripts/patch.js +++ b/scripts/patch.js @@ -1,3 +1,24 @@ const fs = require('fs'); const request = require('request'); -request('https://raw.githubusercontent.com/maxsam4/solidity-coverage/relative-path/lib/app.js').pipe(fs.createWriteStream('node_modules\\solidity-coverage\\lib\\app.js')); \ No newline at end of file +const regex = /..\/n(.)*,/gmi; + +request('https://raw.githubusercontent.com/maxsam4/solidity-coverage/relative-path/lib/app.js').pipe(fs.createWriteStream('node_modules\\solidity-coverage\\lib\\app.js')); + +fs.readFile('.solcover.js', 'utf8', function (err,data) { + if (err) { + return console.log(err); + } + + let testCommand = '..\\\\node_modules\\\\.bin\\\\truffle.cmd test --network coverage'; + fs.readdirSync('./test').forEach(file => { + if(file != 'a_poly_oracle.js' && file != 's_v130_to_v140_upgrade.js') + testCommand = testCommand + ' ' + file; + }); + testCommand = testCommand + '\','; + + var result = data.replace(regex, testCommand); + + fs.writeFile('.solcover.js', result, 'utf8', function (err) { + if (err) return console.log(err); + }); +}); \ No newline at end of file From 0c4cb8fb0602570bc32e8630a6a4da61028d45ce Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Tue, 16 Oct 2018 11:37:13 +0530 Subject: [PATCH 6/9] coverage test command changed --- scripts/patch.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/patch.js b/scripts/patch.js index 98bcec627..8b4960305 100644 --- a/scripts/patch.js +++ b/scripts/patch.js @@ -1,6 +1,6 @@ const fs = require('fs'); const request = require('request'); -const regex = /..\/n(.)*,/gmi; +const regex = /node ..\/n(.)*,/gmi; request('https://raw.githubusercontent.com/maxsam4/solidity-coverage/relative-path/lib/app.js').pipe(fs.createWriteStream('node_modules\\solidity-coverage\\lib\\app.js')); @@ -8,11 +8,11 @@ fs.readFile('.solcover.js', 'utf8', function (err,data) { if (err) { return console.log(err); } - - let testCommand = '..\\\\node_modules\\\\.bin\\\\truffle.cmd test --network coverage'; + + let testCommand = 'truffle test --network coverage'; fs.readdirSync('./test').forEach(file => { if(file != 'a_poly_oracle.js' && file != 's_v130_to_v140_upgrade.js') - testCommand = testCommand + ' ' + file; + testCommand = testCommand + ' test\\\\' + file; }); testCommand = testCommand + '\','; From d4ecbe8f0e5c3def5334e36c5ca275920301241a Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Tue, 16 Oct 2018 12:19:42 +0530 Subject: [PATCH 7/9] Updated coverage script --- .gitignore | 2 +- scripts/patch.js | 5 +++-- scripts/wincov.cmd | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index f8c1da1e4..a65b840b5 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,4 @@ coverageEnv package-lock.json bridge.log .node-xml* -.solcover.js \ No newline at end of file +.solcover.js.bk \ No newline at end of file diff --git a/scripts/patch.js b/scripts/patch.js index 8b4960305..b1bbbcb3f 100644 --- a/scripts/patch.js +++ b/scripts/patch.js @@ -1,6 +1,7 @@ const fs = require('fs'); const request = require('request'); const regex = /node ..\/n(.)*,/gmi; +const regex2 = /truffle test(.)*,/gmi; request('https://raw.githubusercontent.com/maxsam4/solidity-coverage/relative-path/lib/app.js').pipe(fs.createWriteStream('node_modules\\solidity-coverage\\lib\\app.js')); @@ -15,8 +16,8 @@ fs.readFile('.solcover.js', 'utf8', function (err,data) { testCommand = testCommand + ' test\\\\' + file; }); testCommand = testCommand + '\','; - - var result = data.replace(regex, testCommand); + let result = data.replace(regex2, testCommand); + result = result.replace(regex, testCommand); fs.writeFile('.solcover.js', result, 'utf8', function (err) { if (err) return console.log(err); diff --git a/scripts/wincov.cmd b/scripts/wincov.cmd index b2a433450..854e42936 100644 --- a/scripts/wincov.cmd +++ b/scripts/wincov.cmd @@ -10,7 +10,9 @@ --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501207,1000000000000000000000000" ^ --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208,1000000000000000000000000" ^ --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209,1000000000000000000000000" -@START /b node_modules\.bin\ganache-cli.cmd --gasLimit 0xfffffffffff --defaultBalanceEther 1000000000 --gasPrice 1 %accounts%> %temp%\nul +@START /b node_modules\.bin\testrpc-sc.cmd --gasLimit 0xfffffffffff --defaultBalanceEther 1000000000 --gasPrice 1 --port 8545 %accounts%> %temp%\nul + +@COPY .solcover.js .solcover.js.bk node scripts\patch.js node_modules\.bin\solidity-coverage.cmd - +@MOVE /y .solcover.js.bk .solcover.js From d7cc2dc66a4621eea2f7bca5e405d224e84f21d5 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Tue, 16 Oct 2018 12:41:55 +0530 Subject: [PATCH 8/9] updated gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a65b840b5..1693ab75c 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ coverageEnv package-lock.json bridge.log .node-xml* -.solcover.js.bk \ No newline at end of file +.solcover.js.bk +allFiredEvents \ No newline at end of file From 696ebb0b7678fe37d2a7ae6582a06782e6518ab8 Mon Sep 17 00:00:00 2001 From: Mudit Gupta Date: Tue, 16 Oct 2018 16:18:38 +0530 Subject: [PATCH 9/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 91e1dd73d..98173db84 100644 --- a/README.md +++ b/README.md @@ -208,10 +208,10 @@ node CLI/polymath-cli dividends_manager ## Package version requirements for your machine: -- Homebrew v1.6.7 - node v8.x.x or v9.x.x - npm v6.x.x or newer - Yarn v1.3 or newer +- Homebrew v1.6.7 (for macOS) - Truffle v4.1.11 (core: 4.1.11) - Solidity v0.4.24 (solc-js) - Ganache CLI v6.1.3 (ganache-core: 2.1.2) or newer