Merge branch 'main' of gitlab.hackers.town:veilid/veilid into json-rpc

This commit is contained in:
John Smith
2023-06-16 13:13:51 -04:00
18 changed files with 787 additions and 123 deletions

View File

@@ -1 +1 @@
pub mod test_serialize;
pub mod test_serialize_routing_table;

View File

@@ -1,5 +1,7 @@
use crate::*;
const SERIALIZED_PEERINFO: &str = r###"{"node_ids":["FAKE:eFOfgm_FNZBsTRi7KAESNwYFAUGgX2uDrTRWAL8ucjM"],"signed_node_info":{"Direct":{"node_info":{"network_class":"InboundCapable","outbound_protocols":1,"address_types":3,"envelope_support":[0],"crypto_support":[[86,76,68,48]],"dial_info_detail_list":[{"class":"Direct","dial_info":{"kind":"UDP","socket_address":{"address":{"IPV4":"1.2.3.4"},"port":5150}}},{"class":"Direct","dial_info":{"kind":"UDP","socket_address":{"address":{"IPV6":"bad:cafe::1"},"port":5150}}},{"class":"Direct","dial_info":{"kind":"TCP","socket_address":{"address":{"IPV4":"5.6.7.8"},"port":5150}}},{"class":"Direct","dial_info":{"kind":"TCP","socket_address":{"address":{"IPV6":"bad:cafe::1"},"port":5150}}},{"class":"Direct","dial_info":{"kind":"WS","socket_address":{"address":{"IPV4":"9.10.11.12"},"port":5150},"request":"bootstrap-1.dev.veilid.net:5150/ws"}},{"class":"Direct","dial_info":{"kind":"WS","socket_address":{"address":{"IPV6":"bad:cafe::1"},"port":5150},"request":"bootstrap-1.dev.veilid.net:5150/ws"}}]},"timestamp":1685058646770389,"signatures":[]}}}"###;
fn fake_routing_table() -> routing_table::RoutingTable {
let veilid_config = VeilidConfig::new();
#[cfg(feature = "unstable-blockstore")]
@@ -81,6 +83,15 @@ pub async fn test_routingtable_buckets_round_trip() {
copy.terminate().await;
}
pub async fn test_round_trip_peerinfo() {
let pi: routing_table::PeerInfo = deserialize_json(SERIALIZED_PEERINFO).unwrap();
let back = serialize_json(pi);
assert_eq!(SERIALIZED_PEERINFO, back);
}
pub async fn test_all() {
test_routingtable_buckets_round_trip().await;
test_round_trip_peerinfo().await;
}