Skip to content

Commit

Permalink
Add a qos 2 test, 'multiple publish and store one'
Browse files Browse the repository at this point in the history
  • Loading branch information
gnought committed Aug 11, 2019
1 parent 49f0825 commit 5d35282
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/qos2.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,35 @@ test('publish after disconnection', function (t) {
})
})
})

test('multiple publish and store one', function (t) {
t.plan(2)

var broker = aedes()
var sid = {
id: 'abcde'
}
var s = connect(setup(broker), { clientId: sid.id })
var toPublish = {
cmd: 'publish',
topic: 'hello',
payload: Buffer.from('world'),
qos: 2,
retain: false,
messageId: 42
}

var count = 5
while (--count) {
s.inStream.write(toPublish)
}
broker.on('closed', function () {
broker.persistence.incomingGetPacket(sid, toPublish, function (err, origPacket) {
delete origPacket.brokerId
delete origPacket.brokerCounter
t.deepEqual(origPacket, toPublish, 'packet must match')
t.error(err)
t.end()
})
})
})

0 comments on commit 5d35282

Please sign in to comment.