From d57b772725b9286f888c12c483afd987d40440df Mon Sep 17 00:00:00 2001 From: Gnought <1684105+gnought@users.noreply.github.com> Date: Mon, 15 Jul 2019 01:59:50 +0800 Subject: [PATCH 1/7] Added a missing dup field --- packet.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packet.js b/packet.js index d084269..a8de370 100644 --- a/packet.js +++ b/packet.js @@ -8,6 +8,7 @@ function Packet (original, broker) { this.payload = original.payload || Buffer.alloc(0) this.qos = original.qos || 0 this.retain = original.retain || false + this.dup = original.dup || false // [MQTT-2.3.1-5] if (this.qos > 0 || this.cmd !== 'publish') { // [MQTT-2.3.1-1] From 7286489092771baab338a243674b68b9a1f98a9a Mon Sep 17 00:00:00 2001 From: Gnought <1684105+gnought@users.noreply.github.com> Date: Mon, 15 Jul 2019 13:18:22 +0800 Subject: [PATCH 2/7] Fixed typo --- packet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packet.js b/packet.js index a8de370..cf3c29b 100644 --- a/packet.js +++ b/packet.js @@ -8,7 +8,7 @@ function Packet (original, broker) { this.payload = original.payload || Buffer.alloc(0) this.qos = original.qos || 0 this.retain = original.retain || false - this.dup = original.dup || false + this.dup = origianl.dup || false // [MQTT-2.3.1-5] if (this.qos > 0 || this.cmd !== 'publish') { // [MQTT-2.3.1-1] From acba414836b8430d299c0c7345abb331c5f7666b Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Tue, 28 Jan 2020 14:15:08 +0100 Subject: [PATCH 3/7] Fixed typo --- packet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packet.js b/packet.js index cf3c29b..a8de370 100644 --- a/packet.js +++ b/packet.js @@ -8,7 +8,7 @@ function Packet (original, broker) { this.payload = original.payload || Buffer.alloc(0) this.qos = original.qos || 0 this.retain = original.retain || false - this.dup = origianl.dup || false + this.dup = original.dup || false // [MQTT-2.3.1-5] if (this.qos > 0 || this.cmd !== 'publish') { // [MQTT-2.3.1-1] From c6a782983d43ad6e15102cf79c3cdfcde6c4835c Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Tue, 11 Feb 2020 09:22:20 +0100 Subject: [PATCH 4/7] Added dup test --- test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test.js b/test.js index ad3301c..b860456 100644 --- a/test.js +++ b/test.js @@ -42,6 +42,19 @@ test('Packet defaults - PUBLISH, QoS 1', function (t) { t.end() }) +test('Packet defaults - PUBLISH, dup=true', function (t) { + var instance = new Packet({ dup: true }) + t.equal(instance.cmd, 'publish') + t.equal(instance.brokerId, undefined) + t.equal(instance.brokerCounter, 0) + t.equal(instance.topic, undefined) + t.deepEqual(instance.payload, Buffer.alloc(0)) + t.equal(instance.qos, 0) + t.equal(instance.retain, false) + t.equal(instance.messageId, undefined) + t.end() +}) + test('Packet copies over most data', function (t) { var original = { cmd: 'pubrel', From 918d5efd36005ca28adc4e72461fc66adb6b054a Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Tue, 11 Feb 2020 09:24:20 +0100 Subject: [PATCH 5/7] Added dup tests to defaults --- test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test.js b/test.js index b860456..67efe9b 100644 --- a/test.js +++ b/test.js @@ -11,6 +11,7 @@ test('Packet defaults - PUBLISH, QoS 0', function (t) { t.equal(instance.topic, undefined) t.deepEqual(instance.payload, Buffer.alloc(0)) t.equal(instance.qos, 0) + t.equal(instance.dup, false) t.equal(instance.retain, false) t.equal(instance.messageId, undefined) t.end() @@ -24,6 +25,7 @@ test('Packet defaults - PUBREL, QoS 0', function (t) { t.equal(instance.topic, undefined) t.deepEqual(instance.payload, Buffer.alloc(0)) t.equal(instance.qos, 0) + t.equal(instance.dup, false) t.equal(instance.retain, false) t.equal(instance.messageId, 1) t.end() @@ -37,6 +39,7 @@ test('Packet defaults - PUBLISH, QoS 1', function (t) { t.equal(instance.topic, undefined) t.deepEqual(instance.payload, Buffer.alloc(0)) t.equal(instance.qos, 1) + t.equal(instance.dup, false) t.equal(instance.retain, false) t.equal(instance.messageId, 1) t.end() @@ -50,6 +53,7 @@ test('Packet defaults - PUBLISH, dup=true', function (t) { t.equal(instance.topic, undefined) t.deepEqual(instance.payload, Buffer.alloc(0)) t.equal(instance.qos, 0) + t.equal(instance.dup, true) t.equal(instance.retain, false) t.equal(instance.messageId, undefined) t.end() From 111dfe6dccd61f5f9980a4a8b539d988f8f8a7c0 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Tue, 11 Feb 2020 09:29:43 +0100 Subject: [PATCH 6/7] Fixed tests --- test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test.js b/test.js index 67efe9b..4d9e120 100644 --- a/test.js +++ b/test.js @@ -67,6 +67,7 @@ test('Packet copies over most data', function (t) { topic: 'hello', payload: 'world', qos: 2, + dup: true, retain: true, messageId: 24 } @@ -78,6 +79,7 @@ test('Packet copies over most data', function (t) { topic: 'hello', payload: 'world', qos: 2, + dup: true, retain: true, messageId: 1 // this is different } @@ -107,6 +109,7 @@ test('Packet fills in broker data', function (t) { topic: 'hello', payload: 'world', qos: 2, + dup: false, retain: true, messageId: 1 // this is different } From cf8c1ba469c78cd703610b38abf9a5e02b3ea9a5 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Tue, 11 Feb 2020 09:38:35 +0100 Subject: [PATCH 7/7] removed messageid from expected --- test.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test.js b/test.js index 80f71a9..a15c63b 100644 --- a/test.js +++ b/test.js @@ -82,8 +82,7 @@ test('Packet copies over most data', function (t) { payload: 'world', qos: 2, dup: true, - retain: true, - messageId: 1 // this is different + retain: true } t.ok(Object.prototype.hasOwnProperty.call(instance, 'messageId')) @@ -115,8 +114,7 @@ test('Packet fills in broker data', function (t) { payload: 'world', qos: 2, dup: false, - retain: true, - messageId: 1 // this is different + retain: true } t.ok(Object.prototype.hasOwnProperty.call(instance, 'messageId'))