Skip to content

Commit 7edddc3

Browse files
committed
Add failing tests due to Some(quantity) in send methods
simple_bolt12_send_receive is failing due to unexpected behavior. When quantity is Some in send we get a InvoiceRequestCreationFailed error and in send_using_amount we get a PaymentSendingFailed error. initiate_refund is the only bolt12 method that is successful when a the quantity is Some.
1 parent 3a82198 commit 7edddc3

File tree

1 file changed

+41
-7
lines changed

1 file changed

+41
-7
lines changed

tests/integration_tests_rust.rs

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -425,16 +425,27 @@ fn simple_bolt12_send_receive() {
425425

426426
let expected_amount_msat = 100_000_000;
427427
let offer = node_b.bolt12_payment().receive(expected_amount_msat, "asdf").unwrap();
428-
let payment_id = node_a.bolt12_payment().send(&offer, None, None).unwrap();
428+
let quantity = Some(1);
429+
let payer_note = Some("Test".to_string());
430+
let payment_id = node_a.bolt12_payment().send(&offer, quantity, payer_note.clone()).unwrap();
429431

430432
expect_payment_successful_event!(node_a, Some(payment_id), None);
431433
let node_a_payments = node_a.list_payments();
432434
assert_eq!(node_a_payments.len(), 1);
433435
match node_a_payments.first().unwrap().kind {
434-
PaymentKind::Bolt12Offer { hash, preimage, secret: _, offer_id, .. } => {
436+
PaymentKind::Bolt12Offer {
437+
hash,
438+
preimage,
439+
secret: _,
440+
offer_id,
441+
quantity: ref qty,
442+
payer_note: ref note,
443+
} => {
435444
assert!(hash.is_some());
436445
assert!(preimage.is_some());
437446
assert_eq!(offer_id, offer.id());
447+
assert_eq!(&quantity, qty);
448+
assert_eq!(payer_note.unwrap(), note.clone().unwrap().0);
438449
//TODO: We should eventually set and assert the secret sender-side, too, but the BOLT12
439450
//API currently doesn't allow to do that.
440451
},
@@ -465,23 +476,34 @@ fn simple_bolt12_send_receive() {
465476
let less_than_offer_amount = offer_amount_msat - 10_000;
466477
let expected_amount_msat = offer_amount_msat + 10_000;
467478
let offer = node_b.bolt12_payment().receive(offer_amount_msat, "asdf").unwrap();
479+
let quantity = Some(1);
480+
let payer_note = Some("Test".to_string());
468481
assert!(node_a
469482
.bolt12_payment()
470483
.send_using_amount(&offer, less_than_offer_amount, None, None)
471484
.is_err());
472485
let payment_id = node_a
473486
.bolt12_payment()
474-
.send_using_amount(&offer, expected_amount_msat, None, None)
487+
.send_using_amount(&offer, expected_amount_msat, quantity, payer_note.clone())
475488
.unwrap();
476489

477490
expect_payment_successful_event!(node_a, Some(payment_id), None);
478491
let node_a_payments = node_a.list_payments_with_filter(|p| p.id == payment_id);
479492
assert_eq!(node_a_payments.len(), 1);
480493
let payment_hash = match node_a_payments.first().unwrap().kind {
481-
PaymentKind::Bolt12Offer { hash, preimage, secret: _, offer_id, .. } => {
494+
PaymentKind::Bolt12Offer {
495+
hash,
496+
preimage,
497+
secret: _,
498+
offer_id,
499+
quantity: ref qty,
500+
payer_note: ref note,
501+
} => {
482502
assert!(hash.is_some());
483503
assert!(preimage.is_some());
484504
assert_eq!(offer_id, offer.id());
505+
assert_eq!(&quantity, qty);
506+
assert_eq!(payer_note.unwrap(), note.clone().unwrap().0);
485507
//TODO: We should eventually set and assert the secret sender-side, too, but the BOLT12
486508
//API currently doesn't allow to do that.
487509
hash.unwrap()
@@ -511,8 +533,12 @@ fn simple_bolt12_send_receive() {
511533

512534
// Now node_b refunds the amount node_a just overpaid.
513535
let overpaid_amount = expected_amount_msat - offer_amount_msat;
514-
let refund =
515-
node_b.bolt12_payment().initiate_refund(overpaid_amount, 3600, None, None).unwrap();
536+
let quantity = Some(1);
537+
let payer_note = Some("Test".to_string());
538+
let refund = node_b
539+
.bolt12_payment()
540+
.initiate_refund(overpaid_amount, 3600, quantity, payer_note.clone())
541+
.unwrap();
516542
let invoice = node_a.bolt12_payment().request_refund_payment(&refund).unwrap();
517543
expect_payment_received_event!(node_a, overpaid_amount);
518544

@@ -526,9 +552,17 @@ fn simple_bolt12_send_receive() {
526552
let node_b_payments = node_b.list_payments_with_filter(|p| p.id == node_b_payment_id);
527553
assert_eq!(node_b_payments.len(), 1);
528554
match node_b_payments.first().unwrap().kind {
529-
PaymentKind::Bolt12Refund { hash, preimage, secret: _, .. } => {
555+
PaymentKind::Bolt12Refund {
556+
hash,
557+
preimage,
558+
secret: _,
559+
quantity: ref qty,
560+
payer_note: ref note,
561+
} => {
530562
assert!(hash.is_some());
531563
assert!(preimage.is_some());
564+
assert_eq!(&quantity, qty);
565+
assert_eq!(payer_note.unwrap(), note.clone().unwrap().0)
532566
//TODO: We should eventually set and assert the secret sender-side, too, but the BOLT12
533567
//API currently doesn't allow to do that.
534568
},

0 commit comments

Comments
 (0)