Skip to content

Commit 2a2cf2e

Browse files
committed
zpay32: adapt the current tests to the changes
Adpat the current tests to the new behavior of 'Decode', 'validateInvoice', 'parseTaggedFields', 'parse32Bytes' and 'parseDestination'.
1 parent 3db9187 commit 2a2cf2e

File tree

4 files changed

+93
-143
lines changed

4 files changed

+93
-143
lines changed

channeldb/migration_01_to_11/migration_11_invoices_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ func getPayReq(net *bitcoinCfg.Params) (string, error) {
161161
options := []func(*zpay32.Invoice){
162162
zpay32.CLTVExpiry(uint64(testCltvDelta)),
163163
zpay32.Description("test"),
164+
zpay32.PaymentAddr([32]byte{}),
164165
}
165166

166167
payReq, err := zpay32.NewInvoice(

lnrpc/routerrpc/router_backend_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -782,9 +782,8 @@ func TestExtractIntentFromSendRequest(t *testing.T) {
782782
sendReq: &SendPaymentRequest{
783783
PaymentRequest: paymentReqMissingAddr,
784784
},
785-
valid: false,
786-
expectedErrorMsg: "payment request must contain " +
787-
"either a payment address or blinded paths",
785+
valid: false,
786+
expectedErrorMsg: "payment secret not found",
788787
},
789788
{
790789
name: "Invalid dest vertex length",

zpay32/invoice_internal_test.go

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
321320
func 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.
427422
func 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

Comments
 (0)