Skip to content

Commit b8135fb

Browse files
committed
Fixup changes
1 parent 681e3cb commit b8135fb

5 files changed

Lines changed: 35 additions & 40 deletions

File tree

orange-sdk/src/event.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use ldk_node::payment::{ConfirmationStatus, PaymentKind};
1414
use ldk_node::{CustomTlvRecord, DynStore, UserChannelId};
1515

1616
use std::collections::VecDeque;
17-
use std::sync::{Arc, Condvar, Mutex};
17+
use std::sync::{Arc, Mutex};
1818
use std::task::{Poll, Waker};
1919
use tokio::sync::watch;
2020

@@ -190,7 +190,6 @@ impl_writeable_tlv_based_enum!(Event,
190190
pub struct EventQueue {
191191
queue: Arc<Mutex<VecDeque<Event>>>,
192192
waker: Arc<Mutex<Option<Waker>>>,
193-
notifier: Condvar,
194193
kv_store: Arc<DynStore>,
195194
logger: Arc<Logger>,
196195
}
@@ -199,8 +198,7 @@ impl EventQueue {
199198
pub(crate) fn new(kv_store: Arc<DynStore>, logger: Arc<Logger>) -> Self {
200199
let queue = Arc::new(Mutex::new(VecDeque::new()));
201200
let waker = Arc::new(Mutex::new(None));
202-
let notifier = Condvar::new();
203-
Self { queue, waker, notifier, kv_store, logger }
201+
Self { queue, waker, kv_store, logger }
204202
}
205203

206204
pub(crate) fn add_event(&self, event: Event) -> Result<(), ldk_node::lightning::io::Error> {
@@ -210,8 +208,6 @@ impl EventQueue {
210208
self.persist_queue(&locked_queue)?;
211209
}
212210

213-
self.notifier.notify_one();
214-
215211
if let Some(waker) = self.waker.lock().unwrap().take() {
216212
waker.wake();
217213
}
@@ -227,19 +223,12 @@ impl EventQueue {
227223
EventFuture { event_queue: Arc::clone(&self.queue), waker: Arc::clone(&self.waker) }.await
228224
}
229225

230-
pub(crate) fn wait_next_event(&self) -> Event {
231-
let locked_queue =
232-
self.notifier.wait_while(self.queue.lock().unwrap(), |queue| queue.is_empty()).unwrap();
233-
locked_queue.front().unwrap().clone()
234-
}
235-
236226
pub(crate) fn event_handled(&self) -> Result<(), ldk_node::lightning::io::Error> {
237227
{
238228
let mut locked_queue = self.queue.lock().unwrap();
239229
locked_queue.pop_front();
240230
self.persist_queue(&locked_queue)?;
241231
}
242-
self.notifier.notify_one();
243232

244233
if let Some(waker) = self.waker.lock().unwrap().take() {
245234
waker.wake();

orange-sdk/src/ffi/bitcoin_payment_instructions.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ pub enum ParseError {
8585
UnknownRequiredParameter,
8686
HrnResolutionError(String),
8787
InstructionsExpired,
88+
InvalidLnurl(String),
8889
}
8990

9091
impl Display for ParseError {
@@ -108,6 +109,7 @@ impl Display for ParseError {
108109
write!(f, "Human readable name resolution error: {}", e)
109110
},
110111
ParseError::InstructionsExpired => write!(f, "Payment instructions have expired"),
112+
ParseError::InvalidLnurl(e) => write!(f, "Invalid LNURL: {}", e),
111113
}
112114
}
113115
}
@@ -131,6 +133,7 @@ impl From<BPIParseError> for ParseError {
131133
ParseError::HrnResolutionError(msg.to_string())
132134
},
133135
BPIParseError::InstructionsExpired => ParseError::InstructionsExpired,
136+
BPIParseError::InvalidLnurl(msg) => ParseError::InvalidLnurl(msg.to_string()),
134137
}
135138
}
136139
}

