Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: sdd test_send_backend_message #541

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions crates/node/src/tests/wasm/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use rings_rpc::protos::rings_node::*;
use wasm_bindgen_futures::JsFuture;
use wasm_bindgen_test::*;

use crate::backend::types::BackendMessage;
use crate::prelude::rings_core::utils;
use crate::prelude::rings_core::utils::js_value;
use crate::provider::browser;
Expand Down Expand Up @@ -104,6 +105,34 @@ async fn test_two_provider_connect_and_list() {
assert_eq!(peers.len(), 0);
}

#[wasm_bindgen_test]
async fn test_send_backend_message() {
let provider1 = new_provider().await;
let provider2 = new_provider().await;

futures::try_join!(
JsFuture::from(provider1.listen()),
JsFuture::from(provider2.listen()),
)
.unwrap();

create_connection(&provider1, &provider2).await;
console_log!("wait for register");
utils::js_utils::window_sleep(1000).await.unwrap();

let msg = BackendMessage::PlainText("test".to_string());
let req = msg
.into_send_backend_message_request(provider2.address())
.unwrap();

JsFuture::from(provider1.request(
"sendBackendMessage".to_string(),
js_value::serialize(&req).unwrap(),
))
.await
.unwrap();
}

#[wasm_bindgen_test]
async fn test_get_address_from_hex_pubkey() {
let pk = "02c0eeef8d136b10b862a0ac979eac2ad036f9902d87963ddf0fa108f1e275b9c7";
Expand Down
Loading