amqplib 0.10.8 → 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.
Files changed (85) hide show
  1. package/.claude/commands/lint-disable.md +9 -0
  2. package/.claude/commands/lint-enable.md +12 -0
  3. package/.claude/settings.local.json +16 -0
  4. package/.github/workflows/publish.yml +1 -1
  5. package/.github/workflows/test.yml +1 -1
  6. package/CHANGELOG.md +34 -0
  7. package/CLAUDE.md +12 -0
  8. package/Makefile +5 -12
  9. package/bin/generate-defs.js +382 -369
  10. package/biome.json +51 -0
  11. package/callback_api.js +12 -8
  12. package/channel_api.js +5 -10
  13. package/examples/direct_reply_to_client.js +9 -5
  14. package/examples/direct_reply_to_server.js +8 -6
  15. package/examples/headers.js +13 -10
  16. package/examples/receive_generator.js +13 -20
  17. package/examples/send_generators.js +2 -9
  18. package/examples/ssl.js +2 -3
  19. package/examples/stream_queues/receive_stream.js +39 -36
  20. package/examples/stream_queues/send_stream.js +26 -29
  21. package/examples/tutorials/callback_api/emit_log.js +4 -3
  22. package/examples/tutorials/callback_api/emit_log_direct.js +5 -4
  23. package/examples/tutorials/callback_api/emit_log_topic.js +5 -4
  24. package/examples/tutorials/callback_api/new_task.js +5 -4
  25. package/examples/tutorials/callback_api/receive.js +16 -10
  26. package/examples/tutorials/callback_api/receive_logs.js +17 -11
  27. package/examples/tutorials/callback_api/receive_logs_direct.js +19 -13
  28. package/examples/tutorials/callback_api/receive_logs_topic.js +19 -14
  29. package/examples/tutorials/callback_api/rpc_client.js +20 -16
  30. package/examples/tutorials/callback_api/rpc_server.js +27 -21
  31. package/examples/tutorials/callback_api/send.js +4 -3
  32. package/examples/tutorials/callback_api/worker.js +18 -13
  33. package/examples/tutorials/emit_log.js +4 -6
  34. package/examples/tutorials/emit_log_direct.js +5 -7
  35. package/examples/tutorials/emit_log_topic.js +5 -7
  36. package/examples/tutorials/new_task.js +4 -6
  37. package/examples/tutorials/receive.js +8 -4
  38. package/examples/tutorials/receive_logs.js +10 -6
  39. package/examples/tutorials/receive_logs_direct.js +16 -10
  40. package/examples/tutorials/receive_logs_topic.js +16 -11
  41. package/examples/tutorials/rpc_client.js +17 -15
  42. package/examples/tutorials/rpc_server.js +9 -8
  43. package/examples/tutorials/send.js +4 -6
  44. package/examples/tutorials/worker.js +17 -14
  45. package/examples/waitForConfirms.js +2 -2
  46. package/lefthook.yml +14 -0
  47. package/lib/api_args.js +124 -149
  48. package/lib/bitset.js +28 -18
  49. package/lib/callback_model.js +134 -190
  50. package/lib/channel.js +175 -213
  51. package/lib/channel_model.js +41 -85
  52. package/lib/codec.js +257 -228
  53. package/lib/connect.js +74 -82
  54. package/lib/connection.js +204 -240
  55. package/lib/credentials.js +21 -29
  56. package/lib/defs.js +2559 -1927
  57. package/lib/error.js +5 -6
  58. package/lib/format.js +15 -33
  59. package/lib/frame.js +66 -66
  60. package/lib/heartbeat.js +17 -24
  61. package/lib/mux.js +32 -41
  62. package/package.json +8 -5
  63. package/test/bitset.test.js +65 -0
  64. package/test/callback_api.test.js +438 -0
  65. package/test/channel.test.js +592 -0
  66. package/test/channel_api.test.js +537 -0
  67. package/test/codec.test.js +172 -0
  68. package/test/connect.test.js +196 -0
  69. package/test/connection.test.js +330 -0
  70. package/test/data.test.js +33 -0
  71. package/test/frame.test.js +180 -0
  72. package/test/lib/data.js +249 -0
  73. package/test/lib/util.js +223 -0
  74. package/test/mux.test.js +215 -0
  75. package/test/bitset.js +0 -69
  76. package/test/callback_api.js +0 -379
  77. package/test/channel.js +0 -621
  78. package/test/channel_api.js +0 -606
  79. package/test/codec.js +0 -237
  80. package/test/connect.js +0 -197
  81. package/test/connection.js +0 -390
  82. package/test/data.js +0 -269
  83. package/test/frame.js +0 -191
  84. package/test/mux.js +0 -203
  85. package/test/util.js +0 -217
