diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..67f5307 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,16 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "plugins": [ + "@typescript-eslint", + "prettier" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "prettier/prettier": "error" + } +} diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index b98af6a..b5d29a6 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -1,33 +1,28 @@ name: Node CI -on: - push: - branches: - - $default-branch - pull_request: - branches: - - "*" - +on: [push] +env: + FORCE_COLOR: 2 jobs: - build: - - runs-on: ubuntu-latest - + test: + name: v${{ matrix.node }} @ ${{ matrix.os }} + runs-on: ${{ matrix.os }} strategy: matrix: - node-version: [12.x, 14.x, 16.x] - + node: [14, 16, 18] + os: [ubuntu-latest] steps: - - uses: actions/checkout@v1 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v1 + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node }} + uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} - - name: npm install, build, and test + node-version: ${{ matrix.node }} + - run: npm install + - name: Build and run tests + run: | + npm run build --if-present + npm test + - name: Run browser tests and lint run: | - npm install - npm run test npm run browser-tests npm run lint - env: - CI: true \ No newline at end of file diff --git a/.mocharc.json b/.mocharc.json new file mode 100644 index 0000000..f10a5b3 --- /dev/null +++ b/.mocharc.json @@ -0,0 +1,8 @@ +{ + "require" : [ + "ts-node/register" + ], + "spec": "./test/test-vectors/*.ts", + "package": "./package.json", + "ui": "bdd" +} diff --git a/package.json b/package.json index cacbb22..5867c8a 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ ], "dependencies": { "@noble/hashes": "1.1.2", - "@noble/secp256k1": "1.6.2", + "@noble/secp256k1": "1.6.3", "@scure/bip32": "1.1.0", "@scure/bip39": "1.1.0" }, @@ -40,8 +40,8 @@ "test": "npm-run-all test:node", "test:node": "mocha", "clean": "rimraf test-builds bip39 '*.js' '*.js.map' '*.d.ts' '*.d.ts.map' 'src/**/*.js'", - "lint": "tslint --project tsconfig.json", - "lint:fix": "tslint --fix --project tsconfig.json", + "lint": "eslint", + "lint:fix": "eslint --fix", "browser-tests": "npm-run-all browser-tests:build browser-tests:test", "browser-tests:build": "bash -x ./scripts/build-browser-tests.sh", "browser-tests:test": "npm-run-all browser-tests:test-parcel browser-tests:test-browserify browser-tests:test-webpack browser-tests:test-rollup", @@ -51,30 +51,30 @@ "browser-tests:test-rollup": "karma start --single-run --browsers ChromeHeadless test/karma.rollup.conf.js" }, "devDependencies": { - "@rollup/plugin-commonjs": "^20.0.0", - "@rollup/plugin-node-resolve": "^13.0.4", - "@types/mocha": "^5.2.7", - "@types/node": "^16.9.2", - "browserify": "^16.5.0", - "karma": "^4.3.0", - "karma-chrome-launcher": "^3.1.0", - "karma-mocha": "^1.3.0", - "karma-mocha-reporter": "^2.2.5", - "mocha": "^6.2.0", - "npm-run-all": "^4.1.5", - "parcel": "^2.0.0-rc.0", - "prettier": "1.18.2", - "rimraf": "^3.0.0", - "rollup": "^2.53.0", - "rollup-plugin-commonjs": "^10.1.0", - "rollup-plugin-node-resolve": "^5.2.0", - "ts-node": "^8.3.0", - "tslint": "^5.19.0", - "tslint-config-prettier": "^1.18.0", - "tslint-plugin-prettier": "^2.0.1", - "typescript": "4.5.4", - "webpack": "^4.39.3", - "webpack-cli": "^3.3.8" + "@rollup/plugin-commonjs": "22.0.1", + "@rollup/plugin-node-resolve": "13.3.0", + "@types/estree": "0.0.47", + "@types/mocha": "9.1.1", + "@types/node": "18.0.4", + "@typescript-eslint/eslint-plugin": "5.30.6", + "@typescript-eslint/parser": "5.30.6", + "browserify": "17.0.0", + "eslint": "8.19.0", + "eslint-plugin-prettier": "4.2.1", + "karma": "6.4.0", + "karma-chrome-launcher": "3.1.1", + "karma-mocha": "2.0.1", + "karma-mocha-reporter": "2.2.5", + "mocha": "10.0.0", + "npm-run-all": "4.1.5", + "parcel": "2.6.2", + "prettier": "2.7.1", + "rimraf": "~3.0.2", + "rollup": "2.76.0", + "ts-node": "10.9.1", + "typescript": "4.7.3", + "webpack": "5.73.0", + "webpack-cli": "4.10" }, "keywords": [ "ethereum", diff --git a/scripts/build-browser-tests.sh b/scripts/build-browser-tests.sh index 315bebd..a42b2c6 100644 --- a/scripts/build-browser-tests.sh +++ b/scripts/build-browser-tests.sh @@ -10,7 +10,7 @@ echo "Building tests with Browserify" npx browserify test-builds/tsc/test/test-vectors/*.js > test-builds/browserify-build.js echo "Building tests with webpack" -npx webpack --mode development test-builds/tsc/test/test-vectors/*.js --output test-builds/webpack-build.js +npx webpack --mode development ./test-builds/tsc/test/test-vectors/*.js --output-path ./test-builds echo "Building tests with Rollup" rollup -c test/rollup.config.js diff --git a/test/karma.webpack.conf.js b/test/karma.webpack.conf.js index 999af31..30a5765 100644 --- a/test/karma.webpack.conf.js +++ b/test/karma.webpack.conf.js @@ -1,7 +1,7 @@ module.exports = function(config) { config.set({ frameworks: ["mocha"], - files: ["../test-builds/webpack-build.js"], + files: ["../test-builds/main.js"], colors: true, logLevel: config.LOG_INFO, browsers: ["ChromeHeadless"], diff --git a/test/mocha.opts b/test/mocha.opts deleted file mode 100644 index ae70e30..0000000 --- a/test/mocha.opts +++ /dev/null @@ -1,2 +0,0 @@ ---require ts-node/register -test/test-vectors/*.ts diff --git a/test/test-vectors/scrypt.ts b/test/test-vectors/scrypt.ts index 484e408..1da86ca 100644 --- a/test/test-vectors/scrypt.ts +++ b/test/test-vectors/scrypt.ts @@ -39,7 +39,7 @@ describe("scrypt", function() { describe("scrypt sync", function() { for (let i = 0; i < TEST_VECTORS.length; i++) { it(`Should process the test ${i} correctly`, function() { - this.enableTimeouts(false); + this.timeout(10000) const vector = TEST_VECTORS[i]; @@ -60,7 +60,7 @@ describe("scrypt", function() { describe("scrypt async", function() { for (let i = 0; i < TEST_VECTORS.length; i++) { it(`Should process the test ${i} correctly`, async function() { - this.enableTimeouts(false); + this.timeout(10000); const vector = TEST_VECTORS[i];