amqplib 0.5.1 → 0.5.2
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/CHANGELOG.md +21 -0
- package/Makefile +1 -1
- package/README.md +2 -2
- package/callback_api.js +1 -0
- package/channel_api.js +1 -0
- package/examples/headers.js +2 -2
- package/examples/receive_generator.js +39 -0
- package/examples/send_generators.js +1 -1
- package/examples/ssl.js +1 -1
- package/examples/tutorials/callback_api/emit_log.js +1 -1
- package/examples/tutorials/callback_api/emit_log_direct.js +1 -1
- package/examples/tutorials/callback_api/emit_log_topic.js +1 -1
- package/examples/tutorials/callback_api/new_task.js +1 -1
- package/examples/tutorials/callback_api/rpc_client.js +1 -1
- package/examples/tutorials/callback_api/rpc_server.js +1 -1
- package/examples/tutorials/callback_api/send.js +1 -1
- package/examples/tutorials/emit_log.js +1 -1
- package/examples/tutorials/emit_log_direct.js +1 -1
- package/examples/tutorials/emit_log_topic.js +1 -1
- package/examples/tutorials/new_task.js +1 -1
- package/examples/tutorials/rpc_client.js +1 -1
- package/examples/tutorials/rpc_server.js +1 -1
- package/examples/tutorials/send.js +1 -1
- package/examples/waitForConfirms.js +1 -1
- package/lib/channel.js +2 -2
- package/lib/codec.js +64 -38
- package/lib/connect.js +33 -12
- package/lib/connection.js +4 -3
- package/lib/credentials.js +6 -3
- package/lib/defs.js +75 -75
- package/lib/frame.js +2 -1
- package/package.json +4 -3
- package/test/callback_api.js +6 -5
- package/test/channel.js +15 -14
- package/test/channel_api.js +25 -24
- package/test/codec.js +48 -9
- package/test/connect.js +63 -3
- package/test/connection.js +10 -9
- package/test/data.js +32 -9
- package/test/frame.js +4 -4
- package/test/util.js +14 -0
- package/.npmignore +0 -9
package/test/data.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
5
|
var C = require('claire');
|
|
6
|
-
|
|
6
|
+
var Buffer = require('safe-buffer').Buffer;
|
|
7
7
|
var forAll = C.forAll;
|
|
8
8
|
var arb = C.data;
|
|
9
9
|
var transform = C.transform;
|
|
@@ -18,7 +18,7 @@ var Undefined = C.Undefined;
|
|
|
18
18
|
|
|
19
19
|
// Stub these out so we can use outside tests
|
|
20
20
|
// if (!suite) var suite = function() {}
|
|
21
|
-
// if (!test) var test = function() {}
|
|
21
|
+
// if (!test) var test = function() {}
|
|
22
22
|
|
|
23
23
|
// These aren't exported in claire/index. so I could have to reproduce
|
|
24
24
|
// them I guess.
|
|
@@ -36,7 +36,7 @@ function rangeInt(name, a, b) {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
function toFloat32(i) {
|
|
39
|
-
var b =
|
|
39
|
+
var b = Buffer.alloc(4);
|
|
40
40
|
b.writeFloatBE(i, 0);
|
|
41
41
|
return b.readFloatBE(0);
|
|
42
42
|
}
|
|
@@ -53,6 +53,12 @@ function floatChooser(maxExp) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
function explicitType(t, underlying) {
|
|
57
|
+
return label(t, transform(function(n) {
|
|
58
|
+
return {'!': t, value: n};
|
|
59
|
+
}, underlying));
|
|
60
|
+
}
|
|
61
|
+
|
|
56
62
|
// FIXME null, byte array, others?
|
|
57
63
|
|
|
58
64
|
var Octet = rangeInt('octet', 0, 255);
|
|
@@ -63,7 +69,7 @@ var ShortStr = label('shortstr',
|
|
|
63
69
|
|
|
64
70
|
var LongStr = label('longstr',
|
|
65
71
|
transform(
|
|
66
|
-
function(bytes) { return
|
|
72
|
+
function(bytes) { return Buffer.from(bytes); },
|
|
67
73
|
repeat(Octet)));
|
|
68
74
|
|
|
69
75
|
var UShort = rangeInt('short-uint', 0, 0xffff);
|
|
@@ -85,12 +91,27 @@ var Decimal = label('decimal', transform(
|
|
|
85
91
|
return {'!': 'decimal', value: {places: args[1], digits: args[0]}};
|
|
86
92
|
}, sequence(arb.UInt, Octet)));
|
|
87
93
|
|
|
94
|
+
// Signed 8 bit int
|
|
95
|
+
var Byte = rangeInt('byte', -128, 127);
|
|
96
|
+
|
|
97
|
+
// Explicitly typed values
|
|
98
|
+
var ExByte = explicitType('byte', Byte);
|
|
99
|
+
var ExInt8 = explicitType('int8', Byte);
|
|
100
|
+
var ExShort = explicitType('short', Short);
|
|
101
|
+
var ExInt16 = explicitType('int16', Short);
|
|
102
|
+
var ExInt = explicitType('int', Long);
|
|
103
|
+
var ExInt32 = explicitType('int32', Long);
|
|
104
|
+
var ExLong = explicitType('long', LongLong);
|
|
105
|
+
var ExInt64 = explicitType('int64', LongLong);
|
|
106
|
+
|
|
88
107
|
var FieldArray = label('field-array', recursive(function() {
|
|
89
108
|
return arb.Array(
|
|
90
109
|
arb.Null,
|
|
91
|
-
LongStr, ShortStr,
|
|
92
|
-
UShort, ULong, ULongLong,
|
|
93
|
-
Short, Long, LongLong,
|
|
110
|
+
LongStr, ShortStr,
|
|
111
|
+
Octet, UShort, ULong, ULongLong,
|
|
112
|
+
Byte, Short, Long, LongLong,
|
|
113
|
+
ExByte, ExInt8, ExShort, ExInt16,
|
|
114
|
+
ExInt, ExInt32, ExLong, ExInt64,
|
|
94
115
|
Bit, Float, Double, FieldTable, FieldArray)
|
|
95
116
|
}));
|
|
96
117
|
|
|
@@ -100,7 +121,9 @@ var FieldTable = label('table', recursive(function() {
|
|
|
100
121
|
arb.Null,
|
|
101
122
|
LongStr, ShortStr, Octet,
|
|
102
123
|
UShort, ULong, ULongLong,
|
|
103
|
-
Short, Long, LongLong,
|
|
124
|
+
Byte, Short, Long, LongLong,
|
|
125
|
+
ExByte, ExInt8, ExShort, ExInt16,
|
|
126
|
+
ExInt, ExInt32, ExLong, ExInt64,
|
|
104
127
|
Bit, Float, Double, FieldArray, FieldTable))
|
|
105
128
|
}));
|
|
106
129
|
|
|
@@ -184,7 +207,7 @@ function method(info) {
|
|
|
184
207
|
function properties(info) {
|
|
185
208
|
var types = info.args.map(argtype);
|
|
186
209
|
types.unshift(ULongLong); // size
|
|
187
|
-
var domain = sequence.apply(null, types);
|
|
210
|
+
var domain = sequence.apply(null, types);
|
|
188
211
|
var names = info.args.map(name);
|
|
189
212
|
return label(info.name, transform(function(fieldVals) {
|
|
190
213
|
return {id: info.id,
|
package/test/frame.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var assert = require('assert');
|
|
4
4
|
var succeed = require('./util').succeed;
|
|
5
5
|
var fail = require('./util').fail;
|
|
6
|
-
|
|
6
|
+
var Buffer = require('safe-buffer').Buffer;
|
|
7
7
|
var connection = require('../lib/connection');
|
|
8
8
|
var Frames = connection.Connection;
|
|
9
9
|
var HEARTBEAT = require('../lib/frame').HEARTBEAT;
|
|
@@ -21,7 +21,7 @@ function inputs() {
|
|
|
21
21
|
return new PassThrough({objectMode: true});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
var HB =
|
|
24
|
+
var HB = Buffer.from([defs.constants.FRAME_HEARTBEAT,
|
|
25
25
|
0, 0, // channel 0
|
|
26
26
|
0, 0, 0, 0, // zero size
|
|
27
27
|
defs.constants.FRAME_END]);
|
|
@@ -51,7 +51,7 @@ suite("Explicit parsing", function() {
|
|
|
51
51
|
var input = inputs();
|
|
52
52
|
var frames = new Frames(input);
|
|
53
53
|
frames.frameMax = 5; //for the max frame test
|
|
54
|
-
input.write(
|
|
54
|
+
input.write(Buffer.from(bytes));
|
|
55
55
|
frames.step(function(err, frame) {
|
|
56
56
|
if (err != null) done();
|
|
57
57
|
else done(new Error('Was a bogus frame!'));
|
|
@@ -166,7 +166,7 @@ var Content = transform(function(args) {
|
|
|
166
166
|
return {
|
|
167
167
|
method: args[0].fields,
|
|
168
168
|
header: args[1].fields,
|
|
169
|
-
body:
|
|
169
|
+
body: Buffer.from(args[2])
|
|
170
170
|
}
|
|
171
171
|
}, sequence(amqp.methods['BasicDeliver'],
|
|
172
172
|
amqp.properties['BasicProperties'], Body));
|
package/test/util.js
CHANGED
|
@@ -107,6 +107,19 @@ function succeed(done) {
|
|
|
107
107
|
return function() { done(); }
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
// Produce a callback that will complete the test successfully
|
|
111
|
+
// only if the value is an object, it has the specified
|
|
112
|
+
// attribute, and its value is equals to the expected value
|
|
113
|
+
function succeedIfAttributeEquals(attribute, value, done) {
|
|
114
|
+
return function(object) {
|
|
115
|
+
if (object && !(object instanceof Error) && value === object[attribute]) {
|
|
116
|
+
return done();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
done(new Error(attribute + " is not equal to " + value));
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
110
123
|
// Produce a callback that will fail the test, given either an error
|
|
111
124
|
// (to be used as a failure continuation) or any other value (to be
|
|
112
125
|
// used as a success continuation when failure is expected)
|
|
@@ -196,6 +209,7 @@ module.exports = {
|
|
|
196
209
|
socketPair: socketPair,
|
|
197
210
|
runServer: runServer,
|
|
198
211
|
succeed: succeed,
|
|
212
|
+
succeedIfAttributeEquals: succeedIfAttributeEquals,
|
|
199
213
|
fail: fail,
|
|
200
214
|
latch: latch,
|
|
201
215
|
completes: completes,
|