Skip to content

Commit 962fb9e

Browse files
committed
Replace await, now a keyword, with wait
1 parent 7acbfd7 commit 962fb9e

File tree

3 files changed

+110
-110
lines changed

3 files changed

+110
-110
lines changed

test/channel.js

Lines changed: 61 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ function baseChannelTest(client, server) {
3030
});
3131

3232
pair.server.read(8); // discard the protocol header
33-
var s = util.runServer(pair.server, function(send, await) {
34-
conn_handshake(send, await)
33+
var s = util.runServer(pair.server, function(send, wait) {
34+
conn_handshake(send, wait)
3535
.then(function() {
36-
server(send, await, bothDone);
36+
server(send, wait, bothDone);
3737
}, fail(bothDone));
3838
});
3939
};
@@ -46,18 +46,18 @@ function channelTest(client, server) {
4646
if (LOG_ERRORS) ch.on('error', console.warn);
4747
client(ch, done, conn);
4848
},
49-
function(send, await, done) {
50-
channel_handshake(send, await)
49+
function(send, wait, done) {
50+
channel_handshake(send, wait)
5151
.then(function(ch) {
52-
return server(send, await, done, ch);
52+
return server(send, wait, done, ch);
5353
}).then(null, fail(done)); // so you can return a promise to let
5454
// errors bubble out
5555
}
5656
);
5757
};
5858

