@@ -316,8 +316,7 @@ func TestParseFieldDataLength(t *testing.T) {
316316}
317317
318318// TestParse32Bytes checks that the payment hash is properly parsed.
319- // If the data does not have a length of 52 bytes, we skip over parsing the
320- // field and do not return an error.
319+ // If the data does not have a length of 52 bytes, we return an error.
321320func TestParse32Bytes (t * testing.T ) {
322321 t .Parallel ()
323322
@@ -329,24 +328,21 @@ func TestParse32Bytes(t *testing.T) {
329328 result * [32 ]byte
330329 }{
331330 {
332- data : []byte {},
333- valid : true ,
334- result : nil , // skip unknown length, not 52 bytes
331+ data : []byte {},
332+ valid : false ,
335333 },
336334 {
337- data : []byte {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 },
338- valid : true ,
339- result : nil , // skip unknown length, not 52 bytes
335+ data : []byte {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 },
336+ valid : false ,
340337 },
341338 {
342339 data : testPaymentHashData ,
343340 valid : true ,
344341 result : & testPaymentHash ,
345342 },
346343 {
347- data : append (testPaymentHashData , 0x0 ),
348- valid : true ,
349- result : nil , // skip unknown length, not 52 bytes
344+ data : append (testPaymentHashData , 0x0 ),
345+ valid : false ,
350346 },
351347 }
352348
@@ -422,8 +418,7 @@ func TestParseDescription(t *testing.T) {
422418}
423419
424420// TestParseDestination checks that the destination is properly parsed.
425- // If the data does not have a length of 53 bytes, we skip over parsing the
426- // field and do not return an error.
421+ // If the data does not have a length of 53 bytes, we return an error.
427422func TestParseDestination (t * testing.T ) {
428423 t .Parallel ()
429424
@@ -435,24 +430,21 @@ func TestParseDestination(t *testing.T) {
435430 result * btcec.PublicKey
436431 }{
437432 {
438- data : []byte {},
439- valid : true ,
440- result : nil , // skip unknown length, not 53 bytes
433+ data : []byte {},
434+ valid : false ,
441435 },
442436 {
443- data : []byte {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 },
444- valid : true ,
445- result : nil , // skip unknown length, not 53 bytes
437+ data : []byte {0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 },
438+ valid : false ,
446439 },
447440 {
448441 data : testPubKeyData ,
449442 valid : true ,
450443 result : testPubKey ,
451444 },
452445 {
453- data : append (testPubKeyData , 0x0 ),
454- valid : true ,
455- result : nil , // skip unknown length, not 53 bytes
446+ data : append (testPubKeyData , 0x0 ),
447+ valid : false ,
456448 },
457449 }
458450
0 commit comments