]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Add a test for Router's should_request_full_sync
authorJeffrey Czyz <jkczyz@gmail.com>
Mon, 10 Feb 2020 20:01:35 +0000 (12:01 -0800)
committerJeffrey Czyz <jkczyz@gmail.com>
Mon, 10 Feb 2020 20:01:35 +0000 (12:01 -0800)
lightning/src/ln/router.rs

index d772ebc1ac731f59bc0179948e9832b7dca440cf..36e68462c392d9d8983535ef0faa0e77c7040b2f 100644 (file)
@@ -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!(<NetworkMap>::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));
+       }
 }