mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-04-16 22:13:14 -04:00
Merge branch 'api-get-node-id' into 'main'
Api get node Id See merge request veilid/veilid!380
This commit is contained in:
commit
d766550540
@ -67,7 +67,7 @@ async fn main() {
|
||||
};
|
||||
|
||||
let veilid = veilid_core::api_startup_config(update_callback, config).await.unwrap();
|
||||
println!("Node ID: {}", veilid.config().unwrap().get().network.routing_table.node_id);
|
||||
println!("Node ID: {}", veilid.get_node_id().unwrap());
|
||||
veilid.attach().await.unwrap();
|
||||
// Until CTRL+C is pressed, keep running
|
||||
tokio::signal::ctrl_c().await.unwrap();
|
||||
|
@ -66,7 +66,7 @@ async fn main() {
|
||||
};
|
||||
|
||||
let veilid = veilid_core::api_startup_config(update_callback, config).await.unwrap();
|
||||
println!("Node ID: {}", veilid.config().unwrap().get().network.routing_table.node_id);
|
||||
println!("Node ID: {}", veilid.get_node_id().unwrap());
|
||||
veilid.attach().await.unwrap();
|
||||
// Until CTRL+C is pressed, keep running
|
||||
tokio::signal::ctrl_c().await.unwrap();
|
||||
|
@ -192,6 +192,23 @@ 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 +216,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;
|
||||
}
|
||||
|
@ -136,6 +136,11 @@ impl VeilidAPI {
|
||||
.ok_or(VeilidAPIError::NotInitialized)
|
||||
}
|
||||
|
||||
/// Get the Node ID.
|
||||
pub fn get_node_id(&self) -> VeilidAPIResult<CryptoTypedGroup<CryptoKey>> {
|
||||
Ok(self.config()?.get().network.routing_table.node_id.clone())
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Internal Accessors
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user