Skip to content

Commit f9ec3a3

Browse files
committed
Use check_added_monitors test utility in invoice utils tests
In a coming commit, the `lightning-invoice::utils` module will move to the `lightning` crate, causing its tests to be included in the global lockorder tests done in that crate. This should be fine, except that the `lightning-invoice::utils` module currently holds the `added_monitors` lock too long causing lockorder violations. Instead, this commit replaces the legacy monitors-added test with the `check_added_monitors` test utility.
1 parent 5a2641e commit f9ec3a3

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lightning-invoice/src/utils.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -905,20 +905,15 @@ mod test {
905905
nodes[0].node.send_payment(payment_hash,
906906
RecipientOnionFields::secret_only(*invoice.payment_secret()),
907907
PaymentId(payment_hash.0), route_params, Retry::Attempts(0)).unwrap();
908-
let mut added_monitors = nodes[0].chain_monitor.added_monitors.lock().unwrap();
909-
assert_eq!(added_monitors.len(), 1);
910-
added_monitors.clear();
908+
check_added_monitors(&nodes[0], 1);
911909

912910
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
913911
assert_eq!(events.len(), 1);
914912
SendEvent::from_event(events.remove(0))
915-
916913
};
917914
nodes[1].node.handle_update_add_htlc(&nodes[0].node.get_our_node_id(), &payment_event.msgs[0]);
918915
nodes[1].node.handle_commitment_signed(&nodes[0].node.get_our_node_id(), &payment_event.commitment_msg);
919-
let mut added_monitors = nodes[1].chain_monitor.added_monitors.lock().unwrap();
920-
assert_eq!(added_monitors.len(), 1);
921-
added_monitors.clear();
916+
check_added_monitors(&nodes[1], 1);
922917
let events = nodes[1].node.get_and_clear_pending_msg_events();
923918
assert_eq!(events.len(), 2);
924919
}
@@ -1362,9 +1357,7 @@ mod test {
13621357
nodes[0].node.send_payment(payment_hash,
13631358
RecipientOnionFields::secret_only(*invoice.payment_secret()),
13641359
PaymentId(payment_hash.0), params, Retry::Attempts(0)).unwrap();
1365-
let mut added_monitors = nodes[0].chain_monitor.added_monitors.lock().unwrap();
1366-
assert_eq!(added_monitors.len(), 1);
1367-
added_monitors.clear();
1360+
check_added_monitors(&nodes[0], 1);
13681361

13691362
let mut events = nodes[0].node.get_and_clear_pending_msg_events();
13701363
assert_eq!(events.len(), 1);

0 commit comments

Comments
 (0)