Skip to content

Commit

Permalink
Improvements for regtest testing
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed May 7, 2024
1 parent 68d545d commit c360af2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 4 additions & 4 deletions mutiny-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions mutiny-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::utils::spawn;
use crate::{auth::MutinyAuthClient, hermes::HermesClient, logging::MutinyLogger};
use crate::{blindauth::BlindAuthClient, cashu::CashuHttpClient};
Expand Down
10 changes: 8 additions & 2 deletions mutiny-core/src/nodemanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,12 @@ impl<S: MutinyStorage> NodeManager<S> {
/// 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<NodeManager<S>>) {
// 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 {
Expand Down Expand Up @@ -617,8 +623,8 @@ impl<S: MutinyStorage> NodeManager<S> {
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;
}
Expand Down

0 comments on commit c360af2

Please sign in to comment.