diff --git a/lightning/src/ln/async_signer_tests.rs b/lightning/src/ln/async_signer_tests.rs index 99ec3db127f..a21f2fd3978 100644 --- a/lightning/src/ln/async_signer_tests.rs +++ b/lightning/src/ln/async_signer_tests.rs @@ -367,12 +367,7 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) { RecipientOnionFields::secret_only(payment_secret_2), PaymentId(payment_hash_2.0)).unwrap(); check_added_monitors!(nodes[0], 1); - let events_1 = nodes[0].node.get_and_clear_pending_msg_events(); - assert_eq!(events_1.len(), 1); - match events_1[0] { - MessageSendEvent::UpdateHTLCs { .. } => {}, - _ => panic!("Unexpected event"), - } + get_htlc_update_msgs(&nodes[0], &nodes[1].node.get_our_node_id()); // Send back update_fulfill_htlc + commitment_signed for the first payment. nodes[1].node.claim_funds(payment_preimage_1); @@ -384,25 +379,9 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) { let events_2 = nodes[1].node.get_and_clear_pending_msg_events(); assert_eq!(events_2.len(), 1); match events_2[0] { - 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 } } => { - assert_eq!(*node_id, nodes[0].node.get_our_node_id()); - assert!(update_add_htlcs.is_empty()); - assert_eq!(update_fulfill_htlcs.len(), 1); - assert!(update_fail_htlcs.is_empty()); - assert!(update_fail_malformed_htlcs.is_empty()); - assert!(update_fee.is_none()); - + MessageSendEvent::UpdateHTLCs { ref node_id, updates: msgs::CommitmentUpdate { ref update_fulfill_htlcs, ref commitment_signed, .. } } => { nodes[0].node.handle_update_fulfill_htlc(&nodes[1].node.get_our_node_id(), &update_fulfill_htlcs[0]); - let events_3 = nodes[0].node.get_and_clear_pending_events(); - assert_eq!(events_3.len(), 1); - match events_3[0] { - Event::PaymentSent { ref payment_preimage, ref payment_hash, .. } => { - assert_eq!(*payment_preimage, payment_preimage_1); - assert_eq!(*payment_hash, payment_hash_1); - }, - _ => panic!("Unexpected event"), - } - + expect_payment_sent(&nodes[0], payment_preimage_1, None, false, false); if monitor_update_failure { chanmon_cfgs[0].persister.set_update_ret(ChannelMonitorUpdateStatus::InProgress); } @@ -475,11 +454,6 @@ fn do_test_async_commitment_signature_ordering(monitor_update_failure: bool) { assert!(as_resp.3 == RAACommitmentOrder::CommitmentFirst); // Now that everything is restored, get the CS + RAA and handle them. - assert_eq!(as_resp.2.as_ref().unwrap().update_add_htlcs.len(), 1); - assert!(as_resp.2.as_ref().unwrap().update_fulfill_htlcs.is_empty()); - assert!(as_resp.2.as_ref().unwrap().update_fail_htlcs.is_empty()); - assert!(as_resp.2.as_ref().unwrap().update_fail_malformed_htlcs.is_empty()); - assert!(as_resp.2.as_ref().unwrap().update_fee.is_none()); nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &as_resp.2.as_ref().unwrap().update_add_htlcs[0]); nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &as_resp.2.as_ref().unwrap().commitment_signed); 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) { nodes[1].node.handle_revoke_and_ack(&nodes[0].node.get_our_node_id(), as_resp.1.as_ref().unwrap()); let bs_second_commitment_signed = get_htlc_update_msgs!(nodes[1], nodes[0].node.get_our_node_id()); - assert!(bs_second_commitment_signed.update_add_htlcs.is_empty()); - assert!(bs_second_commitment_signed.update_fulfill_htlcs.is_empty()); - assert!(bs_second_commitment_signed.update_fail_htlcs.is_empty()); - assert!(bs_second_commitment_signed.update_fail_malformed_htlcs.is_empty()); - assert!(bs_second_commitment_signed.update_fee.is_none()); check_added_monitors!(nodes[1], 1); // The rest of this is boilerplate for resolving the previous state. nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_revoke_and_ack); let as_commitment_signed = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id()); - assert!(as_commitment_signed.update_add_htlcs.is_empty()); - assert!(as_commitment_signed.update_fulfill_htlcs.is_empty()); - assert!(as_commitment_signed.update_fail_htlcs.is_empty()); - assert!(as_commitment_signed.update_fail_malformed_htlcs.is_empty()); - assert!(as_commitment_signed.update_fee.is_none()); check_added_monitors!(nodes[0], 1); 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) { expect_pending_htlcs_forwardable!(nodes[1]); let events_5 = nodes[1].node.get_and_clear_pending_events(); - assert_eq!(events_5.len(), 1); - match events_5[0] { - Event::PaymentClaimable { ref payment_hash, ref purpose, .. } => { - assert_eq!(payment_hash_2, *payment_hash); - match &purpose { - PaymentPurpose::Bolt11InvoicePayment { payment_preimage, payment_secret, .. } => { - assert!(payment_preimage.is_none()); - assert_eq!(payment_secret_2, *payment_secret); - }, - _ => panic!("expected PaymentPurpose::Bolt11InvoicePayment") - } - }, - _ => panic!("Unexpected event"), - } + check_payment_claimable(&events_5[0], payment_hash_2, payment_secret_2, 1_000_000, None, nodes[1].node.get_our_node_id()); nodes[0].node.handle_revoke_and_ack(&nodes[1].node.get_our_node_id(), &bs_second_revoke_and_ack); assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());