work on wasm tests

This commit is contained in:
Christien Rioux 2023-10-22 11:24:15 -04:00
parent 0c8b2e7023
commit 8fa4ab10a4
6 changed files with 102 additions and 73 deletions

View File

@ -253,13 +253,14 @@ tracing-oslog = { version = "0.1.2", optional = true }
### DEV DEPENDENCIES
[dev-dependencies]
serial_test = "2.0.0"
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
simplelog = { version = "0.12.1", features = ["test"] }
serial_test = "2.0.0"
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
serial_test = { version = "2.0.0", default-features = false, features = [
"async",
] }
wasm-bindgen-test = "0.3.37"
console_error_panic_hook = "0.1.7"
wee_alloc = "0.4.5"

View File

@ -192,7 +192,7 @@ impl RouteSpecStore {
)
}
#[instrument(level = "trace", skip(self, inner, rti), ret, err)]
#[instrument(level = "trace", skip(self, inner, rti), ret, err(level=Level::DEBUG))]
#[allow(clippy::too_many_arguments)]
fn allocate_route_inner(
&self,

View File

@ -192,7 +192,12 @@ pub fn config_callback(key: String) -> ConfigCallbackReturn {
"network.routing_table.node_id" => Ok(Box::new(TypedKeyGroup::new())),
"network.routing_table.node_id_secret" => Ok(Box::new(TypedSecretGroup::new())),
// "network.routing_table.bootstrap" => Ok(Box::new(Vec::<String>::new())),
#[cfg(not(target_arch = "wasm32"))]
"network.routing_table.bootstrap" => Ok(Box::new(vec!["bootstrap.veilid.net".to_string()])),
#[cfg(target_arch = "wasm32")]
"network.routing_table.bootstrap" => Ok(Box::new(vec![
"ws://bootstrap.veilid.net:5150/ws".to_string(),
])),
"network.routing_table.limit_over_attached" => Ok(Box::new(64u32)),
"network.routing_table.limit_fully_attached" => Ok(Box::new(32u32)),
"network.routing_table.limit_attached_strong" => Ok(Box::new(16u32)),
@ -326,10 +331,16 @@ pub async fn test_config() {
assert_eq!(inner.network.rpc.default_route_hop_count, 1u8);
assert_eq!(inner.network.routing_table.node_id.len(), 0);
assert_eq!(inner.network.routing_table.node_id_secret.len(), 0);
#[cfg(not(target_arch = "wasm32"))]
assert_eq!(
inner.network.routing_table.bootstrap,
vec!["bootstrap.veilid.net"],
);
#[cfg(target_arch = "wasm32")]
assert_eq!(
inner.network.routing_table.bootstrap,
vec!["ws://bootstrap.veilid.net:5150/ws"],
);
assert_eq!(inner.network.routing_table.limit_over_attached, 64u32);
assert_eq!(inner.network.routing_table.limit_fully_attached, 32u32);
assert_eq!(inner.network.routing_table.limit_attached_strong, 16u32);

View File

@ -1,11 +1,6 @@
//! Test suite for Native
#![cfg(not(target_arch = "wasm32"))]
use crate::crypto::tests::*;
use crate::network_manager::tests::*;
use crate::routing_table;
use crate::table_store::tests::*;
use crate::tests::common::*;
use crate::veilid_api;
use crate::tests::*;
use crate::*;
///////////////////////////////////////////////////////////////////////////

View File

@ -4,6 +4,7 @@
use cfg_if::*;
use parking_lot::Once;
use serial_test::serial;
use veilid_core::tests::*;
use wasm_bindgen_test::*;
@ -31,68 +32,86 @@ pub fn setup() -> () {
});
}
#[wasm_bindgen_test]
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_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_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_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_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_routing_table() {
// setup();
// test_serialize_routing_table::test_all().await;
// }
#[wasm_bindgen_test]
async fn wasm_test_veilid_core() {
#[serial]
async fn wasm_test_dht() {
setup();
test_veilid_core::test_all().await;
}
#[wasm_bindgen_test]
async fn wasm_test_veilid_config() {
setup();
test_veilid_config::test_all().await;
}
#[wasm_bindgen_test]
async fn wasm_test_connection_table() {
setup();
test_connection_table::test_all().await;
}
#[wasm_bindgen_test]
async fn wasm_test_signed_node_info() {
setup();
test_signed_node_info::test_all().await;
}
#[wasm_bindgen_test]
async fn wasm_test_table_store() {
setup();
test_table_store::test_all().await;
}
#[wasm_bindgen_test]
async fn wasm_test_protected_store() {
setup();
test_protected_store::test_all().await;
}
#[wasm_bindgen_test]
async fn wasm_test_crypto() {
setup();
test_crypto::test_all().await;
}
#[wasm_bindgen_test]
async fn wasm_test_envelope_receipt() {
setup();
test_envelope_receipt::test_all().await;
}
#[wasm_bindgen_test]
async fn wasm_test_serialize_json() {
setup();
test_serialize_json::test_all().await;
}
#[wasm_bindgen_test]
async fn wasm_test_serialize_routing_table() {
setup();
test_serialize_routing_table::test_all().await;
test_dht::test_all().await;
}

View File

@ -119,11 +119,14 @@ ifstructs = "0.1.1"
### DEV DEPENDENCIES
[dev-dependencies]
serial_test = "^2.0.0"
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
simplelog = { version = "0.12.1", features = ["test"] }
serial_test = "2.0.0"
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
serial_test = { version = "2.0.0", default-features = false, features = [
"async",
] }
console_error_panic_hook = "0.1.7"
wasm-bindgen-test = "0.3.37"
wee_alloc = "0.4.5"