59-
function channel_handshake(send, await) {
60-
return await(defs.ChannelOpen)()
59+
function channel_handshake(send, wait) {
60+
return wait(defs.ChannelOpen)()
6161
.then(function(open) {
6262
assert.notEqual(0, open.channel);
6363
send(defs.ChannelOpenOk, {channelId: Buffer.from('')}, open.channel);
@@ -91,7 +91,7 @@ test("open", channelTest(
9191
function(ch, done) {
9292
open(ch).then(succeed(done), fail(done));
9393
},
94-
function(send, await, done) {
94+
function(send, wait, done) {
9595
done();
9696
}));
9797

@@ -100,8 +100,8 @@ test("bad server", baseChannelTest(
100100
var ch = new Channel(c);
101101
open(ch).then(fail(done), succeed(done));
102102
},
103-
function(send, await, done) {
104-
return await(defs.ChannelOpen)()
103+
function(send, wait, done) {
104+
return wait(defs.ChannelOpen)()
105105
.then(function(open) {
106106
send(defs.ChannelCloseOk, {}, open.channel);
107107
}).then(succeed(done), fail(done));
@@ -117,8 +117,8 @@ test("open, close", channelTest(
117117
})
118118
.then(succeed(done), fail(done));
119119
},
120-
function(send, await, done, ch) {
121-
return await(defs.ChannelClose)()
120+
function(send, wait, done, ch) {
121+
return wait(defs.ChannelClose)()
122122
.then(function(close) {
123123
send(defs.ChannelCloseOk, {}, ch);
124124
}).then(succeed(done), fail(done));
@@ -132,13 +132,13 @@ test("server close", channelTest(
132132
});
133133
open(ch);
134134
},
135-
function(send, await, done, ch) {
135+
function(send, wait, done, ch) {
136136
send(defs.ChannelClose, {
137137
replyText: 'Forced close',
138138
replyCode: defs.constants.CHANNEL_ERROR,
139139
classId: 0, methodId: 0
140140
}, ch);
141-
await(defs.ChannelCloseOk)()
141+
wait(defs.ChannelCloseOk)()
142142
.then(succeed(done), fail(done));
143143
}));
144144

@@ -151,16 +151,16 @@ test("overlapping channel/server close", channelTest(
151151
ch.closeBecause("Bye", defs.constants.REPLY_SUCCESS);
152152
}, fail(both));
153153
},
154-
function(send, await, done, ch) {
155-
await(defs.ChannelClose)()
154+
function(send, wait, done, ch) {
155+
wait(defs.ChannelClose)()
156156
.then(function() {
157157
send(defs.ConnectionClose, {
158158
replyText: 'Got there first',
159159
replyCode: defs.constants.INTERNAL_ERROR,
160160
classId: 0, methodId: 0
161161
}, 0);
162162
})
163-
.then(await(defs.ConnectionCloseOk))
163+
.then(wait(defs.ConnectionCloseOk))
164164
.then(succeed(done), fail(done));
165165
}));
166166

@@ -174,8 +174,8 @@ test("double close", channelTest(
174174
});
175175
}).then(succeed(done), fail(done));
176176
},
177-
function(send, await, done, ch) {
178-
await(defs.ChannelClose)()
177+
function(send, wait, done, ch) {
178+
wait(defs.ChannelClose)()
179179
.then(function() {
180180
send(defs.ChannelCloseOk, {
181181
}, ch);
@@ -208,16 +208,16 @@ test("RPC", channelTest(
208208
ch._rpc(defs.BasicQos, fields, defs.BasicQosOk, wheeboom);
209209
}).then(null, fail(rpcLatch));
210210
},
211-
function(send, await, done, ch) {
211+
function(send, wait, done, ch) {
212212
function sendOk(f) {
213213
send(defs.BasicQosOk, {}, ch);
214214
}
215215

216-
return await(defs.BasicQos)()
216+
return wait(defs.BasicQos)()
217217
.then(sendOk)
218-
.then(await(defs.BasicQos))
218+
.then(wait(defs.BasicQos))
219219
.then(sendOk)
220-
.then(await(defs.BasicQos))
220+
.then(wait(defs.BasicQos))
221221
.then(sendOk)
222222
.then(succeed(done), fail(done));
223223
}));
@@ -241,12 +241,12 @@ test("Bad RPC", channelTest(
241241
});
242242
}, fail(errLatch));
243243
},
244-
function(send, await, done, ch) {
245-
return await()()
244+
function(send, wait, done, ch) {
245+
return wait()()
246246
.then(function() {
247247
send(defs.BasicGetEmpty, {clusterId: ''}, ch);
248248
}) // oh wait! that was wrong! expect a channel close
249-
.then(await(defs.ChannelClose))
249+
.then(wait(defs.ChannelClose))
250250
.then(function() {
251251
send(defs.ChannelCloseOk, {}, ch);
252252
}).then(succeed(done), fail(done));
@@ -284,15 +284,15 @@ test("RPC on closed channel", channelTest(
284284
.then(succeed(done))
285285
.catch(fail(done));
286286
},
287-
function(send, await, done, ch) {
288-
await(defs.BasicRecover)()
287+
function(send, wait, done, ch) {
288+
wait(defs.BasicRecover)()
289289
.then(function() {
290290
send(defs.ChannelClose, {
291291
replyText: 'Nuh-uh!',
292292
replyCode: defs.constants.CHANNEL_ERROR,
293293
methodId: 0, classId: 0
294294
}, ch);
295-
return await(defs.ChannelCloseOk);
295+
return wait(defs.ChannelCloseOk);
296296
})
297297
.then(succeed(done))
298298
.catch(fail(done));
@@ -309,10 +309,10 @@ test("publish all < single chunk threshold", channelTest(
309309
})
310310
.then(succeed(done), fail(done));
311311
},
312-
function(send, await, done, ch) {
313-
await(defs.BasicPublish)()
314-
.then(await(defs.BasicProperties))
315-
.then(await(undefined)) // content frame
312+
function(send, wait, done, ch) {
313+
wait(defs.BasicPublish)()
314+
.then(wait(defs.BasicProperties))
315+
.then(wait(undefined)) // content frame
316316
.then(function(f) {
317317
assert.equal('foobar', f.content.toString());
318318
}).then(succeed(done), fail(done));
@@ -328,10 +328,10 @@ test("publish content > single chunk threshold", channelTest(
328328
}, {}, Buffer.alloc(3000));
329329
}, done);
330330
},
331-
function(send, await, done, ch) {
332-
await(defs.BasicPublish)()
333-
.then(await(defs.BasicProperties))
334-
.then(await(undefined)) // content frame
331+
function(send, wait, done, ch) {
332+
wait(defs.BasicPublish)()
333+
.then(wait(defs.BasicProperties))
334+
.then(wait(undefined)) // content frame
335335
.then(function(f) {
336336
assert.equal(3000, f.content.length);
337337
}).then(succeed(done), fail(done));
@@ -349,10 +349,10 @@ test("publish method & headers > threshold", channelTest(
349349
}, Buffer.from('foobar'));
350350
}, done);
351351
},
352-
function(send, await, done, ch) {
353-
await(defs.BasicPublish)()
354-
.then(await(defs.BasicProperties))
355-
.then(await(undefined)) // content frame
352+
function(send, wait, done, ch) {
353+
wait(defs.BasicPublish)()
354+
.then(wait(defs.BasicProperties))
355+
.then(wait(undefined)) // content frame
356356
.then(function(f) {
357357
assert.equal('foobar', f.content.toString());
358358
}).then(succeed(done), fail(done));
@@ -372,11 +372,11 @@ test("publish zero-length message", channelTest(
372372
}, {}, Buffer.alloc(0));
373373
}, done);
374374
},
375-
function(send, await, done, ch) {
376-
await(defs.BasicPublish)()
377-
.then(await(defs.BasicProperties))
375+
function(send, wait, done, ch) {
376+
wait(defs.BasicPublish)()
377+
.then(wait(defs.BasicProperties))
378378
// no content frame for a zero-length message
379-
.then(await(defs.BasicPublish))
379+
.then(wait(defs.BasicPublish))
380380
.then(succeed(done), fail(done));
381381
}));
382382

@@ -389,7 +389,7 @@ test("delivery", channelTest(
389389
}, done);
390390
});
391391
},
392-
function(send, await, done, ch) {
392+
function(send, wait, done, ch) {
393393
completes(function() {
394394
send(defs.BasicDeliver, DELIVER_FIELDS, ch, Buffer.from('barfoo'));
395395
}, done);
@@ -404,7 +404,7 @@ test("zero byte msg", channelTest(
404404
}, done);
405405
});
406406
},
407-
function(send, await, done, ch) {
407+
function(send, wait, done, ch) {
408408
completes(function() {
409409
send(defs.BasicDeliver, DELIVER_FIELDS, ch, Buffer.from(''));
410410
}, done);
@@ -420,11 +420,11 @@ test("bad delivery", channelTest(
420420
ch.on('close', succeed(errorAndClose));
421421
open(ch);
422422
},
423-
function(send, await, done, ch) {
423+
function(send, wait, done, ch) {
424424
send(defs.BasicDeliver, DELIVER_FIELDS, ch);
425425
// now send another deliver without having sent the content
426426
send(defs.BasicDeliver, DELIVER_FIELDS, ch);
427-
return await(defs.ChannelClose)()
427+
return wait(defs.ChannelClose)()
428428
.then(function() {
429429
send(defs.ChannelCloseOk, {}, ch);
430430
}).then(succeed(done), fail(done));
@@ -441,7 +441,7 @@ test("bad content send", channelTest(
441441
});
442442
}, done);
443443
},
444-
function(send, await, done, ch) {
444+
function(send, wait, done, ch) {
445445
done();
446446
}));
447447

@@ -457,7 +457,7 @@ test("bad properties send", channelTest(
457457
});
458458
}, done);
459459
},
460-
function(send, await, done, ch) {
460+
function(send, wait, done, ch) {
461461
done();
462462
}));
463463

