diff --git a/.github/workflows/postgres-integration.yml b/.github/workflows/postgres-integration.yml index d27e3123ea..29bd723d4c 100644 --- a/.github/workflows/postgres-integration.yml +++ b/.github/workflows/postgres-integration.yml @@ -35,9 +35,11 @@ jobs: - name: Check all features run: cargo check --all-features --tests --verbose --color always - name: Check sparse feature sets + env: + TEST_POSTGRES_URL: "host=localhost user=postgres password=postgres" run: | cargo check --no-default-features --features uniffi,chain-bitcoind,storage-postgres --verbose --color always - cargo test --lib --no-run --no-default-features --features chain-electrum,storage-postgres --verbose --color always + cargo test --lib --no-default-features --features chain-electrum,storage-postgres --verbose --color always cargo check --test integration_tests_postgres --no-default-features --features chain-electrum,storage-postgres --verbose --color always - name: Enable caching for bitcoind id: cache-bitcoind diff --git a/src/builder.rs b/src/builder.rs index 29759e93af..991bc573e1 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -2645,10 +2645,13 @@ pub(crate) fn sanitize_alias(alias_str: &str) -> Result { #[cfg(test)] mod tests { + #[cfg(any(feature = "chain-esplora", feature = "chain-electrum"))] use std::future::Future; use std::sync::Arc; + #[cfg(any(feature = "chain-esplora", feature = "chain-electrum"))] use lightning::io; + #[cfg(any(feature = "chain-esplora", feature = "chain-electrum"))] use lightning::util::persist::{ KVStore, PageToken, PaginatedKVStore, PaginatedListResponse, CHANNEL_MANAGER_PERSISTENCE_KEY, CHANNEL_MANAGER_PERSISTENCE_PRIMARY_NAMESPACE, @@ -2656,12 +2659,16 @@ mod tests { }; use super::{sanitize_alias, BuildError, NodeAlias, NodeBuilder}; + #[cfg(any(feature = "chain-esplora", feature = "chain-electrum"))] use crate::entropy::NodeEntropy; + #[cfg(any(feature = "chain-esplora", feature = "chain-electrum"))] use crate::io::test_utils::InMemoryStore; use crate::logger::Logger; + #[cfg(any(feature = "chain-esplora", feature = "chain-electrum"))] struct ChannelManagerReadFailingStore(InMemoryStore); + #[cfg(any(feature = "chain-esplora", feature = "chain-electrum"))] impl KVStore for ChannelManagerReadFailingStore { fn read( &self, primary_namespace: &str, secondary_namespace: &str, key: &str, @@ -2698,6 +2705,7 @@ mod tests { } } + #[cfg(any(feature = "chain-esplora", feature = "chain-electrum"))] impl PaginatedKVStore for ChannelManagerReadFailingStore { fn list_paginated( &self, primary_namespace: &str, secondary_namespace: &str, @@ -2712,9 +2720,17 @@ mod tests { } } + // Bitcoind fetches the chain tip during `build`, which fails before the channel manager read + // if no server is reachable. #[test] + #[cfg(any(feature = "chain-esplora", feature = "chain-electrum"))] fn channel_manager_read_failure_fails_build() { - let builder = NodeBuilder::new(); + // Esplora and Electrum don't connect during `build`, so no server is needed. + let mut builder = NodeBuilder::new(); + #[cfg(feature = "chain-esplora")] + builder.set_chain_source_esplora("http://127.0.0.1:3002".to_string(), None); + #[cfg(not(feature = "chain-esplora"))] + builder.set_chain_source_electrum("tcp://127.0.0.1:50001".to_string(), None); let logger = Arc::new(Logger::new_log_facade()); #[cfg(not(feature = "uniffi"))] let node_entropy = NodeEntropy::from_seed_bytes([42; 64]);