Skip to content

Commit 945027b

Browse files
committed
Fixup changes
1 parent 4788251 commit 945027b

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

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

559-
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
559+
#[tokio::test(flavor = "multi_thread")]
560560
async fn test_pay_lightning_from_self_custody() {
561561
run_test_pay_lightning_from_self_custody(false).await;
562562
run_test_pay_lightning_from_self_custody(true).await;
@@ -644,13 +644,13 @@ async fn run_test_pay_bolt12_from_self_custody(amountless: bool) {
644644
&& p.amount_msat == Some(amount.milli_sats())));
645645
}
646646

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

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

@@ -753,7 +753,7 @@ async fn test_pay_onchain_from_self_custody() {
753753
.await;
754754
}
755755

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

@@ -794,7 +794,7 @@ async fn test_force_close_handling() {
794794
assert!(!rebalancing);
795795
}
796796

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

@@ -828,7 +828,7 @@ async fn test_close_all_channels() {
828828
assert!(!rebalancing);
829829
}
830830

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

@@ -904,7 +904,7 @@ async fn test_threshold_boundary_trusted_balance_limit() {
904904
);
905905
}
906906

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

@@ -977,7 +977,7 @@ async fn test_threshold_boundary_rebalance_min() {
977977
);
978978
}
979979

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

@@ -1037,7 +1037,7 @@ async fn test_threshold_boundary_onchain_receive_threshold() {
10371037
}
10381038
}
10391039

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

@@ -1095,7 +1095,7 @@ async fn test_threshold_combinations_and_edge_cases() {
10951095
}
10961096
}
10971097

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

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

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

@@ -1185,7 +1185,7 @@ async fn test_payment_with_expired_invoice() {
11851185
assert!(matches!(parse_result.unwrap_err(), ParseError::InstructionsExpired));
11861186
}
11871187

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

@@ -1238,7 +1238,7 @@ async fn test_payment_network_mismatch() {
12381238
);
12391239
}
12401240

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

@@ -1410,7 +1410,7 @@ async fn test_concurrent_payments() {
14101410
);
14111411
}
14121412

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

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

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

@@ -1516,7 +1516,7 @@ async fn test_balance_consistency_under_load() {
15161516
}
15171517
}
15181518

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

@@ -1593,7 +1593,7 @@ async fn test_invalid_tunables_relationships() {
15931593
}
15941594
}
15951595

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

@@ -1658,7 +1658,7 @@ async fn test_extreme_amount_handling() {
16581658
// On-chain address depends on threshold, not msat precision
16591659
}
16601660

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

@@ -1721,7 +1721,7 @@ async fn test_wallet_configuration_validation() {
17211721
);
17221722
}
17231723

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

@@ -1771,7 +1771,7 @@ async fn test_edge_case_payment_instruction_parsing() {
17711771
}
17721772
}
17731773

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

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)