Skip to main content

spawn_lnd/
lib.rs

1#![warn(missing_docs)]
2
3//! Docker-backed LND and Bitcoin Core regtest clusters for Rust integration
4//! tests.
5//!
6//! The crate is library-first: integration tests should use the public API from
7//! here, while binaries and examples stay thin wrappers over the library.
8//!
9//! # Example
10//!
11//! ```no_run
12//! use spawn_lnd::SpawnLnd;
13//!
14//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
15//! let mut cluster = SpawnLnd::builder()
16//!     .nodes(["alice", "bob"])
17//!     .spawn()
18//!     .await?;
19//!
20//! cluster.fund_nodes(["alice", "bob"]).await?;
21//! let channel = cluster.open_channel("alice", "bob").await?;
22//! let mut clients = cluster.connect_nodes().await?;
23//!
24//! let alice_info = clients
25//!     .get_mut("alice")
26//!     .expect("alice client")
27//!     .lightning()
28//!     .get_info(lnd_grpc_rust::lnrpc::GetInfoRequest {})
29//!     .await?
30//!     .into_inner();
31//!
32//! assert!(alice_info.synced_to_chain);
33//! assert!(channel.from_channel.active);
34//!
35//! cluster.shutdown().await?;
36//! # Ok(())
37//! # }
38//! ```
39
40mod bitcoin;
41mod cluster;
42mod config;
43mod docker;
44mod lnd;
45
46pub use bitcoin::{
47    BITCOIND_P2P_PORT, BITCOIND_RPC_PORT, BitcoinCore, BitcoinCoreConfig, BitcoinCoreError,
48    BitcoinRpcAuth, BitcoinRpcClient, BitcoinRpcError, BlockInfo, BlockchainInfo, CreateWallet,
49    DEFAULT_BITCOIN_RPC_USER, DEFAULT_BITCOIN_WALLET_MATURITY_BLOCKS, DEFAULT_BITCOIN_WALLET_NAME,
50    LoadWallet, bitcoin_core_auth_hmac, bitcoin_core_rpcauth,
51};
52pub use cluster::{
53    ChannelReport, DEFAULT_CHANNEL_CAPACITY_SAT, DEFAULT_CHANNEL_CONFIRMATION_BLOCKS,
54    DEFAULT_FUNDING_AMOUNT_BTC, DEFAULT_FUNDING_CONFIRMATION_BLOCKS, FundingReport, PeerConnection,
55    SpawnError, SpawnedCluster, SpawnedNode,
56};
57pub use config::{
58    ConfigError, DEFAULT_BITCOIND_IMAGE, DEFAULT_LND_IMAGE, DEFAULT_NODE_ALIAS,
59    DEFAULT_NODES_PER_BITCOIND, DEFAULT_STARTUP_RETRY_ATTEMPTS, DEFAULT_STARTUP_RETRY_INTERVAL_MS,
60    ENV_BITCOIND_IMAGE, ENV_CLUSTER_SUBNET, ENV_KEEP_CONTAINERS, ENV_LND_IMAGE,
61    ENV_NODES_PER_BITCOIND, ENV_STARTUP_RETRY_ATTEMPTS, ENV_STARTUP_RETRY_INTERVAL_MS, NodeConfig,
62    RetryPolicy, SpawnLnd, SpawnLndBuilder, SpawnLndConfig,
63};
64pub use docker::{
65    CleanupFailure, CleanupReport, ContainerRole, ContainerSpec, DockerClient, DockerError,
66    ImageStatus, LABEL_CLUSTER, LABEL_MANAGED, LABEL_MANAGED_VALUE, LABEL_NODE, LABEL_ROLE,
67    ManagedNetwork, NetworkSpec, SpawnedContainer, StartupRollback, cluster_label_filters,
68    managed_container_labels, managed_label_filters, managed_network_labels, managed_network_name,
69};
70pub use lnd::{
71    DEFAULT_GENERATE_ADDRESS, LND_ADMIN_MACAROON_PATH, LND_GRPC_PORT, LND_P2P_PORT,
72    LND_TLS_CERT_PATH, LND_WALLET_PASSWORD, LndConfig, LndDaemon, LndError,
73};
74
75/// Current crate version as declared by Cargo.
76pub const VERSION: &str = env!("CARGO_PKG_VERSION");
77
78#[cfg(test)]
79mod tests {
80    use super::VERSION;
81
82    #[test]
83    fn exposes_crate_version() {
84        assert_eq!(VERSION, env!("CARGO_PKG_VERSION"));
85    }
86}