Skip to content

Commit

Permalink
Add method to use Vss with FixedHeader Auth.
Browse files Browse the repository at this point in the history
  • Loading branch information
G8XSU committed Oct 15, 2024
1 parent e521be4 commit d33d4ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
13 changes: 12 additions & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Mutex, RwLock};
use std::time::SystemTime;
#[cfg(any(vss, vss_test))]
use vss_client::headers::{LnurlAuthToJwtProvider, VssHeaderProvider};
use vss_client::headers::{FixedHeaders, LnurlAuthToJwtProvider, VssHeaderProvider};

#[derive(Debug, Clone)]
enum ChainDataSourceConfig {
Expand Down Expand Up @@ -401,6 +401,17 @@ impl NodeBuilder {
self.build_with_vss_store_and_header_provider(vss_url, store_id, header_provider)
}

/// Builds a [`Node`] instance with a [`VssStore`] backend and according to the options
/// previously configured. Uses only FixedHeaders as default method for authentication/authorization.
#[cfg(any(vss, vss_test))]
pub fn build_with_vss_store_with_fixed_headers(
&self, vss_url: String, store_id: String, fixed_headers: HashMap<String, String>,
) -> Result<Node, BuildError> {
let header_provider = Arc::new(FixedHeaders::new(fixed_headers));

self.build_with_vss_store_and_header_provider(vss_url, store_id, header_provider)
}

/// Builds a [`Node`] instance with a [`VssStore`] backend and according to the options
/// previously configured. Give `header_provider` is used to attach headers to every request made
/// to [VSS](https://github.com/lightningdevkit/vss-server/blob/main/README.md) backend.
Expand Down
8 changes: 4 additions & 4 deletions tests/integration_tests_vss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ fn channel_full_cycle_with_vss_store() {
builder_a.set_chain_source_esplora(esplora_url.clone(), None);
let vss_base_url = std::env::var("TEST_VSS_BASE_URL").unwrap();
let node_a = builder_a
.build_with_vss_store_and_header_provider(
.build_with_vss_store_with_fixed_headers(
vss_base_url.clone(),
"node_1_store".to_string(),
Arc::new(FixedHeaders::new(HashMap::new())),
HashMap::new(),
)
.unwrap();
node_a.start().unwrap();
Expand All @@ -39,10 +39,10 @@ fn channel_full_cycle_with_vss_store() {
let node_b = builder_b.build_with_vss_store(vss_base_url, "node_2_store".to_string()).unwrap();
builder_b.set_esplora_server(esplora_url);
let node_b = builder_b
.build_with_vss_store_and_header_provider(
.build_with_vss_store_with_fixed_headers(
vss_base_url,
"node_2_store".to_string(),
Arc::new(FixedHeaders::new(HashMap::new())),
HashMap::new(),
)
.unwrap();
node_b.start().unwrap();
Expand Down

0 comments on commit d33d4ed

Please sign in to comment.