Skip to content

Commit bdaccdc

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 bdaccdc

File tree

4 files changed

+92
-141
lines changed

4 files changed

+92
-141
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: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -329,24 +329,21 @@ func TestParse32Bytes(t *testing.T) {
329329
result *[32]byte
330330
}{
331331
{
332-
data: []byte{},
333-
valid: true,
334-
result: nil, // skip unknown length, not 52 bytes
332+
data: []byte{},
333+
valid: false,
335334
},
336335
{
337-
data: []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
338-
valid: true,
339-
result: nil, // skip unknown length, not 52 bytes
336+
data: []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
337+
valid: false,
340338
},
341339
{
342340
data: testPaymentHashData,
343341
valid: true,
344342
result: &testPaymentHash,
345343
},
346344
{
347-
data: append(testPaymentHashData, 0x0),
348-
valid: true,
349-
result: nil, // skip unknown length, not 52 bytes
345+
data: append(testPaymentHashData, 0x0),
346+
valid: false,
350347
},
351348
}
352349

@@ -422,8 +419,7 @@ func TestParseDescription(t *testing.T) {
422419
}
423420

424421
// 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.
422+
// If the data does not have a length of 53 bytes, we return an error.
427423
func TestParseDestination(t *testing.T) {
428424
t.Parallel()
429425

@@ -435,24 +431,21 @@ func TestParseDestination(t *testing.T) {
435431
result *btcec.PublicKey
436432
}{
437433
{
438-
data: []byte{},
439-
valid: true,
440-
result: nil, // skip unknown length, not 53 bytes
434+
data: []byte{},
435+
valid: false,
441436
},
442437
{
443-
data: []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
444-
valid: true,
445-
result: nil, // skip unknown length, not 53 bytes
438+
data: []byte{0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
439+
valid: false,
446440
},
447441
{
448442
data: testPubKeyData,
449443
valid: true,
450444
result: testPubKey,
451445
},
452446
{
453-
data: append(testPubKeyData, 0x0),
454-
valid: true,
455-
result: nil, // skip unknown length, not 53 bytes
447+
data: append(testPubKeyData, 0x0),
448+
valid: false,
456449
},
457450
}
458451

0 commit comments

Comments
 (0)