1#![deny(clippy::pedantic)]
2#![allow(clippy::cast_possible_truncation)]
3#![allow(clippy::cast_possible_wrap)]
4#![allow(clippy::cast_precision_loss)]
5#![allow(clippy::cast_sign_loss)]
6#![allow(clippy::doc_markdown)]
7#![allow(clippy::explicit_deref_methods)]
8#![allow(clippy::implicit_hasher)]
9#![allow(clippy::items_after_statements)]
10#![allow(clippy::large_futures)]
11#![allow(clippy::missing_errors_doc)]
12#![allow(clippy::missing_panics_doc)]
13#![allow(clippy::module_name_repetitions)]
14#![allow(clippy::must_use_candidate)]
15#![allow(clippy::return_self_not_must_use)]
16#![allow(clippy::too_many_lines)]
17
18use std::ffi;
19
20use clap::Parser as _;
21use cli::cleanup_on_exit;
22use devfed::DevJitFed;
23pub use devfed::{DevFed, dev_fed};
24pub use external::{
25 ExternalDaemons, LightningNode, Lightningd, LightningdProcessHandle, Lnd, external_daemons,
26};
27use futures::Future;
28pub use gatewayd::Gatewayd;
29use tests::log_binary_versions;
30use util::ProcessManager;
31
32pub mod cli;
33pub mod devfed;
34pub mod envs;
35pub mod external;
36pub mod faucet;
37pub mod federation;
38pub mod gatewayd;
39pub mod tests;
40pub mod util;
41pub mod vars;
42pub mod version_constants;
43
44#[bon::builder]
45pub async fn run_devfed_test<F, FF>(
46 #[builder(finish_fn)] f: F,
47 num_feds: Option<usize>,
48) -> anyhow::Result<()>
49where
50 F: FnOnce(DevJitFed, ProcessManager) -> FF,
51 FF: Future<Output = anyhow::Result<()>>,
52{
53 let mut args = cli::CommonArgs::parse_from::<_, ffi::OsString>(vec![]);
54
55 if let Some(num_feds) = num_feds {
56 args.num_feds = num_feds;
57 }
58
59 let (process_mgr, task_group) = cli::setup(args).await?;
60 log_binary_versions().await?;
61 let dev_fed = devfed::DevJitFed::new(&process_mgr, false)?;
62 let _ = dev_fed.finalize(&process_mgr).await;
66 let res = cleanup_on_exit(f(dev_fed.clone(), process_mgr.clone()), task_group).await;
67 dev_fed.fast_terminate().await;
68 res?;
69
70 Ok(())
71}