amqplib 0.5.2 → 0.5.3

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.
@@ -19,12 +19,12 @@ var OPEN_OPTS = {
19
19
  'mechanism': 'PLAIN',
20
20
  'response': Buffer.from(['', 'guest', 'guest'].join(String.fromCharCode(0))),
21
21
  'locale': 'en_US',
22
-
22
+
23
23
  // tune-ok
24
24
  'channelMax': 0,
25
25
  'frameMax': 0,
26
26
  'heartbeat': 0,
27
-
27
+
28
28
  // open
29
29
  'virtualHost': '/',
30
30
  'capabilities': '',
@@ -32,7 +32,7 @@ var OPEN_OPTS = {
32
32
  };
33
33
  module.exports.OPEN_OPTS = OPEN_OPTS;
34
34
 
35
- function happy_open(send, await) {
35
+ function happy_open(send, wait) {
36
36
  // kick it off
37
37
  send(defs.ConnectionStart,
38
38
  {versionMajor: 0,
@@ -40,15 +40,15 @@ function happy_open(send, await) {
40
40
  serverProperties: {},
41
41
  mechanisms: Buffer.from('PLAIN'),
42
42
  locales: Buffer.from('en_US')});
43
- return await(defs.ConnectionStartOk)()
43
+ return wait(defs.ConnectionStartOk)()
44
44
  .then(function(f) {
45
45
  send(defs.ConnectionTune,
46
46
  {channelMax: 0,
47
47
  heartbeat: 0,
48
48
  frameMax: 0});
49
49
  })
50
- .then(await(defs.ConnectionTuneOk))
51
- .then(await(defs.ConnectionOpen))
50
+ .then(wait(defs.ConnectionTuneOk))
51
+ .then(wait(defs.ConnectionOpen))
52
52
  .then(function(f) {
53
53
  send(defs.ConnectionOpenOk,
54
54
  {knownHosts: ''});
@@ -69,8 +69,8 @@ function connectionTest(client, server) {
69
69
  assert.deepEqual(Buffer.from("AMQP" + String.fromCharCode(0,0,9,1)),
70
70
  protocolHeader);
71
71
 
72
- var s = util.runServer(pair.server, function(send, await) {
73
- server(send, await, bothDone, pair.server);
72
+ var s = util.runServer(pair.server, function(send, wait) {
73
+ server(send, wait, bothDone, pair.server);
74
74
  });
75
75
  };
76
76
  }
@@ -106,15 +106,15 @@ test("happy", connectionTest(
106
106
  function(c, done) {
107
107
  c.open(OPEN_OPTS, kCallback(succeed(done), fail(done)));
108
108
  },
109
- function(send, await, done) {
110
- happy_open(send, await).then(succeed(done), fail(done));
109
+ function(send, wait, done) {
110
+ happy_open(send, wait).then(succeed(done), fail(done));
111
111
  }));
112
112
 
113
113
  test("wrong first frame", connectionTest(
114
114
  function(c, done) {
115
115
  c.open(OPEN_OPTS, kCallback(fail(done), succeed(done)));
116
116
  },
117
- function(send, await, done) {
117
+ function(send, wait, done) {
118
118
  // bad server! bad! whatever were you thinking?
119
119
  completes(function() {
120
120
  send(defs.ConnectionTune,
@@ -128,14 +128,14 @@ test("unexpected socket close", connectionTest(
128
128
  function(c, done) {
129
129
  c.open(OPEN_OPTS, kCallback(fail(done), succeed(done)));
130
130
  },
131
- function(send, await, done, socket) {
131
+ function(send, wait, done, socket) {
132
132
  send(defs.ConnectionStart,
133
133
  {versionMajor: 0,
134
134
  versionMinor: 9,
135
135
  serverProperties: {},
136
136
  mechanisms: Buffer.from('PLAIN'),
137
137
  locales: Buffer.from('en_US')});
138
- return await(defs.ConnectionStartOk)()
138
+ return wait(defs.ConnectionStartOk)()
139
139
  .then(function() {
140
140
  socket.end();
141
141
  })
@@ -151,15 +151,15 @@ test("wrong frame on channel 0", connectionTest(
151
151
  c.on('error', succeed(done));
152
152
  c.open(OPEN_OPTS);
153
153
  },
154
- function(send, await, done) {
155
- happy_open(send, await)
154
+ function(send, wait, done) {
155
+ happy_open(send, wait)
156
156
  .then(function() {
157
157
  // there's actually nothing that would plausibly be sent to a
158
158
  // just opened connection, so this is violating more than one
159
159
  // rule. Nonetheless.
160
160
  send(defs.ChannelOpenOk, {channelId: Buffer.from('')}, 0);
161
161
  })
162
- .then(await(defs.ConnectionClose))
162
+ .then(wait(defs.ConnectionClose))
163
163
  .then(function(close) {
164
164
  send(defs.ConnectionCloseOk, {}, 0);
165
165
  }).then(succeed(done), fail(done));
@@ -170,15 +170,15 @@ test("unopened channel", connectionTest(
170
170
  c.on('error', succeed(done));
171
171
  c.open(OPEN_OPTS);
172
172
  },
173
- function(send, await, done) {
174
- happy_open(send, await)
173
+ function(send, wait, done) {
174
+ happy_open(send, wait)
175
175
  .then(function() {
176
176
  // there's actually nothing that would plausibly be sent to a
177
177
  // just opened connection, so this is violating more than one
178
178
  // rule. Nonetheless.
179
179
  send(defs.ChannelOpenOk, {channelId: Buffer.from('')}, 3);
180
180
  })
181
- .then(await(defs.ConnectionClose))
181
+ .then(wait(defs.ConnectionClose))
182
182
  .then(function(close) {
183
183
  send(defs.ConnectionCloseOk, {}, 0);
184
184
  }).then(succeed(done), fail(done));
@@ -193,9 +193,9 @@ test("unexpected socket close", connectionTest(
193
193
  c.sendHeartbeat();
194
194
  }, fail(errorAndClosed)));
195
195
  },
196
- function(send, await, done, socket) {
197
- happy_open(send, await)
198
- .then(await())
196
+ function(send, wait, done, socket) {
197
+ happy_open(send, wait)
198
+ .then(wait())
199
199
  .then(function() {
200
200
  socket.end();
201
201
  }).then(succeed(done));
@@ -206,8 +206,8 @@ test("connection.blocked", connectionTest(
206
206
  c.on('blocked', succeed(done));
207
207
  c.open(OPEN_OPTS);
208
208
  },
209
- function(send, await, done, socket) {
210
- happy_open(send, await)
209
+ function(send, wait, done, socket) {
210
+ happy_open(send, wait)
211
211
  .then(function() {
212
212
  send(defs.ConnectionBlocked, {reason: 'felt like it'}, 0);
213
213
  })
@@ -219,8 +219,8 @@ test("connection.unblocked", connectionTest(
219
219
  c.on('unblocked', succeed(done));
220
220
  c.open(OPEN_OPTS);
221
221
  },
222
- function(send, await, done, socket) {
223
- happy_open(send, await)
222
+ function(send, wait, done, socket) {
223
+ happy_open(send, wait)
224
224
  .then(function() {
225
225
  send(defs.ConnectionUnblocked, {}, 0);
226
226
  })
@@ -240,9 +240,9 @@ test("happy", connectionTest(
240
240
  c.close(kCallback(succeed(done), fail(done)));
241
241
  }, function() {}));
242
242
  },
243
- function(send, await, done) {
244
- happy_open(send, await)
245
- .then(await(defs.ConnectionClose))
243
+ function(send, wait, done) {
244
+ happy_open(send, wait)
245
+ .then(wait(defs.ConnectionClose))
246
246
  .then(function(close) {
247
247
  send(defs.ConnectionCloseOk, {});
248
248
  })
@@ -257,9 +257,9 @@ test("interleaved close frames", connectionTest(
257
257
  c.close(kCallback(succeed(done), fail(done)));
258
258
  }, done));
259
259
  },
260
- function(send, await, done) {
261
- happy_open(send, await)
262
- .then(await(defs.ConnectionClose))
260
+ function(send, wait, done) {
261
+ happy_open(send, wait)
262
+ .then(wait(defs.ConnectionClose))
263
263
  .then(function(f) {
264
264
  send(defs.ConnectionClose, {
265
265
  replyText: "Ha!",
@@ -267,7 +267,7 @@ test("interleaved close frames", connectionTest(
267
267
  methodId: 0, classId: 0
268
268
  });
269
269
  })
270
- .then(await(defs.ConnectionCloseOk))
270
+ .then(wait(defs.ConnectionCloseOk))
271
271
  .then(function(f) {
272
272
  send(defs.ConnectionCloseOk, {});
273
273
  })
@@ -281,8 +281,8 @@ test("server error close", connectionTest(
281
281
  c.on('error', succeed(done));
282
282
  c.open(OPEN_OPTS);
283
283
  },
284
- function(send, await, done) {
285
- happy_open(send, await)
284
+ function(send, wait, done) {
285
+ happy_open(send, wait)
286
286
  .then(function(f) {
287
287
  send(defs.ConnectionClose, {
288
288
  replyText: "Begone",
@@ -290,7 +290,7 @@ test("server error close", connectionTest(
290
290
  methodId: 0, classId: 0
291
291
  });
292
292
  })
293
- .then(await(defs.ConnectionCloseOk))
293
+ .then(wait(defs.ConnectionCloseOk))
294
294
  .then(succeed(done), fail(done));
295
295
  }));
296
296
 
@@ -300,8 +300,8 @@ test("operator-intiated close", connectionTest(
300
300
  c.on('error', fail(done));
301
301
  c.open(OPEN_OPTS);
302
302
  },
303
- function(send, await, done) {
304
- happy_open(send, await)
303
+ function(send, wait, done) {
304
+ happy_open(send, wait)
305
305
  .then(function(f) {
306
306
  send(defs.ConnectionClose, {
307
307
  replyText: "Begone",
@@ -309,7 +309,7 @@ test("operator-intiated close", connectionTest(
309
309
  methodId: 0, classId: 0
310
310
  });
311
311
  })
312
- .then(await(defs.ConnectionCloseOk))
312
+ .then(wait(defs.ConnectionCloseOk))
313
313
  .then(succeed(done), fail(done));
314
314
  }));
315
315
 
@@ -325,9 +325,9 @@ test("double close", connectionTest(
325
325
  done();
326
326
  }, done));
327
327
  },
328
- function(send, await, done) {
329
- happy_open(send, await)
330
- .then(await(defs.ConnectionClose))
328
+ function(send, wait, done) {
329
+ happy_open(send, wait)
330
+ .then(wait(defs.ConnectionClose))
331
331
  .then(function() {
332
332
  send(defs.ConnectionCloseOk, {});
333
333
  })
@@ -359,15 +359,15 @@ test("send heartbeat after open", connectionTest(
359
359
  c.open(opts);
360
360
  }, done);
361
361
  },
362
- function(send, await, done, socket) {
362
+ function(send, wait, done, socket) {
363
363
  var timer;
364
- happy_open(send, await)
364
+ happy_open(send, wait)
365
365
  .then(function() {
366
366
  timer = setInterval(function() {
367
367
  socket.write(HB_BUF);
368
368
  }, heartbeat.UNITS_TO_MS);
369
369
  })
370
- .then(await())
370
+ .then(wait())
371
371
  .then(function(hb) {
372
372
  if (hb === HEARTBEAT) done();
373
373
  else done("Next frame after silence not a heartbeat");
@@ -382,8 +382,8 @@ test("detect lack of heartbeats", connectionTest(
382
382
  c.on('error', succeed(done));
383
383
  c.open(opts);
384
384
  },
385
- function(send, await, done, socket) {
386
- happy_open(send, await)
385
+ function(send, wait, done, socket) {
386
+ happy_open(send, wait)
387
387
  .then(succeed(done), fail(done));
388
388
  // conspicuously not sending anything ...
389
389
  }));
package/test/mux.js CHANGED
@@ -37,7 +37,7 @@ test("single input", function(done) {
37
37
  var mux = new Mux(output);
38
38
  mux.pipeFrom(input);
39
39
 
40
- var data = [1,2,3,4,5,6,7,8,9];
40
+ var data = [1,2,3,4,5,6,7,8,9];
41
41
  // not 0, it's treated specially by PassThrough for some reason. By
42
42
  // 'specially' I mean it breaks the stream. See e.g.,
43
43
  // https://github.com/isaacs/readable-stream/pull/55
@@ -112,16 +112,20 @@ test("unpipe", function(done) {
112
112
 
113
113
  schedule(function() {
114
114
  pipedData.forEach(input.write.bind(input));
115
- mux.unpipeFrom(input);
116
115
 
117
116
  schedule(function() {
118
- unpipedData.forEach(input.write.bind(input));
119
- input.end();
117
+ mux.unpipeFrom(input);
118
+
120
119
  schedule(function() {
121
- // exhaust so that 'end' fires
122
- var v; while (v = input.read());
120
+ unpipedData.forEach(input.write.bind(input));
121
+ input.end();
122
+ schedule(function() {
123
+ // exhaust so that 'end' fires
124
+ var v; while (v = input.read());
125
+ });
123
126
  });
124
127
  });
128
+
125
129
  });
126
130
 
127
131
  input.on('end', function() {
package/test/util.js CHANGED
@@ -76,7 +76,7 @@ function runServer(socket, run) {
76
76
  }
77
77
  }
78
78
 
79
- function await(method) {
79
+ function wait(method) {
80
80
  return function() {
81
81
  return new Promise(function(resolve, reject) {
82
82
  if (method) {
@@ -98,7 +98,7 @@ function runServer(socket, run) {
98
98
  });
99
99
  };
100
100
  }
101
- run(send, await);
101
+ run(send, wait);
102
102
  return frames;
103
103
  }
104
104