Crates.io | lnd |
lib.rs | lnd |
version | 0.1.5 |
source | src |
created_at | 2023-12-19 19:17:01.255421 |
updated_at | 2024-05-27 15:29:12.748581 |
description | Utility to run a regtest lnd process connected to a given bitcoind instance, useful in integration testing environment. |
homepage | |
repository | https://github.com/bennyhodl/lnd-test-util |
max_upload_size | |
id | 1074565 |
size | 34,398 |
Utility to run a regtest LND process connected to a given bitcoind instance, useful in integration testing environment.
// Create a bitcoind instance
let mut bitcoin_conf = bitcoind::Conf::default();
bitcoin_conf.enable_zmq = true;
let bitcoind = bitcoind::BitcoinD::with_conf("/usr/local/bin/bitcoind", &bitcoin_conf).unwrap();
// Pass the binary path, bitcoind, and ZMQ ports
let mut lnd = lnd::Lnd::new("<path to lnd>", &bitcoind);
let node = lnd.client.lightning().get_info(GetInfoRequest {}).await;
assert!(node.is_ok());
In your project Cargo.toml, activate the following features
lnd = { version = "*", features = ["download"] }
To use it:
let bitcoind_exe = bitcoind::downloaded_exe_path().expect("bitcoind version feature must be enabled");
let bitcoind = bitcoind::BitcoinD::new(bitcoind_exe).unwrap();
let lnd_exe = lnd::downloaded_exe_path().expect("lnd version feature must be enabled");
let lnd = lnd::Lnd::new(lnd_exe, bitcoind).unwrap();
When the LND_DOWNLOAD_ENDPOINT
/BITCOIND_DOWNLOAD_ENDPOINT
environment variables are set,
lnd
/bitcoind
will try to download the binaries from the given endpoints.
When you don't use the auto-download feature you have the following options:
lnd
executable in the PATH
lnd
executable via the LND_EXEC
env varif let Ok(exe_path) = lnd::exe_path() {
let lnd = lnd::Lnd::new(exe_path, &bitcoind).unwrap();
}
Thanks to these features every #[test]
could easily run isolated with its own environment