orange-sdk/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,10 @@ impl Wallet {
13041304
/// **Caution:** Users must handle events as quickly as possible to prevent a large event backlog,
13051305
/// which can increase the memory footprint of [`Wallet`].
13061306
pub fn wait_next_event(&self) -> Event {
1307-
self.inner.event_queue.wait_next_event()
1307+
let fut = self.inner.event_queue.next_event_async();
1308+
// We use our runtime for the sync variant to ensure `tokio::task::block_in_place` is
1309+
// always called if we'd ever hit this in an outer runtime context.
1310+
self.inner.runtime.block_on(fut)
13081311
}
13091312

13101313
/// Confirm the last retrieved event handled.

orange-sdk/tests/integration_tests.rs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::time::Duration;
1818

1919
mod test_utils;
2020

21-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
21+
#[tokio::test(flavor = "multi_thread")]
2222
async fn test_node_start() {
2323
let TestParams { wallet, .. } = build_test_nodes().await;
2424

@@ -88,7 +88,7 @@ async fn test_receive_to_trusted() {
8888
lsp.stop().unwrap();
8989
}
9090

91-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
91+
#[tokio::test(flavor = "multi_thread")]
9292
async fn test_pay_from_trusted() {
9393
let TestParams { wallet, third_party, lsp, .. } = build_test_nodes().await;
9494

@@ -167,7 +167,7 @@ async fn test_pay_from_trusted() {
167167
}
168168
}
169169

170-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
170+
#[tokio::test(flavor = "multi_thread")]
171171
async fn test_sweep_to_ln() {
172172
let TestParams { wallet, lsp, third_party, .. } = build_test_nodes().await;
173173

@@ -320,7 +320,7 @@ async fn test_sweep_to_ln() {
320320
);
321321
}
322322

323-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
323+
#[tokio::test(flavor = "multi_thread")]
324324
async fn test_receive_to_ln() {
325325
let TestParams { wallet, third_party, .. } = build_test_nodes().await;
326326

@@ -358,7 +358,7 @@ async fn test_receive_to_ln() {
358358
);
359359
}
360360

361-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
361+
#[tokio::test(flavor = "multi_thread")]
362362
async fn test_receive_to_onchain() {
363363
let TestParams { wallet, lsp, bitcoind, third_party, .. } = build_test_nodes().await;
364364

@@ -554,7 +554,7 @@ async fn run_test_pay_lightning_from_self_custody(amountless: bool) {
554554
&& p.amount_msat == Some(amount.milli_sats())));
555555
}
556556

557-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
557+
#[tokio::test(flavor = "multi_thread")]
558558
async fn test_pay_lightning_from_self_custody() {
559559
run_test_pay_lightning_from_self_custody(false).await;
560560
run_test_pay_lightning_from_self_custody(true).await;
@@ -642,13 +642,13 @@ async fn run_test_pay_bolt12_from_self_custody(amountless: bool) {
642642
&& p.amount_msat == Some(amount.milli_sats())));
643643
}
644644

645-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
645+
#[tokio::test(flavor = "multi_thread")]
646646
async fn test_pay_bolt12_from_self_custody() {
647647
run_test_pay_bolt12_from_self_custody(false).await;
648648
run_test_pay_bolt12_from_self_custody(true).await;
649649
}
650650

