From ee1472f3ae53211b0862ad06553f4842c82c3af5 Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Sat, 4 Nov 2023 19:52:29 -0400 Subject: [PATCH] fix #337 --- .../src/routing_table/route_spec_store/mod.rs | 6 + .../route_spec_store/route_set_spec_detail.rs | 7 + .../route_spec_store_cache.rs | 6 +- .../tasks/private_route_management.rs | 1 + veilid-core/src/veilid_api/api.rs | 1 + veilid-core/src/veilid_api/debug.rs | 1 + veilid-core/tests/web.rs | 132 +++++++++--------- 7 files changed, 86 insertions(+), 68 deletions(-) diff --git a/veilid-core/src/routing_table/route_spec_store/mod.rs b/veilid-core/src/routing_table/route_spec_store/mod.rs index 0ddc59c3..11410b74 100644 --- a/veilid-core/src/routing_table/route_spec_store/mod.rs +++ b/veilid-core/src/routing_table/route_spec_store/mod.rs @@ -167,6 +167,7 @@ impl RouteSpecStore { /// Returns other errors on failure /// Returns Ok(route id string) on success #[instrument(level = "trace", skip(self), ret, err(level=Level::TRACE))] + #[allow(clippy::too_many_arguments)] pub fn allocate_route( &self, crypto_kinds: &[CryptoKind], @@ -175,6 +176,7 @@ impl RouteSpecStore { hop_count: usize, directions: DirectionSet, avoid_nodes: &[TypedKey], + automatic: bool, ) -> VeilidAPIResult { let inner = &mut *self.inner.lock(); let routing_table = self.unlocked_inner.routing_table.clone(); @@ -189,6 +191,7 @@ impl RouteSpecStore { hop_count, directions, avoid_nodes, + automatic, ) } @@ -204,6 +207,7 @@ impl RouteSpecStore { hop_count: usize, directions: DirectionSet, avoid_nodes: &[TypedKey], + automatic: bool, ) -> VeilidAPIResult { use core::cmp::Ordering; @@ -576,6 +580,7 @@ impl RouteSpecStore { directions, stability, can_do_sequenced, + automatic, ); // make id @@ -1255,6 +1260,7 @@ impl RouteSpecStore { safety_spec.hop_count, direction, avoid_nodes, + true, )? }; diff --git a/veilid-core/src/routing_table/route_spec_store/route_set_spec_detail.rs b/veilid-core/src/routing_table/route_spec_store/route_set_spec_detail.rs index bedf4efc..f6d08eef 100644 --- a/veilid-core/src/routing_table/route_spec_store/route_set_spec_detail.rs +++ b/veilid-core/src/routing_table/route_spec_store/route_set_spec_detail.rs @@ -29,6 +29,8 @@ pub(crate) struct RouteSetSpecDetail { can_do_sequenced: bool, /// Stats stats: RouteStats, + /// Automatically allocated route vs manually allocated route + automatic: bool, } impl RouteSetSpecDetail { @@ -39,6 +41,7 @@ impl RouteSetSpecDetail { directions: DirectionSet, stability: Stability, can_do_sequenced: bool, + automatic: bool, ) -> Self { Self { route_set, @@ -48,6 +51,7 @@ impl RouteSetSpecDetail { stability, can_do_sequenced, stats: RouteStats::new(cur_ts), + automatic, } } pub fn get_route_by_key(&self, key: &PublicKey) -> Option<&RouteSpecDetail> { @@ -115,6 +119,9 @@ impl RouteSetSpecDetail { } false } + pub fn is_automatic(&self) -> bool { + self.automatic + } /// Generate a key for the cache that can be used to uniquely identify this route's contents pub fn make_cache_key(&self, rti: &RoutingTableInner) -> Vec { diff --git a/veilid-core/src/routing_table/route_spec_store/route_spec_store_cache.rs b/veilid-core/src/routing_table/route_spec_store/route_spec_store_cache.rs index 6f303864..673ce6d3 100644 --- a/veilid-core/src/routing_table/route_spec_store/route_spec_store_cache.rs +++ b/veilid-core/src/routing_table/route_spec_store/route_spec_store_cache.rs @@ -110,8 +110,10 @@ impl RouteSpecStoreCache { self.invalidate_compiled_route_cache(pk); } - // Mark it as dead for the update - self.dead_routes.push(id); + // Mark it as dead for the update if it wasn't automatically created + if !rssd.is_automatic() { + self.dead_routes.push(id); + } true } diff --git a/veilid-core/src/routing_table/tasks/private_route_management.rs b/veilid-core/src/routing_table/tasks/private_route_management.rs index 8fbb36d2..467a7856 100644 --- a/veilid-core/src/routing_table/tasks/private_route_management.rs +++ b/veilid-core/src/routing_table/tasks/private_route_management.rs @@ -219,6 +219,7 @@ impl RoutingTable { default_route_hop_count, DirectionSet::all(), &[], + true, ) { Err(VeilidAPIError::TryAgain { message }) => { log_rtab!(debug "Route allocation unavailable: {}", message); diff --git a/veilid-core/src/veilid_api/api.rs b/veilid-core/src/veilid_api/api.rs index 496dcf66..8e5b432f 100644 --- a/veilid-core/src/veilid_api/api.rs +++ b/veilid-core/src/veilid_api/api.rs @@ -270,6 +270,7 @@ impl VeilidAPI { default_route_hop_count, Direction::Inbound.into(), &[], + false, )?; if !rss.test_route(route_id).await? { rss.release_route(route_id); diff --git a/veilid-core/src/veilid_api/debug.rs b/veilid-core/src/veilid_api/debug.rs index 730870b8..e1e0cdea 100644 --- a/veilid-core/src/veilid_api/debug.rs +++ b/veilid-core/src/veilid_api/debug.rs @@ -1095,6 +1095,7 @@ impl VeilidAPI { hop_count, directions, &[], + false, ) { Ok(v) => v.to_string(), Err(e) => { diff --git a/veilid-core/tests/web.rs b/veilid-core/tests/web.rs index ea6daa49..a3cc5e5a 100644 --- a/veilid-core/tests/web.rs +++ b/veilid-core/tests/web.rs @@ -27,82 +27,82 @@ pub fn setup() -> () { }); } -// #[wasm_bindgen_test] -// #[serial] -// async fn wasm_test_types() { -// setup(); -// test_types::test_all().await; -// } +#[wasm_bindgen_test] +#[serial] +async fn wasm_test_types() { + setup(); + test_types::test_all().await; +} -// #[wasm_bindgen_test] -// #[serial] -// async fn wasm_test_veilid_core() { -// setup(); -// test_veilid_core::test_all().await; -// } +#[wasm_bindgen_test] +#[serial] +async fn wasm_test_veilid_core() { + setup(); + test_veilid_core::test_all().await; +} -// #[wasm_bindgen_test] -// #[serial] -// async fn wasm_test_veilid_config() { -// setup(); -// test_veilid_config::test_all().await; -// } +#[wasm_bindgen_test] +#[serial] +async fn wasm_test_veilid_config() { + setup(); + test_veilid_config::test_all().await; +} -// #[wasm_bindgen_test] -// #[serial] -// async fn wasm_test_connection_table() { -// setup(); -// test_connection_table::test_all().await; -// } +#[wasm_bindgen_test] +#[serial] +async fn wasm_test_connection_table() { + setup(); + test_connection_table::test_all().await; +} -// #[wasm_bindgen_test] -// #[serial] -// async fn wasm_test_signed_node_info() { -// setup(); -// test_signed_node_info::test_all().await; -// } +#[wasm_bindgen_test] +#[serial] +async fn wasm_test_signed_node_info() { + setup(); + test_signed_node_info::test_all().await; +} -// #[wasm_bindgen_test] -// #[serial] -// async fn wasm_test_table_store() { -// setup(); -// test_table_store::test_all().await; -// } +#[wasm_bindgen_test] +#[serial] +async fn wasm_test_table_store() { + setup(); + test_table_store::test_all().await; +} -// #[wasm_bindgen_test] -// #[serial] -// async fn wasm_test_protected_store() { -// setup(); -// test_protected_store::test_all().await; -// } +#[wasm_bindgen_test] +#[serial] +async fn wasm_test_protected_store() { + setup(); + test_protected_store::test_all().await; +} -// #[wasm_bindgen_test] -// #[serial] -// async fn wasm_test_crypto() { -// setup(); -// test_crypto::test_all().await; -// } +#[wasm_bindgen_test] +#[serial] +async fn wasm_test_crypto() { + setup(); + test_crypto::test_all().await; +} -// #[wasm_bindgen_test] -// #[serial] -// async fn wasm_test_envelope_receipt() { -// setup(); -// test_envelope_receipt::test_all().await; -// } +#[wasm_bindgen_test] +#[serial] +async fn wasm_test_envelope_receipt() { + setup(); + test_envelope_receipt::test_all().await; +} -// #[wasm_bindgen_test] -// #[serial] -// async fn wasm_test_serialize_json() { -// setup(); -// test_serialize_json::test_all().await; -// } +#[wasm_bindgen_test] +#[serial] +async fn wasm_test_serialize_json() { + setup(); + test_serialize_json::test_all().await; +} -// #[wasm_bindgen_test] -// #[serial] -// async fn wasm_test_serialize_routing_table() { -// setup(); -// test_serialize_routing_table::test_all().await; -// } +#[wasm_bindgen_test] +#[serial] +async fn wasm_test_serialize_routing_table() { + setup(); + test_serialize_routing_table::test_all().await; +} #[wasm_bindgen_test] #[serial]