diff --git a/.github/workflows/js-integration-test.yml b/.github/workflows/js-integration-test.yml index 5c57d81..2d4fb8a 100644 --- a/.github/workflows/js-integration-test.yml +++ b/.github/workflows/js-integration-test.yml @@ -32,19 +32,14 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: "16.20.0" + node-version: "20.10.0" cache: "npm" - - name: Install npm@9.8.0 - run: npm i -g npm@9.8.0 + - name: Install npm@10.2.3 + run: npm i -g npm@10.2.3 - name: Install dependencies run: npm ci --prefer-offline - - - name: Reinstall zeromq because of Debian bug - run: | - npm uninstall zeromq - npm install zeromq@6.0.0-beta.17 --zmq-shared - name: Test with jest run: | diff --git a/README.md b/README.md index ef54481..e65d881 100644 --- a/README.md +++ b/README.md @@ -2,33 +2,12 @@ JavaScript RPC Client for EdgePi RPC Server ## Installing as an NPM module -If you are not on a debian system, you can simply run the following npm command on any machine: ``` npm install @edgepi-cloud/edgepi-rpc ``` -## Installing as an NPM module on Debian systems -There is currently an issue regularly installing zeromq as a dependency on debian systems. The culprit is the following error: -``` -symbol lookup error: /**/node_modules/zeromq/build/Release/zeromq.node: undefined symbol: sodium_init -``` -To get around this issue, you must first install the zeromq library (libzmq) -``` -sudo apt update -sudo apt install libzmq3-dev -``` -You will then need to npm install the zeromq dependency specifying that you want to build with with installed -library from the previous step. First ensure you have necessary build dependancies -``` -sudo apt-get update && sudo apt-get install -y build-essential cmake -``` -Then npm install zeromq with the shared library. -``` -npm install zeromq@6.0.0-beta.17 --zmq-shared -``` -Now you can simply install edgepi-rpc with the organization's scope from npm -``` -npm install @edgepi-cloud/edgepi-rpc +## Install build dependencies + ``` -If you run into any issues with zeromq after installing the edgepi-rpc package, try reinstalling zeromq -ensuring that it was built against the shared library. For further help installing zeromq, checkout their [github](https://github.com/zeromq/zeromq.js/). +sudo apt update && sudo apt install cmake +``` \ No newline at end of file diff --git a/__mocks__/zeromq.js b/__mocks__/zeromq.js deleted file mode 100644 index edc8647..0000000 --- a/__mocks__/zeromq.js +++ /dev/null @@ -1,19 +0,0 @@ -"use strict"; -class MockRequest { - constructor() { - // Do nothing - } - connect(_mock_endpoint) { - // Do nothing; mock the connect method - } - send(_request_data) { - // Do nothing - } - receive() { - // Do nothing - } -} -const zeromq = { - Request: MockRequest, // Use the custom MockRequest instead of zmq.Request -}; -module.exports = zeromq; diff --git a/jest.config.js b/jest.config.js index e5fbf09..ecbfb69 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,6 @@ /** @type {import('ts-jest').JestConfigWithTsJest} */ module.exports = { preset: 'ts-jest', - testEnvironment: 'node' + testEnvironment: 'node', + maxWorkers: 1 // Forces tests to run sequentially instead of in parallel. Issue: https://github.com/EdgePi-Cloud/edgepi-rpc-client-js/issues/46 } diff --git a/package-lock.json b/package-lock.json index 46ba5e7..27475ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@types/node": "^20.4.2", "protobufjs": "^7.2.4", "protobufjs-cli": "^1.1.1", - "zeromq": "^6.0.0-beta.17" + "zeromq": "^6.0.0-beta.19" }, "devDependencies": { "@types/jest": "^29.5.3", @@ -37,13 +37,13 @@ } }, "node_modules/@aminya/node-gyp-build": { - "version": "4.5.0-aminya.4", - "resolved": "https://registry.npmjs.org/@aminya/node-gyp-build/-/node-gyp-build-4.5.0-aminya.4.tgz", - "integrity": "sha512-2c2+BqZOxfTz/m+1MNWncMyMgil2WOg8cHhKPf1qUo1t9ohOWOgSeb7TVVD4fnTxIcAcpWdmXBpFkjPRyBVS9g==", + "version": "4.5.0-aminya.5", + "resolved": "https://registry.npmjs.org/@aminya/node-gyp-build/-/node-gyp-build-4.5.0-aminya.5.tgz", + "integrity": "sha512-TO7GldxDfSeSRNZVmhlm0liS2GX2o2Q/qTlcD3iD4ltTM6dir568LTRZ+ZDsDbLfMAkfhrbU+VuzNYImwYfczg==", "bin": { - "node-gyp-build": "bin.js", - "node-gyp-build-optional": "optional.js", - "node-gyp-build-test": "build-test.js" + "aminya-node-gyp-build": "bin.js", + "aminya-node-gyp-build-optional": "optional.js", + "aminya-node-gyp-build-test": "build-test.js" } }, "node_modules/@ampproject/remapping": { @@ -4693,9 +4693,9 @@ "license": "MIT" }, "node_modules/node-addon-api": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-6.1.0.tgz", - "integrity": "sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==" + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.0.0.tgz", + "integrity": "sha512-vgbBJTS4m5/KkE16t5Ly0WW9hz46swAstv0hYYwMtbG7AznRhNyfLRe8HZAiWIpcHzoO7HxhLuBQj9rJ/Ho0ZA==" }, "node_modules/node-int64": { "version": "0.4.0", @@ -6093,14 +6093,14 @@ } }, "node_modules/zeromq": { - "version": "6.0.0-beta.17", - "resolved": "https://registry.npmjs.org/zeromq/-/zeromq-6.0.0-beta.17.tgz", - "integrity": "sha512-Tt5L2oBZ1WYsh0rgItpgFHzym5s8UWW7ZScSmwdfP8FP0GD0eJ0ZO0AOjmhqpSZEMQyMUbY5bc/6Xffw/hfkTQ==", + "version": "6.0.0-beta.19", + "resolved": "https://registry.npmjs.org/zeromq/-/zeromq-6.0.0-beta.19.tgz", + "integrity": "sha512-2eU6H7Z4r9LmTkseGdIfEqp0k3rJr5EpXQw2oC0bUqy3wpoj1M83IU/c3qHPXp0z8IklNMoVmVm130d3g2Xf3g==", "hasInstallScript": true, "dependencies": { - "@aminya/node-gyp-build": "4.5.0-aminya.4", + "@aminya/node-gyp-build": "4.5.0-aminya.5", "cross-env": "^7.0.3", - "node-addon-api": "^6.0.0", + "node-addon-api": "^7.0.0", "shelljs": "^0.8.5", "shx": "^0.3.4" }, diff --git a/package.json b/package.json index aa3beae..b4665a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@edgepi-cloud/edgepi-rpc", - "version": "1.0.10", + "version": "1.0.11", "author": "Isaac James", "main": "./lib/index.js", "license": "MIT", @@ -17,7 +17,7 @@ "@types/node": "^20.4.2", "protobufjs": "^7.2.4", "protobufjs-cli": "^1.1.1", - "zeromq": "^6.0.0-beta.17" + "zeromq": "^6.0.0-beta.19" }, "devDependencies": { "@types/jest": "^29.5.3", diff --git a/tests/integration/AdcService.test.ts b/tests/integration/AdcService.test.ts index cfb4b8a..ae0a148 100644 --- a/tests/integration/AdcService.test.ts +++ b/tests/integration/AdcService.test.ts @@ -9,7 +9,7 @@ describe('AdcService', ()=> { let adc: AdcService beforeAll(async() =>{ - adc = new AdcService('tcp://192.168.1.216:5555'); + adc = new AdcService('tcp://localhost:5555'); // set rtds off await adc.setRtd(false, ADCNum.ADC_1) await adc.setRtd(false, ADCNum.ADC_2) diff --git a/tests/integration/bug-fixes.test.ts b/tests/integration/bug-fixes.test.ts new file mode 100644 index 0000000..be3eb61 --- /dev/null +++ b/tests/integration/bug-fixes.test.ts @@ -0,0 +1,11 @@ +const zmq = require('zeromq'); + +jest.unmock('zeromq') + +describe('zeromq bug fix', () => { + test('should create zmq.Context without libsodium error', () => { + expect(() => { + let a = new zmq.Context(); + }).not.toThrow(); + }); +}); diff --git a/tsconfig.json b/tsconfig.json index 9d978aa..e53d138 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,5 +13,7 @@ "outDir": "./lib" }, "include": [ - "./src"] + "./src", + "./jest.config.js" + ] }