package/test/channel.js DELETED
@@ -1,621 +0,0 @@
1
- // Test the channel machinery
2
-
3
- 'use strict';
4
-
5
- var assert = require('assert');
6
- var promisify = require('util').promisify;
7
- var Channel = require('../lib/channel').Channel;
8
- var Connection = require('../lib/connection').Connection;
9
- var util = require('./util');
10
- var succeed = util.succeed, fail = util.fail, latch = util.latch;
11
- var completes = util.completes;
12
- var defs = require('../lib/defs');
13
- var conn_handshake = require('./connection').connection_handshake;
14
- var OPEN_OPTS = require('./connection').OPEN_OPTS;
15
-
16
- var LOG_ERRORS = process.env.LOG_ERRORS;
17
-
18
- function baseChannelTest(client, server) {
19
- return function(done) {
20
- var bothDone = latch(2, done);
21
- var pair = util.socketPair();
22
- var c = new Connection(pair.client);
23
-
24
- if (LOG_ERRORS) c.on('error', console.warn);
25
-
26
- c.open(OPEN_OPTS, function(err, ok) {
27
- if (err === null) client(c, bothDone);
28
- else fail(bothDone);
29
- });
30
-
31
- pair.server.read(8); // discard the protocol header
32
- var s = util.runServer(pair.server, function(send, wait) {
33
- conn_handshake(send, wait)
34
- .then(function() {
35
- server(send, wait, bothDone);
36
- }, fail(bothDone));
37
- });
38
- };
39
- }
40
-
41
- function channelTest(client, server) {
42
- return baseChannelTest(
43
- function(conn, done) {
44
- var ch = new Channel(conn);
45
- if (LOG_ERRORS) ch.on('error', console.warn);
46
- client(ch, done, conn);
47
- },
48
- function(send, wait, done) {
49
- channel_handshake(send, wait)
50
- .then(function(ch) {
51
- return server(send, wait, done, ch);
52
- }).then(null, fail(done)); // so you can return a promise to let
53
- // errors bubble out
54
- }
55
- );
56
- };
57
-
58
- function channel_handshake(send, wait) {
59
- return wait(defs.ChannelOpen)()
60
- .then(function(open) {
61
- assert.notEqual(0, open.channel);
62
- send(defs.ChannelOpenOk, {channelId: Buffer.from('')}, open.channel);
63
- return open.channel;
64
- });
65
- }
66
-
67
- // fields for deliver and publish and get-ok
68
- var DELIVER_FIELDS = {
69
- consumerTag: 'fake',
70
- deliveryTag: 1,
71
- redelivered: false,
72
- exchange: 'foo',
73
- routingKey: 'bar',
74
- replyCode: defs.constants.NO_ROUTE,
75
- replyText: 'derp',
76
- };
77
-
78
- function open(ch) {
79
- ch.allocate();
80
- return promisify(function(cb) {
81
- ch._rpc(defs.ChannelOpen, {outOfBand: ''}, defs.ChannelOpenOk, cb);
82
- })();
83
- }
84
-
85
- suite("channel open and close", function() {
86
-
87
- test("open", channelTest(
88
- function(ch, done) {
89
- open(ch).then(succeed(done), fail(done));
90
- },
91
- function(send, wait, done) {
92
- done();
93
- }));
94
-
95
- test("bad server", baseChannelTest(
96
- function(c, done) {
97
- var ch = new Channel(c);
98
- open(ch).then(fail(done), succeed(done));
99
- },
100
- function(send, wait, done) {
101
- return wait(defs.ChannelOpen)()
102
- .then(function(open) {
103
- send(defs.ChannelCloseOk, {}, open.channel);
104
- }).then(succeed(done), fail(done));
105
- }));
106
-
107
- test("open, close", channelTest(
108
- function(ch, done) {
109
- open(ch)
110
- .then(function() {
111
- return new Promise(function(resolve) {
112
- ch.closeBecause("Bye", defs.constants.REPLY_SUCCESS, resolve);
113
- });
114
- })
115
- .then(succeed(done), fail(done));
116
- },
117
- function(send, wait, done, ch) {
118
- return wait(defs.ChannelClose)()
119
- .then(function(close) {
120
- send(defs.ChannelCloseOk, {}, ch);
121
- }).then(succeed(done), fail(done));
122
- }));
123
-
124
- test("server close", channelTest(
125
- function(ch, done) {
126
- ch.on('error', function(error) {
127
- assert.strictEqual(504, error.code);
128
- assert.strictEqual(0, error.classId);
129
- assert.strictEqual(0, error.methodId);
130
- succeed(done)();
131
- });
132
- open(ch);
133
- },
134
- function(send, wait, done, ch) {
135
- send(defs.ChannelClose, {
136
- replyText: 'Forced close',
137
- replyCode: defs.constants.CHANNEL_ERROR,
138
- classId: 0, methodId: 0
139
- }, ch);
140
- wait(defs.ChannelCloseOk)()
141
- .then(succeed(done), fail(done));
142
- }));
143
-
144
- test("overlapping channel/server close", channelTest(
145
- function(ch, done, conn) {
146
- var both = latch(2, done);
147
- conn.on('error', succeed(both));
148
- ch.on('close', succeed(both));
149
- open(ch).then(function() {
150
- ch.closeBecause("Bye", defs.constants.REPLY_SUCCESS);
151
- }, fail(both));
152
- },
153
- function(send, wait, done, ch) {
154
- wait(defs.ChannelClose)()
155
- .then(function() {
156
- send(defs.ConnectionClose, {
157
- replyText: 'Got there first',
158
- replyCode: defs.constants.INTERNAL_ERROR,
159
- classId: 0, methodId: 0
160
- }, 0);
161
- })
162
- .then(wait(defs.ConnectionCloseOk))
163
- .then(succeed(done), fail(done));
164
- }));
165
-
166
- test("double close", channelTest(
167
- function(ch, done) {
168
- open(ch).then(function() {
169
- ch.closeBecause("First close", defs.constants.REPLY_SUCCESS);
170
- // NB no synchronisation, we do this straight away
171
- assert.throws(function() {
172
- ch.closeBecause("Second close", defs.constants.REPLY_SUCCESS);
173
- });
174
- }).then(succeed(done), fail(done));
175
- },
176
- function(send, wait, done, ch) {
177
- wait(defs.ChannelClose)()
178
- .then(function() {
179
- send(defs.ChannelCloseOk, {
180
- }, ch);
181
- })
182
- .then(succeed(done), fail(done));
183
- }));
184
-
185
- }); //suite
186
-
187
- suite("channel machinery", function() {
188
-
189
- test("RPC", channelTest(
190
- function(ch, done) {
191
- var rpcLatch = latch(3, done);
192
- open(ch).then(function() {
193
-
194
- function wheeboom(err, f) {
195
- if (err !== null) rpcLatch(err);
196
- else rpcLatch();
197
- }
198
-
199
- var fields = {
200
- prefetchCount: 10,
201
- prefetchSize: 0,
202
- global: false
203
- };
204
-
205
- ch._rpc(defs.BasicQos, fields, defs.BasicQosOk, wheeboom);
206
- ch._rpc(defs.BasicQos, fields, defs.BasicQosOk, wheeboom);
207
- ch._rpc(defs.BasicQos, fields, defs.BasicQosOk, wheeboom);
208
- }).then(null, fail(rpcLatch));
209
- },
210
- function(send, wait, done, ch) {
211
- function sendOk(f) {
212
- send(defs.BasicQosOk, {}, ch);
213
- }
214
-
215
- return wait(defs.BasicQos)()
216
- .then(sendOk)
217
- .then(wait(defs.BasicQos))
218
- .then(sendOk)
219
- .then(wait(defs.BasicQos))
220
- .then(sendOk)
221
- .then(succeed(done), fail(done));
222
- }));
223
-
224
- test("Bad RPC", channelTest(
225
- function(ch, done) {
226
- // We want to see the RPC rejected and the channel closed (with an
227
- // error)
228
- var errLatch = latch(2, done);
229
- ch.on('error', function(error) {
230
- assert.strictEqual(505, error.code);
231
- assert.strictEqual(60, error.classId);
232
- assert.strictEqual(72, error.methodId);
233
- succeed(errLatch)();
234
- });
235
-
236
- open(ch)
237
- .then(function() {
238
- ch._rpc(defs.BasicRecover, {requeue: true}, defs.BasicRecoverOk,
239
- function(err) {
240
- if (err !== null) errLatch();
241
- else errLatch(new Error('Expected RPC failure'));
242
- });
243
- }, fail(errLatch));
244
- },
245
- function(send, wait, done, ch) {
246
- return wait()()
247
- .then(function() {
248
- send(defs.BasicGetEmpty, {clusterId: ''}, ch);
249
- }) // oh wait! that was wrong! expect a channel close
250
- .then(wait(defs.ChannelClose))
251
- .then(function() {
252
- send(defs.ChannelCloseOk, {}, ch);
253
- }).then(succeed(done), fail(done));
254
- }));
255
-
256
- test("RPC on closed channel", channelTest(
257
- function(ch, done) {
258
- open(ch);
259
-
260
- var close = new Promise(function(resolve) {
261
- ch.on('error', function(error) {
262
- assert.strictEqual(504, error.code);
263
- assert.strictEqual(0, error.classId);
264
- assert.strictEqual(0, error.methodId);
265
- resolve();
266
- });
267
- });
268
-
269
- function failureCb(resolve, reject) {
270
- return function(err) {
271
- if (err !== null) resolve();
272
- else reject();
273
- }
274
- }
275
-
276
- var fail1 = new Promise(function(resolve, reject) {
277
- return ch._rpc(defs.BasicRecover, {requeue:true}, defs.BasicRecoverOk,
278
- failureCb(resolve, reject));
279
- });
280
-
281
- var fail2 = new Promise(function(resolve, reject) {
282
- return ch._rpc(defs.BasicRecover, {requeue:true}, defs.BasicRecoverOk,
283
- failureCb(resolve, reject));
284
- });
285
-
286
- Promise.all([close, fail1, fail2])
287
- .then(succeed(done))
288
- .catch(fail(done));
289
- },
290
- function(send, wait, done, ch) {
291
- wait(defs.BasicRecover)()
292
- .then(function() {
293
- send(defs.ChannelClose, {
294
- replyText: 'Nuh-uh!',
295
- replyCode: defs.constants.CHANNEL_ERROR,
296
- methodId: 0, classId: 0
297
- }, ch);
298
- return wait(defs.ChannelCloseOk);
299
- })
300
- .then(succeed(done))
301
- .catch(fail(done));
302
- }));
303
-
304
- test("publish all < single chunk threshold", channelTest(
305
- function(ch, done) {
306
- open(ch)
307
- .then(function() {
308
- ch.sendMessage({
309
- exchange: 'foo', routingKey: 'bar',
310
- mandatory: false, immediate: false, ticket: 0
311
- }, {}, Buffer.from('foobar'));
312
- })
313
- .then(succeed(done), fail(done));
314
- },
315
- function(send, wait, done, ch) {
316
- wait(defs.BasicPublish)()
317
- .then(wait(defs.BasicProperties))
318
- .then(wait(undefined)) // content frame
319
- .then(function(f) {
320
- assert.equal('foobar', f.content.toString());
321
- }).then(succeed(done), fail(done));
322
- }));
323
-
324
- test("publish content > single chunk threshold", channelTest(
325
- function(ch, done) {
326
- open(ch);
327
- completes(function() {
328
- ch.sendMessage({
329
- exchange: 'foo', routingKey: 'bar',
330
- mandatory: false, immediate: false, ticket: 0
331
- }, {}, Buffer.alloc(3000));
332
- }, done);
333
- },
334
- function(send, wait, done, ch) {
335
- wait(defs.BasicPublish)()
336
- .then(wait(defs.BasicProperties))
337
- .then(wait(undefined)) // content frame
338
- .then(function(f) {
339
- assert.equal(3000, f.content.length);
340
- }).then(succeed(done), fail(done));
341
- }));
342
-
343
- test("publish method & headers > threshold", channelTest(
344
- function(ch, done) {
345
- open(ch);
346
- completes(function() {
347
- ch.sendMessage({
348
- exchange: 'foo', routingKey: 'bar',
349
- mandatory: false, immediate: false, ticket: 0
350
- }, {
351
- headers: {foo: Buffer.alloc(3000)}
352
- }, Buffer.from('foobar'));
353
- }, done);
354
- },
355
- function(send, wait, done, ch) {
356
- wait(defs.BasicPublish)()
357
- .then(wait(defs.BasicProperties))
358
- .then(wait(undefined)) // content frame
359
- .then(function(f) {
360
- assert.equal('foobar', f.content.toString());
361
- }).then(succeed(done), fail(done));
362
- }));
363
-
364
- test("publish zero-length message", channelTest(
365
- function(ch, done) {
366
- open(ch);
367
- completes(function() {
368
- ch.sendMessage({
369
- exchange: 'foo', routingKey: 'bar',
370
- mandatory: false, immediate: false, ticket: 0
371
- }, {}, Buffer.alloc(0));
372
- ch.sendMessage({
373
- exchange: 'foo', routingKey: 'bar',
374
- mandatory: false, immediate: false, ticket: 0
375
- }, {}, Buffer.alloc(0));
376
- }, done);
377
- },
378
- function(send, wait, done, ch) {
379
- wait(defs.BasicPublish)()
380
- .then(wait(defs.BasicProperties))
381
- // no content frame for a zero-length message
382
- .then(wait(defs.BasicPublish))
383
- .then(succeed(done), fail(done));
384
- }));
385
-
386
- test("delivery", channelTest(
387
- function(ch, done) {
388
- open(ch);
389
- ch.on('delivery', function(m) {
390
- completes(function() {
391
- assert.equal('barfoo', m.content.toString());
392
- }, done);
393
- });
394
- },
395
- function(send, wait, done, ch) {
396
- completes(function() {
397
- send(defs.BasicDeliver, DELIVER_FIELDS, ch, Buffer.from('barfoo'));
398
- }, done);
399
- }));
400
-
401
- test("zero byte msg", channelTest(
402
- function(ch, done) {
403
- open(ch);
404
- ch.on('delivery', function(m) {
405
- completes(function() {
406
- assert.deepEqual(Buffer.alloc(0), m.content);
407
- }, done);
408
- });
409
- },
410
- function(send, wait, done, ch) {
411
- completes(function() {
412
- send(defs.BasicDeliver, DELIVER_FIELDS, ch, Buffer.from(''));
413
- }, done);
414
- }));
415
-
416
- test("bad delivery", channelTest(
417
- function(ch, done) {
418
- var errorAndClose = latch(2, done);
419
- ch.on('error', function(error) {
420
- assert.strictEqual(505, error.code);
421
- assert.strictEqual(60, error.classId);
422
- assert.strictEqual(60, error.methodId);
423
- succeed(errorAndClose)();
424
- });
425
- ch.on('close', succeed(errorAndClose));
426
- open(ch);
427
- },
428
- function(send, wait, done, ch) {
429
- send(defs.BasicDeliver, DELIVER_FIELDS, ch);
430
- // now send another deliver without having sent the content
431
- send(defs.BasicDeliver, DELIVER_FIELDS, ch);
432
- return wait(defs.ChannelClose)()
433
- .then(function() {
434
- send(defs.ChannelCloseOk, {}, ch);
435
- }).then(succeed(done), fail(done));
436
- }));
437
-
438
- test("bad content send", channelTest(
439
- function(ch, done) {
440
- completes(function() {
441
- open(ch);
442
- assert.throws(function() {
443
- ch.sendMessage({routingKey: 'foo',
444
- exchange: 'amq.direct'},
445
- {}, null);
446
- });
447
- }, done);
448
- },
449
- function(send, wait, done, ch) {
450
- done();
451
- }));
452
-
453
- test("bad properties send", channelTest(
454
- function(ch, done) {
455
- completes(function() {
456
- open(ch);
457
- assert.throws(function() {
458
- ch.sendMessage({routingKey: 'foo',
459
- exchange: 'amq.direct'},
460
- {contentEncoding: 7},
461
- Buffer.from('foobar'));
462
- });
463
- }, done);
464
- },
465
- function(send, wait, done, ch) {
466
- done();
467
- }));
468
-
469
- test("bad consumer", channelTest(
470
- function(ch, done) {
471
- var errorAndClose = latch(2, done);
472
- ch.on('delivery', function() {
473
- throw new Error("I am a bad consumer");
474
- });
475
- ch.on('error', function(error) {
476
- assert.strictEqual(541, error.code);
477
- assert.strictEqual(undefined, error.classId);
478
- assert.strictEqual(undefined, error.methodId);
479
- succeed(errorAndClose)();
480
- });
481
- ch.on('close', succeed(errorAndClose));
482
- open(ch);
483
- },
484
- function(send, wait, done, ch) {
485
- send(defs.BasicDeliver, DELIVER_FIELDS, ch, Buffer.from('barfoo'));
486
- return wait(defs.ChannelClose)()
487
- .then(function() {
488
- send(defs.ChannelCloseOk, {}, ch);
489
- }).then(succeed(done), fail(done));
490
- }));
491
-
492
- test("bad send in consumer", channelTest(
493
- function(ch, done) {
494
- var errorAndClose = latch(2, done);
495
- ch.on('close', succeed(errorAndClose));
496
- ch.on('error', function(error) {
497
- assert.strictEqual(541, error.code);
498
- assert.strictEqual(undefined, error.classId);
499
- assert.strictEqual(undefined, error.methodId);
500
- succeed(errorAndClose)();
501
- });
502
-
503
- ch.on('delivery', function() {
504
- ch.sendMessage({routingKey: 'foo',
505
- exchange: 'amq.direct'},
506
- {}, null); // can't send null
507
- });
508
-
509
- open(ch);
510
- },
511
- function(send, wait, done, ch) {
512
- completes(function() {
513
- send(defs.BasicDeliver, DELIVER_FIELDS, ch,
514
- Buffer.from('barfoo'));
515
- }, done);
516
- return wait(defs.ChannelClose)()
517
- .then(function() {
518
- send(defs.ChannelCloseOk, {}, ch);
519
- }).then(succeed(done), fail(done));
520
- }));
521
-
522
- test("return", channelTest(
523
- function(ch, done) {
524
- ch.on('return', function(m) {
525
- completes(function() {
526
- assert.equal('barfoo', m.content.toString());
527
- }, done);
528
- });
529
- open(ch);
530
- },
531
- function(send, wait, done, ch) {
532
- completes(function() {
533
- send(defs.BasicReturn, DELIVER_FIELDS, ch, Buffer.from('barfoo'));
534
- }, done);
535
- }));
536
-
537
- test("cancel", channelTest(
538
- function(ch, done) {
539
- ch.on('cancel', function(f) {
540
- completes(function() {
541
- assert.equal('product of society', f.consumerTag);
542
- }, done);
543
- });
544
- open(ch);
545
- },
546
- function(send, wait, done, ch) {
547
- completes(function() {
548
- send(defs.BasicCancel, {
549
- consumerTag: 'product of society',
550
- nowait: false
551
- }, ch);
552
- }, done);
553
- }));
554
-
555
- function confirmTest(variety, Method) {
556
- return test('confirm ' + variety, channelTest(
557
- function(ch, done) {
558
- ch.on(variety, function(f) {
559
- completes(function() {
560
- assert.equal(1, f.deliveryTag);
561
- }, done);
562
- });
563
- open(ch);
564
- },
565
- function(send, wait, done, ch) {
566
- completes(function() {
567
- send(Method, {
568
- deliveryTag: 1,
569
- multiple: false
570
- }, ch);
571
- }, done);
572
- }));
573
- }
574
-
575
- confirmTest("ack", defs.BasicAck);
576
- confirmTest("nack", defs.BasicNack);
577
-
578
- test("out-of-order acks", channelTest(
579
- function(ch, done) {
580
- var allConfirms = latch(3, function() {
581
- completes(function() {
582
- assert.equal(0, ch.unconfirmed.length);
583
- assert.equal(4, ch.lwm);
584
- }, done);
585
- });
586
- ch.pushConfirmCallback(allConfirms);
587
- ch.pushConfirmCallback(allConfirms);
588
- ch.pushConfirmCallback(allConfirms);
589
- open(ch);
590
- },
591
- function(send, wait, done, ch) {
592
- completes(function() {
593
- send(defs.BasicAck, {deliveryTag: 2, multiple: false}, ch);
594
- send(defs.BasicAck, {deliveryTag: 3, multiple: false}, ch);
595
- send(defs.BasicAck, {deliveryTag: 1, multiple: false}, ch);
596
- }, done);
597
- }));
598
-
599
- test("not all out-of-order acks", channelTest(
600
- function(ch, done) {
601
- var allConfirms = latch(2, function() {
602
- completes(function() {
603
- assert.equal(1, ch.unconfirmed.length);
604
- assert.equal(3, ch.lwm);
605
- }, done);
606
- });
607
- ch.pushConfirmCallback(allConfirms); // tag = 1
608
- ch.pushConfirmCallback(allConfirms); // tag = 2
609
- ch.pushConfirmCallback(function() {
610
- done(new Error('Confirm callback should not be called'));
611
- });
612
- open(ch);
613
- },
614
- function(send, wait, done, ch) {
615
- completes(function() {
616
- send(defs.BasicAck, {deliveryTag: 2, multiple: false}, ch);
617
- send(defs.BasicAck, {deliveryTag: 1, multiple: false}, ch);
618
- }, done);
619
- }));
620
-
621
- });