-static BITCOIND: OnceCell<BitcoinD> = OnceCell::new();
-static ELECTRSD: OnceCell<ElectrsD> = OnceCell::new();
-static PREMINE: OnceCell<()> = OnceCell::new();
-static MINER_LOCK: OnceCell<Mutex<()>> = OnceCell::new();
-
-fn get_bitcoind() -> &'static BitcoinD {
- BITCOIND.get_or_init(|| {
- let bitcoind_exe =
- env::var("BITCOIND_EXE").ok().or_else(|| bitcoind::downloaded_exe_path().ok()).expect(
- "you need to provide an env var BITCOIND_EXE or specify a bitcoind version feature",
- );
- let mut conf = bitcoind::Conf::default();
- conf.network = "regtest";
- let bitcoind = BitcoinD::with_conf(bitcoind_exe, &conf).unwrap();
- std::thread::sleep(Duration::from_secs(1));
- bitcoind
- })
-}
-
-fn get_electrsd() -> &'static ElectrsD {
- ELECTRSD.get_or_init(|| {
- let bitcoind = get_bitcoind();
- let electrs_exe =
- env::var("ELECTRS_EXE").ok().or_else(electrsd::downloaded_exe_path).expect(
- "you need to provide env var ELECTRS_EXE or specify an electrsd version feature",
- );
- let mut conf = electrsd::Conf::default();
- conf.http_enabled = true;
- conf.network = "regtest";
- let electrsd = ElectrsD::with_conf(electrs_exe, &bitcoind, &conf).unwrap();
- std::thread::sleep(Duration::from_secs(1));
- electrsd
- })
+pub fn setup_bitcoind_and_electrsd() -> (BitcoinD, ElectrsD) {
+ let bitcoind_exe =
+ env::var("BITCOIND_EXE").ok().or_else(|| bitcoind::downloaded_exe_path().ok()).expect(
+ "you need to provide an env var BITCOIND_EXE or specify a bitcoind version feature",
+ );
+ let mut bitcoind_conf = bitcoind::Conf::default();
+ bitcoind_conf.network = "regtest";
+ let bitcoind = BitcoinD::with_conf(bitcoind_exe, &bitcoind_conf).unwrap();
+
+ let electrs_exe = env::var("ELECTRS_EXE")
+ .ok()
+ .or_else(electrsd::downloaded_exe_path)
+ .expect("you need to provide env var ELECTRS_EXE or specify an electrsd version feature");
+ let mut electrsd_conf = electrsd::Conf::default();
+ electrsd_conf.http_enabled = true;
+ electrsd_conf.network = "regtest";
+ let electrsd = ElectrsD::with_conf(electrs_exe, &bitcoind, &electrsd_conf).unwrap();
+ (bitcoind, electrsd)