diff --git a/.gitignore b/.gitignore index 5e131eaba..1693ab75c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,8 @@ coverageEnv /flat /tempPoly .eslintrc.js -package-lock.json \ No newline at end of file +package-lock.json +bridge.log +.node-xml* +.solcover.js.bk +allFiredEvents \ No newline at end of file diff --git a/README.md b/README.md index 88f2407ec..98173db84 100644 --- a/README.md +++ b/README.md @@ -208,9 +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 @@ -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..8c322e8c0 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,8 @@ }, "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..b1bbbcb3f --- /dev/null +++ b/scripts/patch.js @@ -0,0 +1,25 @@ +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')); + +fs.readFile('.solcover.js', 'utf8', function (err,data) { + if (err) { + return console.log(err); + } + + 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 + ' test\\\\' + file; + }); + testCommand = 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); + }); +}); \ No newline at end of file diff --git a/scripts/wincov.cmd b/scripts/wincov.cmd new file mode 100644 index 000000000..854e42936 --- /dev/null +++ b/scripts/wincov.cmd @@ -0,0 +1,18 @@ +@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\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 diff --git a/scripts/wintest.cmd b/scripts/wintest.cmd new file mode 100644 index 000000000..e5a2a6a61 --- /dev/null +++ b/scripts/wintest.cmd @@ -0,0 +1,24 @@ +@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 8000000 --defaultBalanceEther 1000000000 --gasPrice 1 %accounts%> %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 + ) +) diff --git a/truffle.js b/truffle-config.js similarity index 100% rename from truffle.js rename to truffle-config.js