Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/postgres-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 17 additions & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2645,23 +2645,30 @@ pub(crate) fn sanitize_alias(alias_str: &str) -> Result<NodeAlias, BuildError> {

#[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,
CHANNEL_MANAGER_PERSISTENCE_SECONDARY_NAMESPACE,
};

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,
Expand Down Expand Up @@ -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,
Expand All @@ -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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]);
Expand Down
Loading