wasm fixes

This commit is contained in:
John Smith 2022-11-29 22:51:51 -05:00
parent 5c0a500971
commit 672d750f8f
14 changed files with 166 additions and 112 deletions

View file

@ -3,10 +3,7 @@ mod protected_store;
mod system;
mod table_store;
pub mod utils;
pub use block_store::*;
pub use protected_store::*;
pub use system::*;
pub use table_store::*;
use utils::*;

View file

@ -1,4 +1,3 @@
use super::*;
use crate::*;
use data_encoding::BASE64URL_NOPAD;
use rkyv::{Archive as RkyvArchive, Deserialize as RkyvDeserialize, Serialize as RkyvSerialize};

View file

@ -1,6 +1,6 @@
use async_executors::{Bindgen, LocalSpawnHandleExt, SpawnHandleExt, Timer};
use futures_util::future::{select, Either};
use js_sys::*;
use crate::*;
//use js_sys::*;
pub async fn get_outbound_relay_peer() -> Option<crate::veilid_api::PeerInfo> {
// unimplemented!
@ -8,7 +8,7 @@ pub async fn get_outbound_relay_peer() -> Option<crate::veilid_api::PeerInfo> {
}
// pub async fn get_pwa_web_server_config() -> {
// if utils::is_browser() {
// if is_browser() {
// let win = window().unwrap();
// let doc = win.document().unwrap();

View file

@ -1,5 +1,3 @@
use super::*;
use crate::intf::table_db::*;
use crate::*;
use keyvaluedb_web::*;
@ -135,7 +133,7 @@ impl TableStore {
}
}
if utils::is_browser() {
if is_browser() {
let out = match Database::delete(table_name.clone()).await {
Ok(_) => true,
Err(_) => false,

View file

@ -1,5 +1,6 @@
#![deny(clippy::all)]
#![deny(unused_must_use)]
#![recursion_limit = "1024"]
cfg_if::cfg_if! {
if #[cfg(target_arch = "wasm32")] {

View file

@ -192,7 +192,7 @@ impl RouteSpecDetail {
/// The core representation of the RouteSpecStore that can be serialized
#[derive(Debug, Clone, Default, RkyvArchive, RkyvSerialize, RkyvDeserialize)]
#[archive_attr(repr(C), derive(CheckBytes))]
#[archive_attr(repr(C, align(8)), derive(CheckBytes))]
pub struct RouteSpecStoreContent {
/// All of the routes we have allocated so far
details: HashMap<DHTKey, RouteSpecDetail>,

View file

@ -1,3 +1,14 @@
#[cfg(target_os = "android")]
mod android;
pub mod common;
#[cfg(target_os = "ios")]
mod ios;
#[cfg(not(target_arch = "wasm32"))]
mod native;
#[allow(unused_imports)]
use super::*;
pub use common::*;
pub use crypto::tests::*;
pub use network_manager::tests::*;

View file

@ -597,11 +597,13 @@ impl VeilidConfig {
macro_rules! get_config {
($key:expr) => {
let keyname = &stringify!($key)[6..];
$key = *cb(keyname.to_owned())?.downcast().map_err(|_| {
let err = format!("incorrect type for key {}", keyname);
debug!("{}", err);
VeilidAPIError::generic(err)
})?;
let v = cb(keyname.to_owned())?;
$key = match v.downcast() {
Ok(v) => *v,
Err(_) => {
apibail_generic!(format!("incorrect type for key {}", keyname))
}
};
};
}

View file

@ -1,8 +1,9 @@
//! Test suite for the Web and headless browsers.
#![cfg(target_arch = "wasm32")]
#![recursion_limit = "256"]
use veilid_core::tests::common::*;
use veilid_core::xx::*;
use veilid_core::tests::*;
use veilid_core::tools::*;
use wasm_bindgen_test::*;
wasm_bindgen_test_configure!(run_in_browser);
@ -15,24 +16,70 @@ static SETUP_ONCE: Once = Once::new();
pub fn setup() -> () {
SETUP_ONCE.call_once(|| {
console_error_panic_hook::set_once();
let mut builder = tracing_wasm::WASMLayerConfigBuilder::new();
builder.set_report_logs_in_timings(false);
builder.set_max_level(Level::TRACE);
builder.set_console_config(tracing_wasm::ConsoleConfig::ReportWithConsoleColor);
tracing_wasm::set_as_global_default_with_config(builder.build());
cfg_if! {
if #[cfg(feature = "tracing")] {
let mut builder = tracing_wasm::WASMLayerConfigBuilder::new();
builder.set_report_logs_in_timings(false);
builder.set_max_level(Level::TRACE);
builder.set_console_config(tracing_wasm::ConsoleConfig::ReportWithConsoleColor);
tracing_wasm::set_as_global_default_with_config(builder.build());
} else {
wasm_logger::init(wasm_logger::Config::default());
}
}
});
}
#[wasm_bindgen_test]
async fn run_test_host_interface() {
setup();
test_host_interface::test_all().await;
}
#[wasm_bindgen_test]
async fn run_test_async_tag_lock() {
async fn run_test_dht_key() {
setup();
test_async_tag_lock::test_all().await;
test_dht_key::test_all().await;
}
#[wasm_bindgen_test]
async fn run_test_veilid_core() {
setup();
test_veilid_core::test_all().await;
}
#[wasm_bindgen_test]
async fn test_veilid_config() {
setup();
test_veilid_config::test_all().await;
}
#[wasm_bindgen_test]
async fn run_test_connection_table() {
setup();
test_connection_table::test_all().await;
}
#[wasm_bindgen_test]
async fn exec_test_table_store() {
setup();
test_table_store::test_all().await;
}
#[wasm_bindgen_test]
async fn exec_test_protected_store() {
setup();
test_protected_store::test_all().await;
}
#[wasm_bindgen_test]
async fn exec_test_crypto() {
setup();
test_crypto::test_all().await;
}
#[wasm_bindgen_test]
async fn exec_test_envelope_receipt() {
setup();
test_envelope_receipt::test_all().await;
}