|
@@ -136,4 +136,60 @@ router-digest F30B38390C375E1EE74BFED844177804442569E0"#;
|
|
assert!(db.contains_key(bridge_to_test).unwrap());
|
|
assert!(db.contains_key(bridge_to_test).unwrap());
|
|
let _bridge_info: BridgeInfo =
|
|
let _bridge_info: BridgeInfo =
|
|
bincode::deserialize(&db.get(bridge_to_test).unwrap().unwrap()).unwrap();
|
|
bincode::deserialize(&db.get(bridge_to_test).unwrap().unwrap()).unwrap();
|
|
|
|
+
|
|
|
|
+ // Add another day's data, with no Russia data this time
|
|
|
|
+ let extra_info_str_2 = r#"@type bridge-extra-info 1.3
|
|
|
|
+extra-info ElephantBridgeDE2 72E12B89136B45BBC81D1EF0AC7DDDBB91B148DB
|
|
|
|
+bridge-stats-end 2024-04-06 06:51:44 (86400 s)
|
|
|
|
+bridge-ips us=32,??=8,au=8,br=8,by=8,cn=8,de=8,eg=8,eu=8,gb=8,ge=8,hr=8,ie=8,ir=8,kp=8,lt=8,mt=8,nl=8,pl=8,ro=8,sg=8,tn=8,tr=8,vn=8"#;
|
|
|
|
+
|
|
|
|
+ let extra_info_set_2 = ExtraInfo::parse_file(&extra_info_str_2);
|
|
|
|
+
|
|
|
|
+ // Add our extra-info to the server's records
|
|
|
|
+ {
|
|
|
|
+ use hyper::{Body, Client, Method, Request};
|
|
|
|
+ let client = Client::new();
|
|
|
|
+ let req = Request::builder()
|
|
|
|
+ .method(Method::POST)
|
|
|
|
+ .uri("http://localhost:8004/add".parse::<hyper::Uri>().unwrap())
|
|
|
|
+ .body(Body::from(
|
|
|
|
+ serde_json::to_string(&extra_info_set_2).unwrap(),
|
|
|
|
+ ))
|
|
|
|
+ .unwrap();
|
|
|
|
+ client.request(req).await.unwrap();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Update extra-infos (add new record)
|
|
|
|
+ update_extra_infos(&db, "http://localhost:8004/")
|
|
|
|
+ .await
|
|
|
|
+ .unwrap();
|
|
|
|
+
|
|
|
|
+ let bridge_info: BridgeInfo =
|
|
|
|
+ bincode::deserialize(&db.get(bridge_to_test).unwrap().unwrap()).unwrap();
|
|
|
|
+
|
|
|
|
+ // We should not have any data on Canada
|
|
|
|
+ assert!(!bridge_info.info_by_country.contains_key("ca"));
|
|
|
|
+
|
|
|
|
+ // We should have data on Russia
|
|
|
|
+ let russia_info = bridge_info.info_by_country.get("ru").unwrap();
|
|
|
|
+ assert_eq!(
|
|
|
|
+ *russia_info
|
|
|
|
+ .info_by_day
|
|
|
|
+ .get(&2460406)
|
|
|
|
+ .unwrap()
|
|
|
|
+ .get(&BridgeInfoType::BridgeIps)
|
|
|
|
+ .unwrap(),
|
|
|
|
+ 40
|
|
|
|
+ );
|
|
|
|
+ // Because we have historical data on Russia, but it wasn't listed
|
|
|
|
+ // today, we should see 0
|
|
|
|
+ assert_eq!(
|
|
|
|
+ *russia_info
|
|
|
|
+ .info_by_day
|
|
|
|
+ .get(&2460407)
|
|
|
|
+ .unwrap()
|
|
|
|
+ .get(&BridgeInfoType::BridgeIps)
|
|
|
|
+ .unwrap(),
|
|
|
|
+ 0
|
|
|
|
+ );
|
|
}
|
|
}
|