adds get_node_id for api

This commit is contained in:
carvilsi 2025-03-19 04:11:04 +01:00
parent e9fe5928dc
commit a4777fc551
2 changed files with 19 additions and 0 deletions

View File

@ -192,6 +192,20 @@ pub async fn test_attach_detach_multiple() {
}
}
pub async fn test_get_node_id() {
trace!("test get node id");
let (update_callback, config_callback) = setup_veilid_core();
let api = api_startup(update_callback, config_callback)
.await
.expect("startup failed");
api.attach().await.unwrap();
sleep(5000).await;
assert_eq!(api.get_node_id().unwrap(), api.config().unwrap().get().network.routing_table.node_id);
api.detach().await.unwrap();
sleep(2000).await;
api.shutdown().await;
}
pub async fn test_all() {
test_startup_shutdown().await;
test_startup_shutdown_from_config().await;
@ -199,4 +213,5 @@ pub async fn test_all() {
test_startup_shutdown_multiple().await;
test_startup_shutdown_from_config_multiple().await;
test_attach_detach_multiple().await;
test_get_node_id().await;
}

View File

@ -136,6 +136,10 @@ impl VeilidAPI {
.ok_or(VeilidAPIError::NotInitialized)
}
pub fn get_node_id(&self) -> VeilidAPIResult<CryptoTypedGroup<CryptoKey>> {
Ok(self.config()?.get().network.routing_table.node_id.clone())
}
////////////////////////////////////////////////////////////////
// Internal Accessors