From 72de9cc178d712a00a326ee061cf2cc91d51c836 Mon Sep 17 00:00:00 2001 From: Jeffrey Czyz Date: Mon, 10 Feb 2020 12:01:35 -0800 Subject: [PATCH] Add a test for Router's should_request_full_sync --- lightning/src/ln/router.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lightning/src/ln/router.rs b/lightning/src/ln/router.rs index d772ebc1a..36e68462c 100644 --- a/lightning/src/ln/router.rs +++ b/lightning/src/ln/router.rs @@ -1051,7 +1051,7 @@ mod tests { use ln::channelmanager; use ln::router::{Router,NodeInfo,NetworkMap,ChannelInfo,DirectionalChannelInfo,RouteHint}; use ln::features::{ChannelFeatures, InitFeatures, NodeFeatures}; - use ln::msgs::{LightningError, ErrorAction}; + use ln::msgs::{ErrorAction, LightningError, RoutingMessageHandler}; use util::test_utils; use util::test_utils::TestVecWriter; use util::logger::Logger; @@ -1845,4 +1845,17 @@ mod tests { assert!(::read(&mut ::std::io::Cursor::new(&w.0)).unwrap() == *network); } } + + #[test] + fn request_full_sync_finite_times() { + let (secp_ctx, _, router) = create_router(); + let node_id = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0202020202020202020202020202020202020202020202020202020202020202").unwrap()[..]).unwrap()); + + assert!(router.should_request_full_sync(&node_id)); + assert!(router.should_request_full_sync(&node_id)); + assert!(router.should_request_full_sync(&node_id)); + assert!(router.should_request_full_sync(&node_id)); + assert!(router.should_request_full_sync(&node_id)); + assert!(!router.should_request_full_sync(&node_id)); + } } -- 2.39.5