@@ -3161,6 +3161,63 @@ test('stops parsing after first error', t => {
3161
3161
] ) )
3162
3162
} )
3163
3163
3164
+ test ( 'undefined properties' , t => {
3165
+ t . plan ( 2 )
3166
+
3167
+ const packet = mqtt . generate ( {
3168
+ cmd : 'connect' ,
3169
+ retain : false ,
3170
+ qos : 0 ,
3171
+ dup : false ,
3172
+ length : 125 ,
3173
+ protocolId : 'MQTT' ,
3174
+ protocolVersion : 5 ,
3175
+ will : {
3176
+ retain : true ,
3177
+ qos : 2 ,
3178
+ properties : {
3179
+ willDelayInterval : 1234 ,
3180
+ payloadFormatIndicator : false ,
3181
+ messageExpiryInterval : 4321 ,
3182
+ contentType : 'test' ,
3183
+ responseTopic : 'topic' ,
3184
+ correlationData : Buffer . from ( [ 1 , 2 , 3 , 4 ] ) ,
3185
+ userProperties : {
3186
+ test : 'test'
3187
+ }
3188
+ } ,
3189
+ topic : 'topic' ,
3190
+ payload : Buffer . from ( [ 4 , 3 , 2 , 1 ] )
3191
+ } ,
3192
+ clean : true ,
3193
+ keepalive : 30 ,
3194
+ properties : {
3195
+ sessionExpiryInterval : 1234 ,
3196
+ receiveMaximum : 432 ,
3197
+ maximumPacketSize : 100 ,
3198
+ topicAliasMaximum : 456 ,
3199
+ requestResponseInformation : true ,
3200
+ requestProblemInformation : true ,
3201
+ correlationData : undefined ,
3202
+ userProperties : {
3203
+ test : 'test'
3204
+ } ,
3205
+ authenticationMethod : 'test' ,
3206
+ authenticationData : Buffer . from ( [ 1 , 2 , 3 , 4 ] )
3207
+ } ,
3208
+ clientId : 'test'
3209
+ } )
3210
+
3211
+ const parser = mqtt . parser ( )
3212
+
3213
+ parser . on ( 'packet' , packet => {
3214
+ t . equal ( packet . cmd , 'connect' )
3215
+ t . equal ( Object . hasOwn ( packet . properties , 'correlationData' ) , false )
3216
+ } )
3217
+
3218
+ parser . parse ( packet )
3219
+ } )
3220
+
3164
3221
testGenerateErrorMultipleCmds ( [
3165
3222
'publish' ,
3166
3223
'puback' ,
0 commit comments