aedes 0.51.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/actions/sticky-pr-comment/action.yml +55 -0
- package/.github/workflows/benchmark-compare-serial.yml +60 -0
- package/.github/workflows/ci.yml +12 -17
- package/.release-it.json +18 -0
- package/.taprc +15 -6
- package/README.md +6 -4
- package/aedes.d.ts +0 -6
- package/aedes.js +270 -242
- package/benchmarks/README.md +33 -0
- package/benchmarks/pingpong.js +94 -25
- package/benchmarks/receiver.js +77 -0
- package/benchmarks/report.js +150 -0
- package/benchmarks/runBenchmarks.js +118 -0
- package/benchmarks/sender.js +86 -0
- package/benchmarks/server.js +19 -18
- package/checkVersion.js +20 -0
- package/docs/Aedes.md +66 -8
- package/docs/Client.md +3 -4
- package/docs/Examples.md +39 -22
- package/docs/MIGRATION.md +50 -0
- package/eslint.config.js +8 -0
- package/example.js +51 -40
- package/examples/clusters/index.js +28 -23
- package/examples/clusters/package.json +10 -6
- package/lib/client.js +405 -306
- package/lib/handlers/connect.js +42 -38
- package/lib/handlers/index.js +9 -11
- package/lib/handlers/ping.js +2 -3
- package/lib/handlers/puback.js +5 -5
- package/lib/handlers/publish.js +29 -14
- package/lib/handlers/pubrec.js +9 -17
- package/lib/handlers/pubrel.js +34 -25
- package/lib/handlers/subscribe.js +47 -43
- package/lib/handlers/unsubscribe.js +16 -19
- package/lib/qos-packet.js +14 -17
- package/lib/utils.js +5 -12
- package/lib/write.js +4 -5
- package/package.json +134 -136
- package/test/auth.js +468 -804
- package/test/basic.js +613 -575
- package/test/bridge.js +44 -40
- package/test/client-pub-sub.js +531 -504
- package/test/close_socket_by_other_party.js +137 -102
- package/test/connect.js +487 -484
- package/test/drain-timeout.js +593 -0
- package/test/drain-toxiproxy.js +620 -0
- package/test/events.js +173 -145
- package/test/helper.js +351 -73
- package/test/keep-alive.js +40 -67
- package/test/meta.js +257 -210
- package/test/not-blocking.js +93 -197
- package/test/qos1.js +464 -554
- package/test/qos2.js +308 -393
- package/test/regr-21.js +39 -21
- package/test/require.cjs +22 -0
- package/test/retain.js +349 -398
- package/test/topics.js +176 -183
- package/test/types/aedes.test-d.ts +4 -8
- package/test/will.js +310 -428
- package/types/instance.d.ts +40 -35
- package/types/packet.d.ts +10 -10
- package/.coveralls.yml +0 -1
- package/benchmarks/bombing.js +0 -34
- package/benchmarks/bombingQoS1.js +0 -36
- package/benchmarks/throughputCounter.js +0 -23
- package/benchmarks/throughputCounterQoS1.js +0 -33
- package/types/.eslintrc.json +0 -47
package/test/bridge.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { test } from 'node:test'
|
|
2
|
+
import {
|
|
3
|
+
createAndConnect,
|
|
4
|
+
subscribe,
|
|
5
|
+
checkNoPacket,
|
|
6
|
+
nextPacket
|
|
7
|
+
} from './helper.js'
|
|
5
8
|
|
|
6
9
|
for (const qos of [0, 1, 2]) {
|
|
7
10
|
const packet = {
|
|
@@ -13,45 +16,46 @@ for (const qos of [0, 1, 2]) {
|
|
|
13
16
|
|
|
14
17
|
if (qos > 0) packet.messageId = 42
|
|
15
18
|
|
|
16
|
-
test(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
s.inStream.write({ cmd: 'pubrel', messageId: 42 })
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
s.inStream.write(packet)
|
|
36
|
-
})
|
|
19
|
+
test(`normal client sends a publish message and shall receive it back, qos = ${qos}`, async (t) => {
|
|
20
|
+
t.plan(4)
|
|
21
|
+
const s = await createAndConnect(t)
|
|
22
|
+
await subscribe(t, s, 'hello', qos)
|
|
23
|
+
|
|
24
|
+
s.inStream.write(packet)
|
|
25
|
+
for await (const packet of s.outStream) {
|
|
26
|
+
if (packet.cmd === 'publish') {
|
|
27
|
+
t.assert.ok(true, 'got publish packet')
|
|
28
|
+
break
|
|
29
|
+
}
|
|
30
|
+
if (packet.cmd === 'pubrec') {
|
|
31
|
+
s.inStream.write({ cmd: 'pubrel', messageId: 42 })
|
|
32
|
+
}
|
|
33
|
+
}
|
|
37
34
|
})
|
|
38
35
|
|
|
39
|
-
test(
|
|
36
|
+
test(`bridge client sends a publish message but shall not receive it back, qos = ${qos}`, async (t) => {
|
|
37
|
+
t.plan(6)
|
|
40
38
|
// protocolVersion 128 + 4 means mqtt 3.1.1 with bridgeMode enabled
|
|
41
39
|
// https://github.com/mqttjs/mqtt-packet/blob/7f7c2ed8bcb4b2c582851d120a94e0b4a731f661/parser.js#L171
|
|
42
|
-
const s =
|
|
43
|
-
t
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
const s = await createAndConnect(t, { connect: { clientId: 'my-client-bridge-1', bridgeMode: true } })
|
|
41
|
+
await subscribe(t, s, 'hello', qos)
|
|
42
|
+
s.inStream.write(packet)
|
|
43
|
+
if (qos === 0) {
|
|
44
|
+
t.assert.ok(true) // need two extra asserts to match QoS2
|
|
45
|
+
t.assert.ok(true) // need two extra asserts to match QoS2
|
|
46
|
+
}
|
|
47
|
+
if (qos === 1) {
|
|
48
|
+
const pkt = await nextPacket(s)
|
|
49
|
+
t.assert.equal(pkt.cmd, 'puback', 'received QoS1 puback')
|
|
50
|
+
t.assert.ok(true) // need an extra assert to match QoS2
|
|
51
|
+
}
|
|
52
|
+
if (qos === 2) {
|
|
53
|
+
const pkt = await nextPacket(s)
|
|
54
|
+
t.assert.equal(pkt.cmd, 'pubrec', 'received QoS2 pubRec')
|
|
55
|
+
s.inStream.write({ cmd: 'pubrel', messageId: 42 })
|
|
56
|
+
const pkt2 = await nextPacket(s)
|
|
57
|
+
t.assert.equal(pkt2.cmd, 'pubcomp', 'received QoS2 pubcomp')
|
|
58
|
+
}
|
|
59
|
+
await checkNoPacket(t, s)
|
|
56
60
|
})
|
|
57
61
|
}
|