Skip to content

Commit 510ae5d

Browse files
committed
f Fix tests with cfg(c_bindings) set
1 parent 6183787 commit 510ae5d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

lightning-liquidity/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ level = "forbid"
4242
# When adding a new cfg attribute, ensure that it is added to this list.
4343
check-cfg = [
4444
"cfg(lsps1_service)",
45+
"cfg(c_bindings)",
4546
]

lightning-liquidity/tests/common/mod.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ impl SocketDescriptor for TestDescriptor {
6262
fn disconnect_socket(&mut self) {}
6363
}
6464

65+
#[cfg(c_bindings)]
66+
type LockingWrapper<T> = lightning::routing::scoring::MultiThreadedLockableScore<T>;
67+
#[cfg(not(c_bindings))]
68+
type LockingWrapper<T> = std::sync::Mutex<T>;
69+
6570
type ChannelManager = channelmanager::ChannelManager<
6671
Arc<ChainMonitor>,
6772
Arc<test_utils::TestBroadcaster>,
@@ -74,7 +79,7 @@ type ChannelManager = channelmanager::ChannelManager<
7479
Arc<NetworkGraph<Arc<test_utils::TestLogger>>>,
7580
Arc<test_utils::TestLogger>,
7681
Arc<KeysManager>,
77-
Arc<Mutex<TestScorer>>,
82+
Arc<LockingWrapper<TestScorer>>,
7883
(),
7984
TestScorer,
8085
>,
@@ -136,7 +141,7 @@ pub(crate) struct Node {
136141
pub(crate) network_graph: Arc<NetworkGraph<Arc<test_utils::TestLogger>>>,
137142
pub(crate) logger: Arc<test_utils::TestLogger>,
138143
pub(crate) best_block: BestBlock,
139-
pub(crate) scorer: Arc<Mutex<TestScorer>>,
144+
pub(crate) scorer: Arc<LockingWrapper<TestScorer>>,
140145
}
141146

142147
impl Drop for Node {
@@ -371,6 +376,9 @@ impl ScoreUpdate for TestScorer {
371376
fn time_passed(&mut self, _: Duration) {}
372377
}
373378

379+
#[cfg(c_bindings)]
380+
impl lightning::routing::scoring::Score for TestScorer {}
381+
374382
impl Drop for TestScorer {
375383
fn drop(&mut self) {
376384
if std::thread::panicking() {
@@ -400,7 +408,7 @@ pub(crate) fn create_liquidity_node(
400408
let logger = Arc::new(test_utils::TestLogger::with_id(format!("node {}", i)));
401409
let genesis_block = genesis_block(network);
402410
let network_graph = Arc::new(NetworkGraph::new(network, logger.clone()));
403-
let scorer = Arc::new(Mutex::new(TestScorer::new()));
411+
let scorer = Arc::new(LockingWrapper::new(TestScorer::new()));
404412
let now = Duration::from_secs(genesis_block.header.time as u64);
405413
let seed = [i as u8; 32];
406414
let keys_manager = Arc::new(KeysManager::new(&seed, now.as_secs(), now.subsec_nanos()));

0 commit comments

Comments
 (0)