Skip to content

Commit

Permalink
More reliable test in 'subscribe and publish QoS 1 in parallel'
Browse files Browse the repository at this point in the history
  • Loading branch information
gnought committed Jul 13, 2019
1 parent 10c3eb6 commit 1d3bc57
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions test/qos1.js
Original file line number Diff line number Diff line change
Expand Up @@ -686,18 +686,18 @@ test('subscribe and publish QoS 1 in parallel', function (t) {
s.outStream.once('data', function (packet) {
t.equal(packet.cmd, 'puback')
t.equal(packet.messageId, 42, 'messageId must match')
s.outStream.once('data', function (packet) {
s.inStream.write({
cmd: 'puback',
messageId: packet.messageId
})
t.deepEqual(packet, expected, 'packet must match')
s.outStream.once('data', function (packet) {
t.equal(packet.cmd, 'suback')
s.outStream.on('data', function (packet) {
if (packet.cmd === 'suback') {
t.deepEqual(packet.granted, [1])
t.equal(packet.messageId, 24)
t.end()
})
}
if (packet.cmd === 'publish') {
s.inStream.write({
cmd: 'puback',
messageId: packet.messageId
})
t.deepEqual(packet, expected, 'packet must match')
}
})
})

Expand All @@ -717,4 +717,8 @@ test('subscribe and publish QoS 1 in parallel', function (t) {
qos: 1,
messageId: 42
})

setTimeout(function () {
t.end()
}, 50)
})

0 comments on commit 1d3bc57

Please sign in to comment.