Skip to content

Commit 05a8e0f

Browse files
committed
f refcell, not mutex
1 parent 2c07936 commit 05a8e0f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lightning-invoice/src/payment.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ mod tests {
462462
use std::cell::RefCell;
463463
use std::collections::VecDeque;
464464
use std::time::{SystemTime, Duration};
465-
use std::sync::Mutex;
466465

467466
fn invoice(payment_preimage: PaymentPreimage) -> Invoice {
468467
let payment_hash = Sha256::hash(&payment_preimage.0);
@@ -1188,12 +1187,12 @@ mod tests {
11881187
}
11891188

11901189
// *** Full Featured Functional Tests with a Real ChannelManager ***
1191-
struct ManualRouter(Mutex<VecDeque<Result<Route, LightningError>>>);
1190+
struct ManualRouter(RefCell<VecDeque<Result<Route, LightningError>>>);
11921191

11931192
impl<S: routing::Score> Router<S> for ManualRouter {
11941193
fn find_route(&self, _payer: &PublicKey, _params: &RouteParameters, _first_hops: Option<&[&ChannelDetails]>, _scorer: &S)
11951194
-> Result<Route, LightningError> {
1196-
self.0.lock().unwrap().pop_front().unwrap()
1195+
self.0.borrow_mut().pop_front().unwrap()
11971196
}
11981197
}
11991198

@@ -1202,7 +1201,7 @@ mod tests {
12021201
if std::thread::panicking() {
12031202
return;
12041203
}
1205-
assert!(self.0.lock().unwrap().is_empty());
1204+
assert!(self.0.borrow_mut().is_empty());
12061205
}
12071206
}
12081207

@@ -1244,7 +1243,7 @@ mod tests {
12441243
route.paths[0][0].fee_msat = 50_000_001;
12451244
route.paths[1][0].fee_msat = 50_000_000;
12461245
routes.push_back(Ok(route.clone()));
1247-
let route_res = ManualRouter(Mutex::new(routes));
1246+
let route_res = ManualRouter(RefCell::new(routes));
12481247

12491248
let event_handled = core::cell::RefCell::new(false);
12501249
let event_handler = |_: &_| { *event_handled.borrow_mut() = true; };

0 commit comments

Comments
 (0)