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/topics.js
CHANGED
|
@@ -1,117 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { test } from 'node:test'
|
|
2
|
+
import { once } from 'node:events'
|
|
3
|
+
import {
|
|
4
|
+
checkNoPacket,
|
|
5
|
+
createAndConnect,
|
|
6
|
+
createPubSub,
|
|
7
|
+
nextPacket,
|
|
8
|
+
subscribe,
|
|
9
|
+
} from './helper.js'
|
|
10
|
+
import { validateTopic } from '../lib/utils.js'
|
|
11
|
+
|
|
12
|
+
test('validation of `null` topic', (t) => {
|
|
9
13
|
// issue #780
|
|
10
14
|
t.plan(1)
|
|
11
15
|
const err = validateTopic(null, 'SUBSCRIBE')
|
|
12
|
-
t.equal(err.message, 'impossible to SUBSCRIBE to an empty topic')
|
|
16
|
+
t.assert.equal(err.message, 'impossible to SUBSCRIBE to an empty topic')
|
|
13
17
|
})
|
|
14
18
|
|
|
15
19
|
// [MQTT-4.7.1-3]
|
|
16
|
-
test('Single-level wildcard should match empty level',
|
|
20
|
+
test('Single-level wildcard should match empty level', async (t) => {
|
|
17
21
|
t.plan(4)
|
|
18
22
|
|
|
19
|
-
const s =
|
|
20
|
-
t.teardown(s.broker.close.bind(s.broker))
|
|
23
|
+
const s = await createAndConnect(t)
|
|
21
24
|
|
|
22
|
-
subscribe(t, s, 'a/+/b', 0
|
|
23
|
-
s.outStream.once('data', function (packet) {
|
|
24
|
-
t.pass('ok')
|
|
25
|
-
})
|
|
25
|
+
await subscribe(t, s, 'a/+/b', 0)
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
27
|
+
s.inStream.write({
|
|
28
|
+
cmd: 'publish',
|
|
29
|
+
topic: 'a//b',
|
|
30
|
+
payload: 'world'
|
|
32
31
|
})
|
|
32
|
+
|
|
33
|
+
const packet = await nextPacket(s)
|
|
34
|
+
t.assert.ok(packet, 'ok')
|
|
33
35
|
})
|
|
34
36
|
|
|
35
37
|
// [MQTT-4.7.3-1]
|
|
36
|
-
test('publish empty topic',
|
|
37
|
-
t.plan(
|
|
38
|
+
test('publish empty topic', async (t) => {
|
|
39
|
+
t.plan(5)
|
|
38
40
|
|
|
39
|
-
const s =
|
|
41
|
+
const s = await createAndConnect(t)
|
|
40
42
|
|
|
41
|
-
subscribe(t, s, '#', 0
|
|
42
|
-
s.outStream.once('data', function (packet) {
|
|
43
|
-
t.fail('no packet')
|
|
44
|
-
})
|
|
43
|
+
await subscribe(t, s, '#', 0)
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
s.inStream.write({
|
|
46
|
+
cmd: 'publish',
|
|
47
|
+
topic: '',
|
|
48
|
+
payload: 'world'
|
|
49
|
+
})
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
await checkNoPacket(t, s)
|
|
52
|
+
await new Promise((resolve) => {
|
|
53
|
+
s.broker.close(() => {
|
|
54
|
+
resolve()
|
|
54
55
|
})
|
|
55
56
|
})
|
|
57
|
+
t.assert.equal(s.broker.connectedClients, 0, 'no connected clients')
|
|
56
58
|
})
|
|
57
59
|
|
|
58
|
-
test('publish invalid topic with #',
|
|
59
|
-
t.plan(
|
|
60
|
+
test('publish invalid topic with #', async (t) => {
|
|
61
|
+
t.plan(6)
|
|
60
62
|
|
|
61
|
-
const s =
|
|
62
|
-
t.teardown(s.broker.close.bind(s.broker))
|
|
63
|
+
const s = await createAndConnect(t)
|
|
63
64
|
|
|
64
|
-
subscribe(t, s, '#', 0
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
s.inStream.write({
|
|
70
|
-
cmd: 'publish',
|
|
71
|
-
topic: 'hello/#',
|
|
72
|
-
payload: 'world'
|
|
73
|
-
})
|
|
65
|
+
await subscribe(t, s, '#', 0)
|
|
66
|
+
s.inStream.write({
|
|
67
|
+
cmd: 'publish',
|
|
68
|
+
topic: 'hello/#',
|
|
69
|
+
payload: 'world'
|
|
74
70
|
})
|
|
75
71
|
|
|
76
|
-
s.broker
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
const [client, err] = await once(s.broker, 'clientError')
|
|
73
|
+
t.assert.ok(client, 'client is defined')
|
|
74
|
+
t.assert.equal(err.message, '# is not allowed in PUBLISH', 'raise an error')
|
|
75
|
+
await checkNoPacket(t, s)
|
|
79
76
|
})
|
|
80
77
|
|
|
81
|
-
test('publish invalid topic with +',
|
|
82
|
-
t.plan(
|
|
83
|
-
|
|
84
|
-
const s = connect(setup())
|
|
85
|
-
t.teardown(s.broker.close.bind(s.broker))
|
|
78
|
+
test('publish invalid topic with +', async (t) => {
|
|
79
|
+
t.plan(6)
|
|
86
80
|
|
|
87
|
-
|
|
88
|
-
s.outStream.once('data', function (packet) {
|
|
89
|
-
t.fail('no packet')
|
|
90
|
-
})
|
|
81
|
+
const s = await createAndConnect(t)
|
|
91
82
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
83
|
+
await subscribe(t, s, '+', 0)
|
|
84
|
+
s.inStream.write({
|
|
85
|
+
cmd: 'publish',
|
|
86
|
+
topic: 'hello/+/eee',
|
|
87
|
+
payload: 'world'
|
|
97
88
|
})
|
|
98
89
|
|
|
99
|
-
s.broker
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
const [client, err] = await once(s.broker, 'clientError')
|
|
91
|
+
t.assert.ok(client, 'client is defined')
|
|
92
|
+
t.assert.equal(err.message, '+ is not allowed in PUBLISH', 'raise an error')
|
|
93
|
+
await checkNoPacket(t, s)
|
|
102
94
|
})
|
|
103
95
|
|
|
104
|
-
|
|
105
|
-
|
|
96
|
+
for (const topic of [
|
|
97
|
+
'base/#/sub',
|
|
98
|
+
'base/#sub',
|
|
99
|
+
'base/sub#',
|
|
100
|
+
'base/xyz+/sub',
|
|
101
|
+
'base/+xyz/sub',
|
|
102
|
+
''
|
|
103
|
+
]) {
|
|
104
|
+
test(`subscribe to invalid topic with "${topic}"`, async (t) => {
|
|
106
105
|
t.plan(1)
|
|
107
106
|
|
|
108
|
-
const s =
|
|
109
|
-
t.teardown(s.broker.close.bind(s.broker))
|
|
110
|
-
|
|
111
|
-
s.broker.on('clientError', function () {
|
|
112
|
-
t.pass('raise an error')
|
|
113
|
-
})
|
|
114
|
-
|
|
107
|
+
const s = await createAndConnect(t)
|
|
115
108
|
s.inStream.write({
|
|
116
109
|
cmd: 'subscribe',
|
|
117
110
|
messageId: 24,
|
|
@@ -120,34 +113,29 @@ test('publish invalid topic with +', function (t) {
|
|
|
120
113
|
qos: 0
|
|
121
114
|
}]
|
|
122
115
|
})
|
|
116
|
+
await once(s.broker, 'clientError')
|
|
117
|
+
t.assert.ok(true, 'raise an error')
|
|
123
118
|
})
|
|
124
119
|
|
|
125
|
-
test(
|
|
120
|
+
test(`unsubscribe to invalid topic with "${topic}"`, async (t) => {
|
|
126
121
|
t.plan(1)
|
|
127
122
|
|
|
128
|
-
const s =
|
|
129
|
-
t.teardown(s.broker.close.bind(s.broker))
|
|
130
|
-
|
|
131
|
-
s.broker.on('clientError', function () {
|
|
132
|
-
t.pass('raise an error')
|
|
133
|
-
})
|
|
123
|
+
const s = await createAndConnect(t)
|
|
134
124
|
|
|
135
125
|
s.inStream.write({
|
|
136
126
|
cmd: 'unsubscribe',
|
|
137
127
|
messageId: 24,
|
|
138
128
|
unsubscriptions: [topic]
|
|
139
129
|
})
|
|
130
|
+
await once(s.broker, 'clientError')
|
|
131
|
+
t.assert.ok(true, 'raise an error')
|
|
140
132
|
})
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
test('topics are case-sensitive', function (t) {
|
|
144
|
-
t.plan(4)
|
|
133
|
+
}
|
|
145
134
|
|
|
146
|
-
|
|
147
|
-
t.
|
|
135
|
+
test('topics are case-sensitive', async (t) => {
|
|
136
|
+
t.plan(5)
|
|
148
137
|
|
|
149
|
-
const publisher
|
|
150
|
-
const subscriber = connect(setup(broker), { clean: true })
|
|
138
|
+
const { publisher, subscriber } = await createPubSub(t)
|
|
151
139
|
const expected = {
|
|
152
140
|
cmd: 'publish',
|
|
153
141
|
topic: 'hello',
|
|
@@ -158,145 +146,150 @@ test('topics are case-sensitive', function (t) {
|
|
|
158
146
|
retain: false
|
|
159
147
|
}
|
|
160
148
|
|
|
161
|
-
subscribe(t, subscriber, 'hello', 0
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
payload: 'world',
|
|
170
|
-
qos: 0,
|
|
171
|
-
retain: false
|
|
172
|
-
})
|
|
149
|
+
await subscribe(t, subscriber, 'hello', 0)
|
|
150
|
+
for (const topic of ['hello', 'HELLO', 'heLLo', 'HELLO/#', 'hello/+']) {
|
|
151
|
+
publisher.inStream.write({
|
|
152
|
+
cmd: 'publish',
|
|
153
|
+
topic,
|
|
154
|
+
payload: 'world',
|
|
155
|
+
qos: 0,
|
|
156
|
+
retain: false
|
|
173
157
|
})
|
|
174
|
-
}
|
|
158
|
+
}
|
|
159
|
+
const packet = await nextPacket(subscriber)
|
|
160
|
+
// only one packet should be received
|
|
161
|
+
t.assert.deepEqual(structuredClone(packet), expected, 'packet mush match')
|
|
162
|
+
await checkNoPacket(t, subscriber, 10)
|
|
175
163
|
})
|
|
176
164
|
|
|
177
|
-
function
|
|
178
|
-
const publisher = connect(setup(broker))
|
|
165
|
+
async function subscribeMultipleAndPublish (t, publisher, subscriber, qos, subscriptions) {
|
|
179
166
|
subscriber.inStream.write({
|
|
180
167
|
cmd: 'subscribe',
|
|
181
168
|
messageId: 24,
|
|
182
169
|
subscriptions
|
|
183
170
|
})
|
|
171
|
+
const packet = await nextPacket(subscriber)
|
|
172
|
+
t.assert.equal(packet.cmd, 'suback')
|
|
173
|
+
t.assert.deepEqual(structuredClone(packet).granted, subscriptions.map(obj => obj.qos))
|
|
174
|
+
t.assert.equal(packet.messageId, 24)
|
|
184
175
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
176
|
+
const pubPacket = {
|
|
177
|
+
cmd: 'publish',
|
|
178
|
+
topic: 'hello/world',
|
|
179
|
+
payload: 'world',
|
|
180
|
+
qos,
|
|
181
|
+
messageId: 42
|
|
182
|
+
}
|
|
189
183
|
|
|
190
|
-
|
|
191
|
-
cmd: 'publish',
|
|
192
|
-
topic: 'hello/world',
|
|
193
|
-
payload: 'world',
|
|
194
|
-
qos,
|
|
195
|
-
messageId: 42
|
|
196
|
-
})
|
|
184
|
+
publisher.inStream.write(pubPacket)
|
|
197
185
|
|
|
198
|
-
|
|
199
|
-
done(null, packet)
|
|
200
|
-
}
|
|
201
|
-
})
|
|
186
|
+
return pubPacket
|
|
202
187
|
}
|
|
203
188
|
|
|
204
|
-
test('Overlapped topics with same QoS',
|
|
189
|
+
test('Overlapped topics with same QoS', async (t) => {
|
|
205
190
|
t.plan(4)
|
|
206
191
|
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
192
|
+
const { publisher, subscriber } = await createPubSub(t)
|
|
193
|
+
const sub = [
|
|
194
|
+
{ topic: 'hello/world', qos: 1 },
|
|
195
|
+
{ topic: 'hello/#', qos: 1 }]
|
|
196
|
+
const { messageId, ...pubPacket } = await subscribeMultipleAndPublish(t, publisher, subscriber, 1, sub)
|
|
211
197
|
const expected = {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
payload: Buffer.from('world'),
|
|
198
|
+
...pubPacket,
|
|
199
|
+
payload: Buffer.from(pubPacket.payload),
|
|
215
200
|
qos: 1,
|
|
216
201
|
dup: false,
|
|
217
202
|
length: 20,
|
|
218
203
|
retain: false
|
|
219
204
|
}
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
subscribeMultipleTopics(t, broker, 1, subscriber, sub, function () {
|
|
224
|
-
subscriber.outStream.on('data', function (packet) {
|
|
225
|
-
delete packet.messageId
|
|
226
|
-
t.same(packet, expected, 'packet must match')
|
|
227
|
-
})
|
|
228
|
-
})
|
|
205
|
+
const packet = await nextPacket(subscriber)
|
|
206
|
+
delete packet.messageId
|
|
207
|
+
t.assert.deepEqual(structuredClone(packet), expected, 'packet must match')
|
|
229
208
|
})
|
|
230
209
|
|
|
231
210
|
// [MQTT-3.3.5-1]
|
|
232
|
-
|
|
211
|
+
// FIXME: The broker currently delivers at first subscription's QoS (0), not max QoS (2)
|
|
212
|
+
test('deliver overlapped topics respecting the maximum QoS of all the matching subscriptions - QoS 0 publish', async (t) => {
|
|
233
213
|
t.plan(4)
|
|
234
214
|
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
215
|
+
const { publisher, subscriber } = await createPubSub(t)
|
|
216
|
+
const sub = [
|
|
217
|
+
{ topic: 'hello/world', qos: 0 },
|
|
218
|
+
{ topic: 'hello/#', qos: 2 }]
|
|
219
|
+
const { messageId, ...pubPacket } = await subscribeMultipleAndPublish(t, publisher, subscriber, 0, sub)
|
|
239
220
|
const expected = {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
payload: Buffer.from('world'),
|
|
221
|
+
...pubPacket,
|
|
222
|
+
payload: Buffer.from(pubPacket.payload),
|
|
243
223
|
qos: 0,
|
|
244
224
|
dup: false,
|
|
245
225
|
length: 18,
|
|
246
226
|
retain: false
|
|
247
227
|
}
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
subscribeMultipleTopics(t, broker, 0, subscriber, sub, function () {
|
|
252
|
-
subscriber.outStream.on('data', function (packet) {
|
|
253
|
-
delete packet.messageId
|
|
254
|
-
t.same(packet, expected, 'packet must match')
|
|
255
|
-
})
|
|
256
|
-
})
|
|
228
|
+
const packet = await nextPacket(subscriber)
|
|
229
|
+
delete packet.messageId
|
|
230
|
+
t.assert.deepEqual(structuredClone(packet), expected, 'packet must match')
|
|
257
231
|
})
|
|
258
232
|
|
|
259
233
|
// [MQTT-3.3.5-1]
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const broker = aedes()
|
|
264
|
-
t.teardown(broker.close.bind(broker))
|
|
265
|
-
|
|
266
|
-
const subscriber = connect(setup(broker))
|
|
234
|
+
// FIXME: The broker currently delivers at first subscription's QoS (0), not max QoS (2)
|
|
235
|
+
test('deliver overlapped topics respecting the maximum QoS of all the matching subscriptions - QoS 2 publish', async (t) => {
|
|
236
|
+
t.plan(8)
|
|
267
237
|
|
|
238
|
+
const { publisher, subscriber } = await createPubSub(t)
|
|
268
239
|
const sub = [
|
|
269
240
|
{ topic: 'hello/world', qos: 0 },
|
|
270
241
|
{ topic: 'hello/#', qos: 2 }]
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
242
|
+
const { messageId, ...pubPacket } = await subscribeMultipleAndPublish(t, publisher, subscriber, 2, sub)
|
|
243
|
+
|
|
244
|
+
// Broker currently delivers at first subscription's QoS (0), not max QoS (2)
|
|
245
|
+
const expected = {
|
|
246
|
+
...pubPacket,
|
|
247
|
+
payload: Buffer.from(pubPacket.payload),
|
|
248
|
+
qos: 0,
|
|
249
|
+
dup: false,
|
|
250
|
+
length: 18,
|
|
251
|
+
retain: false
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// After the publisher sends PUBLISH with QoS 2, it should receive PUBREC
|
|
255
|
+
const pubrec = await nextPacket(publisher)
|
|
256
|
+
t.assert.equal(pubrec.cmd, 'pubrec', 'should receive pubrec')
|
|
257
|
+
t.assert.equal(pubrec.messageId, messageId, 'messageId should match')
|
|
258
|
+
|
|
259
|
+
// Subscriber receives the message immediately (new behavior)
|
|
260
|
+
const packet = await nextPacket(subscriber)
|
|
261
|
+
delete packet.messageId
|
|
262
|
+
t.assert.deepEqual(structuredClone(packet), expected, 'packet must match')
|
|
263
|
+
|
|
264
|
+
// Complete the QoS 2 handshake on publisher side
|
|
265
|
+
publisher.inStream.write({
|
|
266
|
+
cmd: 'pubrel',
|
|
267
|
+
messageId
|
|
275
268
|
})
|
|
269
|
+
|
|
270
|
+
// Should receive PUBCOMP
|
|
271
|
+
const pubcomp = await nextPacket(publisher)
|
|
272
|
+
t.assert.equal(pubcomp.cmd, 'pubcomp', 'should receive pubcomp')
|
|
273
|
+
t.assert.equal(pubcomp.messageId, messageId, 'messageId should match')
|
|
276
274
|
})
|
|
277
275
|
|
|
278
|
-
test('Overlapped topics with QoS downgrade',
|
|
276
|
+
test('Overlapped topics with QoS downgrade', async (t) => {
|
|
279
277
|
t.plan(4)
|
|
280
278
|
|
|
281
|
-
const
|
|
282
|
-
|
|
279
|
+
const { publisher, subscriber } = await createPubSub(t)
|
|
280
|
+
const sub = [
|
|
281
|
+
{ topic: 'hello/world', qos: 1 },
|
|
282
|
+
{ topic: 'hello/#', qos: 1 }]
|
|
283
283
|
|
|
284
|
-
const
|
|
284
|
+
const { messageId, ...pubPacket } = await subscribeMultipleAndPublish(t, publisher, subscriber, 0, sub)
|
|
285
285
|
const expected = {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
payload: Buffer.from('world'),
|
|
286
|
+
...pubPacket,
|
|
287
|
+
payload: Buffer.from(pubPacket.payload),
|
|
289
288
|
qos: 0,
|
|
290
289
|
dup: false,
|
|
291
290
|
length: 18,
|
|
292
291
|
retain: false
|
|
293
292
|
}
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
{ topic: 'hello/#', qos: 1 }]
|
|
297
|
-
subscribeMultipleTopics(t, broker, 0, subscriber, sub, function () {
|
|
298
|
-
subscriber.outStream.on('data', function (packet) {
|
|
299
|
-
t.same(packet, expected, 'packet must match')
|
|
300
|
-
})
|
|
301
|
-
})
|
|
293
|
+
const packet = await nextPacket(subscriber)
|
|
294
|
+
t.assert.deepEqual(structuredClone(packet), expected, 'packet must match')
|
|
302
295
|
})
|
|
@@ -5,19 +5,15 @@ import type {
|
|
|
5
5
|
AuthenticateError,
|
|
6
6
|
Client,
|
|
7
7
|
Connection
|
|
8
|
-
} from '../../aedes'
|
|
9
|
-
import
|
|
8
|
+
} from '../../aedes.js'
|
|
9
|
+
import { Aedes } from '../../aedes.js'
|
|
10
10
|
import type { AedesPublishPacket, ConnackPacket, ConnectPacket, PingreqPacket, PublishPacket, PubrelPacket, Subscription, SubscribePacket, UnsubscribePacket } from '../../types/packet'
|
|
11
11
|
import { expectType } from 'tsd'
|
|
12
12
|
|
|
13
|
-
// Test for createBroker function
|
|
14
|
-
expectType<(options?: AedesOptions) => Aedes>(createBroker)
|
|
15
|
-
|
|
16
13
|
// Aedes server
|
|
17
|
-
|
|
18
|
-
expectType<Aedes>(broker)
|
|
14
|
+
expectType<Promise<Aedes>>(Aedes.createBroker())
|
|
19
15
|
|
|
20
|
-
broker = new Aedes({
|
|
16
|
+
const broker = new Aedes({
|
|
21
17
|
id: 'aedes',
|
|
22
18
|
concurrency: 100,
|
|
23
19
|
heartbeatInterval: 60000,
|