From 7288e0435dd7de5311a097c36fb8d90552752f58 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Sat, 27 Apr 2024 11:34:05 -0500 Subject: [PATCH] Improvements for regtest testing --- mutiny-core/Cargo.toml | 8 ++++---- mutiny-core/src/lib.rs | 6 ++++++ mutiny-core/src/nodemanager.rs | 10 ++++++++-- mutiny-core/src/onchain.rs | 1 + 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/mutiny-core/Cargo.toml b/mutiny-core/Cargo.toml index c222ddad5..645a82d52 100644 --- a/mutiny-core/Cargo.toml +++ b/mutiny-core/Cargo.toml @@ -17,9 +17,9 @@ lnurl-rs = { version = "0.4.0", default-features = false, features = ["async", " cfg-if = "1.0.0" bip39 = { version = "2.0.0" } bitcoin = { version = "0.30.2", default-features = false, features = ["std", "serde", "secp-recovery", "rand"] } -bdk = { version = "1.0.0-alpha.5" } -bdk_esplora = { version = "0.7.0", default-features = false, features = ["std", "async-https"] } -bdk_chain = { version = "0.9.0", features = ["std"] } +bdk = { version = "=1.0.0-alpha.5" } +bdk_esplora = { version = "=0.7.0", default-features = false, features = ["std", "async-https"] } +bdk_chain = { version = "=0.9.0", features = ["std"] } bdk-macros = "0.6.0" getrandom = { version = "0.2" } itertools = "0.11.0" @@ -64,7 +64,7 @@ base64 = "0.13.0" pbkdf2 = "0.11" aes-gcm = "0.10.1" -log = "=0.4.18" +log = "0.4.18" futures = "0.3.25" thiserror = "1.0" anyhow = "1.0" diff --git a/mutiny-core/src/lib.rs b/mutiny-core/src/lib.rs index 54155f6b5..d0187601c 100644 --- a/mutiny-core/src/lib.rs +++ b/mutiny-core/src/lib.rs @@ -46,6 +46,12 @@ mod test_utils; pub use crate::gossip::{GOSSIP_SYNC_TIME_KEY, NETWORK_GRAPH_KEY, PROB_SCORER_KEY}; pub use crate::keymanager::generate_seed; pub use crate::ldkstorage::{CHANNEL_CLOSURE_PREFIX, CHANNEL_MANAGER_KEY, MONITORS_PREFIX_KEY}; +pub use bitcoin; +pub use fedimint_core; +pub use lightning; +pub use lightning_invoice; +pub use nostr_sdk; + use crate::storage::{ get_payment_hash_from_key, list_payment_info, persist_payment_info, update_nostr_contact_list, IndexItem, MutinyStorage, DEVICE_ID_KEY, EXPECTED_NETWORK_KEY, NEED_FULL_SYNC_KEY, diff --git a/mutiny-core/src/nodemanager.rs b/mutiny-core/src/nodemanager.rs index 767c8a408..dd891a2ae 100644 --- a/mutiny-core/src/nodemanager.rs +++ b/mutiny-core/src/nodemanager.rs @@ -579,6 +579,12 @@ impl NodeManager { /// Creates a background process that will sync the wallet with the blockchain. /// This will also update the fee estimates every 10 minutes. pub fn start_sync(nm: Arc>) { + // sync every second on regtest, this makes testing easier + let sync_interval_secs = match nm.network { + Network::Bitcoin | Network::Testnet | Network::Signet => 60, + Network::Regtest => 1, + net => unreachable!("Unknown network: {net}"), + }; utils::spawn(async move { let mut synced = false; loop { @@ -617,8 +623,8 @@ impl NodeManager { synced = true; } - // sleep for 1 minute, checking graceful shutdown check each 1s. - for _ in 0..60 { + // wait for next sync round, checking graceful shutdown check each second. + for _ in 0..sync_interval_secs { if nm.stop.load(Ordering::Relaxed) { return; } diff --git a/mutiny-core/src/onchain.rs b/mutiny-core/src/onchain.rs index 7cad3d3bc..5cee30977 100644 --- a/mutiny-core/src/onchain.rs +++ b/mutiny-core/src/onchain.rs @@ -524,6 +524,7 @@ impl OnChainWallet { .add_recipient(spk, amount) .enable_rbf() .fee_rate(fee_rate); + builder.finish()? }; log_debug!(self.logger, "Unsigned PSBT: {psbt}");