diff --git a/.crossbar/key.priv b/.crossbar/key.priv deleted file mode 100644 index 074572828..000000000 --- a/.crossbar/key.priv +++ /dev/null @@ -1,11 +0,0 @@ -Crossbar.io node private key - KEEP THIS SAFE! - -creator: oberstet@intel-nuci7 -created-at: 2023-01-16T10:13:47.153Z -machine-id: 816b4b901e774fc1ad59cbf2719806b7 -node-authid: intel-nuci7 -node-cluster-ip: 127.0.0.1 -public-key-ed25519: 04ffa62e526aa0ff648cd61be4cc9d92f80e973485473647f76e96bef0d84dfe -public-adr-eth: 0x62E7Af2CF452e820051210D237723E5914fB53F4 -private-key-ed25519: 39e3c34e472b6b5e6b93f73690584471f5c717b7320ea393d90d4f15a9747338 -private-key-eth: 3dcf36bafeb82d1b3927389847c68f1920c33c5f3607fffb4b2561da24351849 diff --git a/.crossbar/key.pub b/.crossbar/key.pub deleted file mode 100644 index 20adf7673..000000000 --- a/.crossbar/key.pub +++ /dev/null @@ -1,9 +0,0 @@ -Crossbar.io node public key - -creator: oberstet@intel-nuci7 -created-at: 2023-01-16T10:13:47.153Z -machine-id: 816b4b901e774fc1ad59cbf2719806b7 -node-authid: intel-nuci7 -node-cluster-ip: 127.0.0.1 -public-key-ed25519: 04ffa62e526aa0ff648cd61be4cc9d92f80e973485473647f76e96bef0d84dfe -public-adr-eth: 0x62E7Af2CF452e820051210D237723E5914fB53F4 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb9b6512c..5baba4448 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,12 +1,13 @@ name: Autobahn JS CI on: + workflow_dispatch: push: branches: - - master + - $default-branch pull_request: branches: - - master + - $default-branch jobs: unittest: @@ -16,13 +17,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - # https://de.wikipedia.org/wiki/Node.js#Versionen - node: ['14', '18', '19'] + node: [lts/-2, lts/-1, lts/*] name: Node ${{ matrix.node }} run steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} @@ -34,11 +34,10 @@ jobs: - name: Install dependencies run: | - sudo apt update - sudo npm install -g nodeunit - sudo pip3 install --no-cache-dir -U scons boto taschenmesser + cd packages/autobahn + npm install - name: Run tests run: | - cd packages/autobahn && npm install - make test + cd packages/autobahn + npm run test diff --git a/.gitignore b/.gitignore index b2c793621..5b1fcf71b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ package/.crossbar/ package-lock.json packages/autobahn-xbr/lib/contracts/ packages/autobahn-xbr/contracts/ +packages/autobahn/coverage/ \ No newline at end of file diff --git a/packages/autobahn/.c8rc.json b/packages/autobahn/.c8rc.json new file mode 100644 index 000000000..9cb19d107 --- /dev/null +++ b/packages/autobahn/.c8rc.json @@ -0,0 +1,13 @@ +{ + "all": true, + "sourceMap": false, + "include": [ + "lib/**/*.js" + ], + "report-dir": "./coverage", + "temp-dir": "./coverage", + "reporter": [ + "lcov", + "text-summary" + ] +} \ No newline at end of file diff --git a/packages/autobahn/lib/log.js b/packages/autobahn/lib/log.js index b48ccbbbf..6650cf5bd 100644 --- a/packages/autobahn/lib/log.js +++ b/packages/autobahn/lib/log.js @@ -28,8 +28,6 @@ if ('console' in global) { } } -console.log('Sdfsdf'); - // write debug messages to tracefile if AUTOBAHN_TRACE is set as environment variable - only works on NodeJS if ('process' in global && process.env.AUTOBAHN_TRACE) { debug = function () { diff --git a/packages/autobahn/lib/transport/rawsocket.js b/packages/autobahn/lib/transport/rawsocket.js index 4f6256b30..08b5e2c78 100644 --- a/packages/autobahn/lib/transport/rawsocket.js +++ b/packages/autobahn/lib/transport/rawsocket.js @@ -41,6 +41,8 @@ Factory.prototype.create = function () { var self = this; + log.debug("rawsocket.Factory.create"); + // the WAMP transport we create var transport = {}; diff --git a/packages/autobahn/lib/transport/websocket.js b/packages/autobahn/lib/transport/websocket.js index 7dc7cbd0f..73f1748db 100644 --- a/packages/autobahn/lib/transport/websocket.js +++ b/packages/autobahn/lib/transport/websocket.js @@ -35,6 +35,7 @@ function Factory (options) { if (!options.protocols) { options.protocols = []; options.serializers.forEach(function (ser) { + util.assert(typeof ser.SERIALIZER_ID === "string", "options.serializers[].SERIALIZER_ID must be a string"); options.protocols.push("wamp.2." + ser.SERIALIZER_ID); }); } else { @@ -71,6 +72,8 @@ Factory.prototype.create = function () { var self = this; + log.debug("websocket.Factory.create"); + // the WAMP transport we create var transport = {}; diff --git a/packages/autobahn/package.json b/packages/autobahn/package.json index 3028ee590..ec60f7724 100644 --- a/packages/autobahn/package.json +++ b/packages/autobahn/package.json @@ -8,7 +8,8 @@ "/lib" ], "scripts": { - "test": "nodeunit test/test.js" + "test": "nodeunit test/test.js", + "test:coverage": "c8 nodeunit test/test.js" }, "engines": { "node": ">= 7.10.1" @@ -22,6 +23,7 @@ }, "optionalDependencies": { "bufferutil": ">= 1.2.1", + "c8": "^8.0.1", "utf-8-validate": ">= 1.2.1", "when": ">= 3.7.7" }, diff --git a/packages/autobahn/test/README.md b/packages/autobahn/test/README.md index 733d3d01e..b3c579a44 100644 --- a/packages/autobahn/test/README.md +++ b/packages/autobahn/test/README.md @@ -4,7 +4,12 @@ Tests run using NodeJS and the nodeunit package. First, ensure that a Crossbar.io instance is running with the default configuration (use `crossbar init` if needed). This will run a WAMP-over-WebSocket transport at `ws://localhost:8080/ws`. -> You should be able to use any compliant WAMP router (on `ws://localhost:8080/ws`) - your mileage may vary though. +> You should be able to use any compliant WAMP router (on `ws://localhost:8080/ws`) - your mileage may vary though. + +The easiest way is to use Docker (in the root directory of the repository): +```console +docker run -it -v $PWD/.crossbar:/node -p 8080:8080 -p 8090:8090 -u $UID crossbario/crossbar --cbdir /node +``` Then, open a terminal and run `npm test` in the `package` directory. diff --git a/packages/autobahn/test/test.js b/packages/autobahn/test/test.js index 964f21375..b51364823 100644 --- a/packages/autobahn/test/test.js +++ b/packages/autobahn/test/test.js @@ -63,8 +63,8 @@ exports.testCBORSerialization = serialization_cbor.testCBORSerialization; exports.testCBORLargePayload = serialization_cbor.testCBORLargePayload; exports.testBinaryCBOR = binary.testBinaryCBOR; -// exports.testBinaryMsgPack = binary.testBinaryMsgPack; -// exports.testBinaryJSON = binary.testBinaryJSON; +exports.testBinaryMsgPack = binary.testBinaryMsgPack; +exports.testBinaryJSON = binary.testBinaryJSON; exports.testRawSocketTransport = rawsocket_transport.testRawSocketTransport; diff --git a/packages/autobahn/test/test_binary.js b/packages/autobahn/test/test_binary.js index 8deace9ec..05e5a4f68 100644 --- a/packages/autobahn/test/test_binary.js +++ b/packages/autobahn/test/test_binary.js @@ -32,8 +32,7 @@ function run_test (test, ser) { var done = autobahn.when.defer(); var config = { - //url: testutil.config.url, - url: "ws://127.0.0.1:8090", + url: testutil.config.url, realm: testutil.config.realm, serializers: [ser] }; @@ -71,14 +70,6 @@ function run_test (test, ser) { {a: 5, b: "hello2", c: [1, 2, 3]}, [-9007199254740991, 9007199254740991], null, - // UTC of today - BigInt('1558266424841951553'), - // 2**255-1 : NotImplementedError TODO: TAG BIGNUM for bigger bignum bytes_info=24, len(ull)=8 - // BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819967'), - BigInt('340282366920938463463374607431768211455'), - Uint8Array.from([0, 1, 2, 3, 4, 5, 6, 7]), - randomBytes(32), - {a: 5, b: "hello2", c: randomBytes(32)} ]; for (var i = 0; i < vals1.length; ++i) { @@ -144,7 +135,11 @@ function run_test (test, ser) { function () { test.log("Registration failed!", arguments); } - ); + ) + .catch(function (error) { + connection.close(); + done.reject(error); + }); }; connection.open(); @@ -192,7 +187,7 @@ exports.testBinaryJSON = function (testcase) { var dl = []; - dl.push(run_test(testcase, test, new autobahn.serializer.JSONSerializer())); + dl.push(run_test(test, new autobahn.serializer.JSONSerializer())); autobahn.when.all(dl).then(function () { var chk = test.check(); diff --git a/packages/autobahn/test/test_binary_cbor.txt b/packages/autobahn/test/test_binary_cbor.txt index d7a1a9920..443dc9b0c 100644 --- a/packages/autobahn/test/test_binary_cbor.txt +++ b/packages/autobahn/test/test_binary_cbor.txt @@ -10,29 +10,13 @@ 9 " c, 1,2,3" 10 "Result [com.myapp.echo]: -9007199254740991,9007199254740991" 11 "Result [com.myapp.echo]: null" -12 "Result [com.myapp.echo]: 1558266424841951553" -13 "Result [com.myapp.echo]: 340282366920938463463374607431768211455" -14 "Result [com.myapp.echo]: 0,1,2,3,4,5,6,7" -15 "Result [com.myapp.echo]: 8f44d509e0492acec4fc109a030a5c751f063fb743cc388f0ed722bacc3bc66c" -16 "Result [com.myapp.echo]:" -17 " a, 5" -18 " b, hello2" -19 " c, 035e7711c8da2e9434aab5039dc3d72046dee4e57af0e957e948fbbad15e48f8" -20 "Result [any.echo]: 1.7" -21 "Result [any.echo]: hello" -22 "Result [any.echo]: 1,2,-3" -23 "Result [any.echo]:" -24 " a, 5" -25 " b, hello2" -26 " c, 1,2,3" -27 "Result [any.echo]: -9007199254740991,9007199254740991" -28 "Result [any.echo]: null" -29 "Result [any.echo]: 1558266424841951553" -30 "Result [any.echo]: 340282366920938463463374607431768211455" -31 "Result [any.echo]: 0,1,2,3,4,5,6,7" -32 "Result [any.echo]: 8f44d509e0492acec4fc109a030a5c751f063fb743cc388f0ed722bacc3bc66c" -33 "Result [any.echo]:" -34 " a, 5" -35 " b, hello2" -36 " c, 035e7711c8da2e9434aab5039dc3d72046dee4e57af0e957e948fbbad15e48f8" -37 "All finished." +12 "Result [any.echo]: 1.7" +13 "Result [any.echo]: hello" +14 "Result [any.echo]: 1,2,-3" +15 "Result [any.echo]:" +16 " a, 5" +17 " b, hello2" +18 " c, 1,2,3" +19 "Result [any.echo]: -9007199254740991,9007199254740991" +20 "Result [any.echo]: null" +21 "All finished." diff --git a/packages/autobahn/test/test_binary_json.txt b/packages/autobahn/test/test_binary_json.txt new file mode 100644 index 000000000..7fb80b301 --- /dev/null +++ b/packages/autobahn/test/test_binary_json.txt @@ -0,0 +1,22 @@ +0 "Connected: wamp.2.json" +1 "All registered." +2 "Serializer ID: json" +3 "Result [com.myapp.echo]: 1.7" +4 "Result [com.myapp.echo]: hello" +5 "Result [com.myapp.echo]: 1,2,-3" +6 "Result [com.myapp.echo]:" +7 " a, 5" +8 " b, hello2" +9 " c, 1,2,3" +10 "Result [com.myapp.echo]: -9007199254740991,9007199254740991" +11 "Result [com.myapp.echo]: null" +12 "Result [any.echo]: 1.7" +13 "Result [any.echo]: hello" +14 "Result [any.echo]: 1,2,-3" +15 "Result [any.echo]:" +16 " a, 5" +17 " b, hello2" +18 " c, 1,2,3" +19 "Result [any.echo]: -9007199254740991,9007199254740991" +20 "Result [any.echo]: null" +21 "All finished." diff --git a/packages/autobahn/test/test_binary_msgpack.txt b/packages/autobahn/test/test_binary_msgpack.txt new file mode 100644 index 000000000..e4a4663c6 --- /dev/null +++ b/packages/autobahn/test/test_binary_msgpack.txt @@ -0,0 +1,22 @@ +0 "Connected: wamp.2.msgpack" +1 "All registered." +2 "Serializer ID: msgpack" +3 "Result [com.myapp.echo]: 1.7" +4 "Result [com.myapp.echo]: hello" +5 "Result [com.myapp.echo]: 1,2,-3" +6 "Result [com.myapp.echo]:" +7 " a, 5" +8 " b, hello2" +9 " c, 1,2,3" +10 "Result [com.myapp.echo]: -9007199254740991,9007199254740991" +11 "Result [com.myapp.echo]: null" +12 "Result [any.echo]: 1.7" +13 "Result [any.echo]: hello" +14 "Result [any.echo]: 1,2,-3" +15 "Result [any.echo]:" +16 " a, 5" +17 " b, hello2" +18 " c, 1,2,3" +19 "Result [any.echo]: -9007199254740991,9007199254740991" +20 "Result [any.echo]: null" +21 "All finished."