@@ -474,9 +474,9 @@ test("bad consumer", channelTest(
474474
ch.on('close', succeed(errorAndClose));
475475
open(ch);
476476
},
477-
function(send, await, done, ch) {
477+
function(send, wait, done, ch) {
478478
send(defs.BasicDeliver, DELIVER_FIELDS, ch, Buffer.from('barfoo'));
479-
return await(defs.ChannelClose)()
479+
return wait(defs.ChannelClose)()
480480
.then(function() {
481481
send(defs.ChannelCloseOk, {}, ch);
482482
}).then(succeed(done), fail(done));
@@ -499,12 +499,12 @@ test("bad send in consumer", channelTest(
499499

500500
open(ch);
501501
},
502-
function(send, await, done, ch) {
502+
function(send, wait, done, ch) {
503503
completes(function() {
504504
send(defs.BasicDeliver, DELIVER_FIELDS, ch,
505505
Buffer.from('barfoo'));
506506
}, done);
507-
return await(defs.ChannelClose)()
507+
return wait(defs.ChannelClose)()
508508
.then(function() {
509509
send(defs.ChannelCloseOk, {}, ch);
510510
}).then(succeed(done), fail(done));
@@ -519,7 +519,7 @@ test("return", channelTest(
519519
});
520520
open(ch);
521521
},
522-
function(send, await, done, ch) {
522+
function(send, wait, done, ch) {
523523
completes(function() {
524524
send(defs.BasicReturn, DELIVER_FIELDS, ch, Buffer.from('barfoo'));
525525
}, done);
@@ -534,7 +534,7 @@ test("cancel", channelTest(
534534
});
535535
open(ch);
536536
},
537-
function(send, await, done, ch) {
537+
function(send, wait, done, ch) {
538538
completes(function() {
539539
send(defs.BasicCancel, {
540540
consumerTag: 'product of society',
@@ -553,7 +553,7 @@ function confirmTest(variety, Method) {
553553
});
554554
open(ch);
555555
},
556-
function(send, await, done, ch) {
556+
function(send, wait, done, ch) {
557557
completes(function() {
558558
send(Method, {
559559
deliveryTag: 1,
@@ -579,7 +579,7 @@ test("out-of-order acks", channelTest(
579579
ch.pushConfirmCallback(allConfirms);
580580
open(ch);
581581
},
582-
function(send, await, done, ch) {
582+
function(send, wait, done, ch) {
583583
completes(function() {
584584
send(defs.BasicAck, {deliveryTag: 2, multiple: false}, ch);
585585
send(defs.BasicAck, {deliveryTag: 3, multiple: false}, ch);
@@ -602,7 +602,7 @@ test("not all out-of-order acks", channelTest(
602602
});
603603
open(ch);
604604
},
605-
function(send, await, done, ch) {
605+
function(send, wait, done, ch) {
606606
completes(function() {
607607
send(defs.BasicAck, {deliveryTag: 2, multiple: false}, ch);
608608
send(defs.BasicAck, {deliveryTag: 1, multiple: false}, ch);

0 commit comments

Comments
 (0)