@@ -367,12 +367,7 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
367
367
RecipientOnionFields :: secret_only ( payment_secret_2) , PaymentId ( payment_hash_2. 0 ) ) . unwrap ( ) ;
368
368
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
369
369
370
- let events_1 = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
371
- assert_eq ! ( events_1. len( ) , 1 ) ;
372
- match events_1[ 0 ] {
373
- MessageSendEvent :: UpdateHTLCs { .. } => { } ,
374
- _ => panic ! ( "Unexpected event" ) ,
375
- }
370
+ get_htlc_update_msgs ( & nodes[ 0 ] , & nodes[ 1 ] . node . get_our_node_id ( ) ) ;
376
371
377
372
// Send back update_fulfill_htlc + commitment_signed for the first payment.
378
373
nodes[ 1 ] . node . claim_funds ( payment_preimage_1) ;
@@ -384,25 +379,9 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
384
379
let events_2 = nodes[ 1 ] . node . get_and_clear_pending_msg_events ( ) ;
385
380
assert_eq ! ( events_2. len( ) , 1 ) ;
386
381
match events_2[ 0 ] {
387
- MessageSendEvent :: UpdateHTLCs { ref node_id, updates : msgs:: CommitmentUpdate { ref update_add_htlcs, ref update_fulfill_htlcs, ref update_fail_htlcs, ref update_fail_malformed_htlcs, ref update_fee, ref commitment_signed } } => {
388
- assert_eq ! ( * node_id, nodes[ 0 ] . node. get_our_node_id( ) ) ;
389
- assert ! ( update_add_htlcs. is_empty( ) ) ;
390
- assert_eq ! ( update_fulfill_htlcs. len( ) , 1 ) ;
391
- assert ! ( update_fail_htlcs. is_empty( ) ) ;
392
- assert ! ( update_fail_malformed_htlcs. is_empty( ) ) ;
393
- assert ! ( update_fee. is_none( ) ) ;
394
-
382
+ MessageSendEvent :: UpdateHTLCs { ref node_id, updates : msgs:: CommitmentUpdate { ref update_fulfill_htlcs, ref commitment_signed, .. } } => {
395
383
nodes[ 0 ] . node . handle_update_fulfill_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & update_fulfill_htlcs[ 0 ] ) ;
396
- let events_3 = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
397
- assert_eq ! ( events_3. len( ) , 1 ) ;
398
- match events_3[ 0 ] {
399
- Event :: PaymentSent { ref payment_preimage, ref payment_hash, .. } => {
400
- assert_eq ! ( * payment_preimage, payment_preimage_1) ;
401
- assert_eq ! ( * payment_hash, payment_hash_1) ;
402
- } ,
403
- _ => panic ! ( "Unexpected event" ) ,
404
- }
405
-
384
+ expect_payment_sent ( & nodes[ 0 ] , payment_preimage_1, None , false , false ) ;
406
385
if monitor_update_failure {
407
386
chanmon_cfgs[ 0 ] . persister . set_update_ret ( ChannelMonitorUpdateStatus :: InProgress ) ;
408
387
}
@@ -475,11 +454,6 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
475
454
assert ! ( as_resp. 3 == RAACommitmentOrder :: CommitmentFirst ) ;
476
455
477
456
// Now that everything is restored, get the CS + RAA and handle them.
478
- assert_eq ! ( as_resp. 2 . as_ref( ) . unwrap( ) . update_add_htlcs. len( ) , 1 ) ;
479
- assert ! ( as_resp. 2 . as_ref( ) . unwrap( ) . update_fulfill_htlcs. is_empty( ) ) ;
480
- assert ! ( as_resp. 2 . as_ref( ) . unwrap( ) . update_fail_htlcs. is_empty( ) ) ;
481
- assert ! ( as_resp. 2 . as_ref( ) . unwrap( ) . update_fail_malformed_htlcs. is_empty( ) ) ;
482
- assert ! ( as_resp. 2 . as_ref( ) . unwrap( ) . update_fee. is_none( ) ) ;
483
457
nodes[ 1 ] . node . handle_update_add_htlc ( & nodes[ 0 ] . node . get_our_node_id ( ) , & as_resp. 2 . as_ref ( ) . unwrap ( ) . update_add_htlcs [ 0 ] ) ;
484
458
nodes[ 1 ] . node . handle_commitment_signed ( & nodes[ 0 ] . node . get_our_node_id ( ) , & as_resp. 2 . as_ref ( ) . unwrap ( ) . commitment_signed ) ;
485
459
let bs_revoke_and_ack = get_event_msg ! ( nodes[ 1 ] , MessageSendEvent :: SendRevokeAndACK , nodes[ 0 ] . node. get_our_node_id( ) ) ;
@@ -488,22 +462,12 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
488
462
489
463
nodes[ 1 ] . node . handle_revoke_and_ack ( & nodes[ 0 ] . node . get_our_node_id ( ) , as_resp. 1 . as_ref ( ) . unwrap ( ) ) ;
490
464
let bs_second_commitment_signed = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
491
- assert ! ( bs_second_commitment_signed. update_add_htlcs. is_empty( ) ) ;
492
- assert ! ( bs_second_commitment_signed. update_fulfill_htlcs. is_empty( ) ) ;
493
- assert ! ( bs_second_commitment_signed. update_fail_htlcs. is_empty( ) ) ;
494
- assert ! ( bs_second_commitment_signed. update_fail_malformed_htlcs. is_empty( ) ) ;
495
- assert ! ( bs_second_commitment_signed. update_fee. is_none( ) ) ;
496
465
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
497
466
498
467
// The rest of this is boilerplate for resolving the previous state.
499
468
500
469
nodes[ 0 ] . node . handle_revoke_and_ack ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_revoke_and_ack) ;
501
470
let as_commitment_signed = get_htlc_update_msgs ! ( nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
502
- assert ! ( as_commitment_signed. update_add_htlcs. is_empty( ) ) ;
503
- assert ! ( as_commitment_signed. update_fulfill_htlcs. is_empty( ) ) ;
504
- assert ! ( as_commitment_signed. update_fail_htlcs. is_empty( ) ) ;
505
- assert ! ( as_commitment_signed. update_fail_malformed_htlcs. is_empty( ) ) ;
506
- assert ! ( as_commitment_signed. update_fee. is_none( ) ) ;
507
471
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
508
472
509
473
nodes[ 0 ] . node . handle_commitment_signed ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_second_commitment_signed. commitment_signed ) ;
@@ -523,20 +487,7 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) {
523
487
expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
524
488
525
489
let events_5 = nodes[ 1 ] . node . get_and_clear_pending_events ( ) ;
526
- assert_eq ! ( events_5. len( ) , 1 ) ;
527
- match events_5[ 0 ] {
528
- Event :: PaymentClaimable { ref payment_hash, ref purpose, .. } => {
529
- assert_eq ! ( payment_hash_2, * payment_hash) ;
530
- match & purpose {
531
- PaymentPurpose :: Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => {
532
- assert ! ( payment_preimage. is_none( ) ) ;
533
- assert_eq ! ( payment_secret_2, * payment_secret) ;
534
- } ,
535
- _ => panic ! ( "expected PaymentPurpose::Bolt11InvoicePayment" )
536
- }
537
- } ,
538
- _ => panic ! ( "Unexpected event" ) ,
539
- }
490
+ check_payment_claimable ( & events_5[ 0 ] , payment_hash_2, payment_secret_2, 1_000_000 , None , nodes[ 1 ] . node . get_our_node_id ( ) ) ;
540
491
541
492
nodes[ 0 ] . node . handle_revoke_and_ack ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_second_revoke_and_ack) ;
542
493
assert ! ( nodes[ 0 ] . node. get_and_clear_pending_msg_events( ) . is_empty( ) ) ;
0 commit comments