651-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
651+
#[tokio::test(flavor = "multi_thread")]
652652
async fn test_pay_onchain_from_self_custody() {
653653
let TestParams { wallet, bitcoind, third_party, .. } = build_test_nodes().await;
654654

@@ -751,7 +751,7 @@ async fn test_pay_onchain_from_self_custody() {
751751
.await;
752752
}
753753

754-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
754+
#[tokio::test(flavor = "multi_thread")]
755755
async fn test_force_close_handling() {
756756
let TestParams { wallet, lsp, bitcoind, third_party, .. } = build_test_nodes().await;
757757

@@ -792,7 +792,7 @@ async fn test_force_close_handling() {
792792
assert!(!rebalancing);
793793
}
794794

795-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
795+
#[tokio::test(flavor = "multi_thread")]
796796
async fn test_close_all_channels() {
797797
let TestParams { wallet, lsp, bitcoind, third_party, .. } = build_test_nodes().await;
798798

@@ -826,7 +826,7 @@ async fn test_close_all_channels() {
826826
assert!(!rebalancing);
827827
}
828828

829-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
829+
#[tokio::test(flavor = "multi_thread")]
830830
async fn test_threshold_boundary_trusted_balance_limit() {
831831
let TestParams { wallet, third_party, .. } = build_test_nodes().await;
832832

@@ -902,7 +902,7 @@ async fn test_threshold_boundary_trusted_balance_limit() {
902902
);
903903
}
904904

905-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
905+
#[tokio::test(flavor = "multi_thread")]
906906
async fn test_threshold_boundary_rebalance_min() {
907907
let TestParams { wallet, third_party, .. } = build_test_nodes().await;
908908

@@ -975,7 +975,7 @@ async fn test_threshold_boundary_rebalance_min() {
975975
);
976976
}
977977

978-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
978+
#[tokio::test(flavor = "multi_thread")]
979979
async fn test_threshold_boundary_onchain_receive_threshold() {
980980
let TestParams { wallet, .. } = build_test_nodes().await;
981981

@@ -1035,7 +1035,7 @@ async fn test_threshold_boundary_onchain_receive_threshold() {
10351035
}
10361036
}
10371037

1038-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1038+
#[tokio::test(flavor = "multi_thread")]
10391039
async fn test_threshold_combinations_and_edge_cases() {
10401040
let TestParams { wallet, .. } = build_test_nodes().await;
10411041

@@ -1093,7 +1093,7 @@ async fn test_threshold_combinations_and_edge_cases() {
10931093
}
10941094
}
10951095

1096-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1096+
#[tokio::test(flavor = "multi_thread")]
10971097
async fn test_invalid_payment_instructions() {
10981098
let TestParams { wallet, third_party, .. } = build_test_nodes().await;
10991099

@@ -1154,7 +1154,7 @@ async fn test_invalid_payment_instructions() {
11541154
assert_eq!(txs.len(), 0, "Failed payments should not be recorded in transaction list");
11551155
}
11561156

1157-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1157+
#[tokio::test(flavor = "multi_thread")]
11581158
async fn test_payment_with_expired_invoice() {
11591159
let TestParams { wallet, third_party, .. } = build_test_nodes().await;
11601160

@@ -1183,7 +1183,7 @@ async fn test_payment_with_expired_invoice() {
11831183
assert!(matches!(parse_result.unwrap_err(), ParseError::InstructionsExpired));
11841184
}
11851185

1186-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1186+
#[tokio::test(flavor = "multi_thread")]
11871187
async fn test_payment_network_mismatch() {
11881188
let TestParams { wallet, bitcoind, .. } = build_test_nodes().await;
11891189

@@ -1236,7 +1236,7 @@ async fn test_payment_network_mismatch() {
12361236
);
12371237
}
12381238

1239-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1239+
#[tokio::test(flavor = "multi_thread")]
12401240
async fn test_concurrent_payments() {
12411241
let TestParams { wallet, bitcoind, third_party, .. } = build_test_nodes().await;
12421242

@@ -1408,7 +1408,7 @@ async fn test_concurrent_payments() {
14081408
);
14091409
}
14101410

1411-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1411+
#[tokio::test(flavor = "multi_thread")]
14121412
async fn test_concurrent_receive_operations() {
14131413
let TestParams { wallet, third_party, .. } = build_test_nodes().await;
14141414

@@ -1463,7 +1463,7 @@ async fn test_concurrent_receive_operations() {
14631463
assert_eq!(incoming_count, 2, "Should have exactly 2 incoming transactions");
14641464
}
14651465

1466-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1466+
#[tokio::test(flavor = "multi_thread")]
14671467
async fn test_balance_consistency_under_load() {
14681468
let TestParams { wallet, third_party, .. } = build_test_nodes().await;
14691469

@@ -1514,7 +1514,7 @@ async fn test_balance_consistency_under_load() {
15141514
}
15151515
}
15161516

1517-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1517+
#[tokio::test(flavor = "multi_thread")]
15181518
async fn test_invalid_tunables_relationships() {
15191519
let TestParams { wallet, .. } = build_test_nodes().await;
15201520

@@ -1591,7 +1591,7 @@ async fn test_invalid_tunables_relationships() {
15911591
}
15921592
}
15931593

1594-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1594+
#[tokio::test(flavor = "multi_thread")]
15951595
async fn test_extreme_amount_handling() {
15961596
let TestParams { wallet, .. } = build_test_nodes().await;
15971597

@@ -1656,7 +1656,7 @@ async fn test_extreme_amount_handling() {
16561656
// On-chain address depends on threshold, not msat precision
16571657
}
16581658

1659-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1659+
#[tokio::test(flavor = "multi_thread")]
16601660
async fn test_wallet_configuration_validation() {
16611661
let TestParams { wallet, .. } = build_test_nodes().await;
16621662

@@ -1719,7 +1719,7 @@ async fn test_wallet_configuration_validation() {
17191719
);
17201720
}
17211721

1722-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1722+
#[tokio::test(flavor = "multi_thread")]
17231723
async fn test_edge_case_payment_instruction_parsing() {
17241724
let TestParams { wallet, third_party, .. } = build_test_nodes().await;
17251725

@@ -1769,7 +1769,7 @@ async fn test_edge_case_payment_instruction_parsing() {
17691769
}
17701770
}
17711771

1772-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
1772+
#[tokio::test(flavor = "multi_thread")]
17731773
async fn test_lsp_connectivity_fallback() {
17741774
let TestParams { wallet, lsp, bitcoind, third_party, .. } = build_test_nodes().await;
17751775

orange-sdk/tests/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub async fn wait_next_event(wallet: &orange_sdk::Wallet) -> orange_sdk::Event {
6464
fn create_bitcoind(uuid: Uuid) -> Bitcoind {
6565
let mut conf = Conf::default();
6666
conf.args.push("-txindex");
67-
conf.args.push("-rpcworkqueue=100");
67+
conf.args.push("-rpcworkqueue=200");
6868
conf.staticdir = Some(temp_dir().join(format!("orange-test-{uuid}/bitcoind")));
6969
let bitcoind = Bitcoind::with_conf(corepc_node::downloaded_exe_path().unwrap(), &conf)
7070
.unwrap_or_else(|_| panic!("Failed to start bitcoind for test {uuid}"));

0 commit comments

Comments
 (0)