Skip to content

Commit

Permalink
Remove local file access and networking tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arik-so committed Feb 16, 2022
1 parent fb6d8d1 commit f8b6d45
Showing 1 changed file with 0 additions and 85 deletions.
85 changes: 0 additions & 85 deletions lightning-graph-sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,88 +51,3 @@ where
let mut file = File::open(sync_path)?;
processing::read_network_graph(&network_graph, &mut file, &chain_source)
}

#[cfg(test)]
mod tests {
use std::time::Instant;
use bitcoin::blockdata::constants::genesis_block;
use bitcoin::Network;

use lightning::routing::network_graph::NetworkGraph;

use crate::error::GraphSyncError;
use crate::{sync_network_graph_with_file_path, sync_network_graph_with_url};



#[tokio::test]
async fn test_http_request() {
let block_hash = genesis_block(Network::Bitcoin).block_hash();
let network_graph = NetworkGraph::new(block_hash);

let chain_source: Option<Box<dyn lightning::chain::Access>> = None;

let sync_result = sync_network_graph_with_url(
&network_graph,
"localhost",
3000,
"delta/500",
&chain_source,
)
.await;

if !sync_result.is_ok() {
let error_string = match sync_result.as_ref().unwrap_err() {
GraphSyncError::IOError(error) => error.to_string(),
GraphSyncError::DecodeError(error) => error.to_string(),
GraphSyncError::LightningError(error) => (&error.err).to_string(),
GraphSyncError::ProcessingError(error) => error.to_string(),
};
println!("Error: {}", error_string);
}

assert!(sync_result.is_ok())
}

#[test]
fn test_file_load() {
let block_hash = genesis_block(Network::Bitcoin).block_hash();
let network_graph = NetworkGraph::new(block_hash);

let chain_source: Option<Box<dyn lightning::chain::Access>> = None;

let start = Instant::now();

// let path = "/Users/arik/Developer/rust-lightning/lightning-graph-sync/res/full_compressed.lngossip";
// let path = "/Users/arik/Developer/rust-lightning/lightning-graph-sync/res/full_incremental.lngossip";
// let path = "/Users/arik/Developer/rust-lightning/lightning-graph-sync/res/one_day_incremental.lngossip";
// let path = "/Users/arik/Developer/rust-lightning/lightning-graph-sync/res/one_day.lngossip";
// let path = "/Users/arik/Developer/rust-lightning/lightning-graph-sync/res/one_week.lngossip";

// initialize full graph
let path = "/Users/arik/Developer/rust-lightning/lightning-graph-sync/res/test_starting_reference.lngossip";
let initialization_result = sync_network_graph_with_file_path(
&network_graph,
path,
&chain_source,
);
if initialization_result.is_err() {
panic!("initialization failed");
}

let path = "/Users/arik/Developer/rust-lightning/lightning-graph-sync/res/test_incremental_delta.lngossip";
let sync_result = sync_network_graph_with_file_path(
&network_graph,
path,
&chain_source,
);
if sync_result.is_err() {
panic!("sync failed");
}

let duration = start.elapsed();
let elapsed_time = format!("{:?}", duration);

println!("sync result: {}, time: {}", sync_result.is_ok(), elapsed_time);
}
}

0 comments on commit f8b6d45

Please sign in to comment.