Skip to content

Commit

Permalink
Merge pull request #2454 from b-zee/fix-wasm-test-fixup
Browse files Browse the repository at this point in the history
fix(autonomi): wasm test fixup
  • Loading branch information
maqi authored Nov 19, 2024
2 parents 7ebd4dc + b1ab091 commit 618ee7e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
2 changes: 1 addition & 1 deletion autonomi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern crate tracing;

pub mod client;
#[cfg(feature = "data")]
pub mod self_encryption;
mod self_encryption;
mod utils;

pub use sn_evm::get_evm_network_from_env;
Expand Down
31 changes: 9 additions & 22 deletions autonomi/tests/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,20 @@ use wasm_bindgen_test::*;

wasm_bindgen_test_configure!(run_in_browser);

// #[wasm_bindgen_test]
// async fn put() -> Result<(), Box<dyn std::error::Error>> {
// enable_logging_wasm("sn_networking,autonomi,wasm");

// let client = Client::connect(&peers_from_env()?).await?;
// let wallet = get_funded_wallet();
// let data = gen_random_data(1024 * 1024 * 10);

// let addr = client.data_put(data.clone(), wallet.into()).await?;

// sleep(Duration::from_secs(10)).await;

// let data_fetched = client.data_get(addr).await?;
// assert_eq!(data, data_fetched, "data fetched should match data put");

// Ok(())
// }

#[wasm_bindgen_test]
async fn self_encryption_timing() -> Result<(), Box<dyn std::error::Error>> {
async fn put() -> Result<(), Box<dyn std::error::Error>> {
enable_logging_wasm("sn_networking,autonomi,wasm");

let client = Client::connect(&peers_from_env()?).await?;
let wallet = get_funded_wallet();
let data = gen_random_data(1024 * 1024 * 10);

let now = sn_networking::target_arch::Instant::now();
let (data_map_chunk, chunks) = autonomi::self_encryption::encrypt(data).await?;
tracing::info!("Encryption took: {:.2?}", now.elapsed());
let addr = client.data_put(data.clone(), wallet.into()).await?;

sleep(Duration::from_secs(10)).await;

let data_fetched = client.data_get(addr).await?;
assert_eq!(data, data_fetched, "data fetched should match data put");

Ok(())
}
Expand Down

0 comments on commit 618ee7e

Please sign in to comment.