From: Jeffrey Czyz Date: Mon, 10 Feb 2020 20:01:35 +0000 (-0800) Subject: Add a test for Router's should_request_full_sync X-Git-Tag: v0.0.12~140^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=72de9cc178d712a00a326ee061cf2cc91d51c836;p=rust-lightning Add a test for Router's should_request_full_sync --- 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)); + } }