@@ -260,6 +260,79 @@ testParseGenerate('connect MQTT 5.0', {
260260 4 , 3 , 2 , 1 // Will payload
261261] ) )
262262
263+ testParseGenerate ( 'connect MQTT 5.0 with will properties but w/o will payload' , {
264+ cmd : 'connect' ,
265+ retain : false ,
266+ qos : 0 ,
267+ dup : false ,
268+ length : 121 ,
269+ protocolId : 'MQTT' ,
270+ protocolVersion : 5 ,
271+ will : {
272+ retain : true ,
273+ qos : 2 ,
274+ properties : {
275+ willDelayInterval : 1234 ,
276+ payloadFormatIndicator : false ,
277+ messageExpiryInterval : 4321 ,
278+ contentType : 'test' ,
279+ responseTopic : 'topic' ,
280+ correlationData : Buffer . from ( [ 1 , 2 , 3 , 4 ] ) ,
281+ userProperties : {
282+ 'test' : 'test'
283+ }
284+ } ,
285+ topic : 'topic' ,
286+ payload : Buffer . from ( [ ] )
287+ } ,
288+ clean : true ,
289+ keepalive : 30 ,
290+ properties : {
291+ sessionExpiryInterval : 1234 ,
292+ receiveMaximum : 432 ,
293+ maximumPacketSize : 100 ,
294+ topicAliasMaximum : 456 ,
295+ requestResponseInformation : true ,
296+ requestProblemInformation : true ,
297+ userProperties : {
298+ 'test' : 'test'
299+ } ,
300+ authenticationMethod : 'test' ,
301+ authenticationData : Buffer . from ( [ 1 , 2 , 3 , 4 ] )
302+ } ,
303+ clientId : 'test'
304+ } , Buffer . from ( [
305+ 16 , 121 , // Header
306+ 0 , 4 , // Protocol ID length
307+ 77 , 81 , 84 , 84 , // Protocol ID
308+ 5 , // Protocol version
309+ 54 , // Connect flags
310+ 0 , 30 , // Keepalive
311+ 47 , // properties length
312+ 17 , 0 , 0 , 4 , 210 , // sessionExpiryInterval
313+ 33 , 1 , 176 , // receiveMaximum
314+ 39 , 0 , 0 , 0 , 100 , // maximumPacketSize
315+ 34 , 1 , 200 , // topicAliasMaximum
316+ 25 , 1 , // requestResponseInformation
317+ 23 , 1 , // requestProblemInformation,
318+ 38 , 0 , 4 , 116 , 101 , 115 , 116 , 0 , 4 , 116 , 101 , 115 , 116 , // userProperties,
319+ 21 , 0 , 4 , 116 , 101 , 115 , 116 , // authenticationMethod
320+ 22 , 0 , 4 , 1 , 2 , 3 , 4 , // authenticationData
321+ 0 , 4 , // Client ID length
322+ 116 , 101 , 115 , 116 , // Client ID
323+ 47 , // will properties
324+ 24 , 0 , 0 , 4 , 210 , // will delay interval
325+ 1 , 0 , // payload format indicator
326+ 2 , 0 , 0 , 16 , 225 , // message expiry interval
327+ 3 , 0 , 4 , 116 , 101 , 115 , 116 , // content type
328+ 8 , 0 , 5 , 116 , 111 , 112 , 105 , 99 , // response topic
329+ 9 , 0 , 4 , 1 , 2 , 3 , 4 , // corelation data
330+ 38 , 0 , 4 , 116 , 101 , 115 , 116 , 0 , 4 , 116 , 101 , 115 , 116 , // user properties
331+ 0 , 5 , // Will topic length
332+ 116 , 111 , 112 , 105 , 99 , // Will topic
333+ 0 , 0 // Will payload length
334+ ] ) )
335+
263336testParseGenerate ( 'connect MQTT 5.0 w/o will properties' , {
264337 cmd : 'connect' ,
265338 retain : false ,
0 commit comments