Fix the browser tests by not relying on Flaming Fir (#5728)

* Fix the browser tests

* Mistyping

* Fix warnings

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
This commit is contained in:
Ashley
2020-04-22 16:28:08 +02:00
committed by GitHub
parent 4e7e65ff99
commit 733a4250aa
2 changed files with 16 additions and 28 deletions
+9 -24
View File
@@ -32,14 +32,9 @@ use wasm_bindgen_futures::JsFuture;
use wasm_bindgen::JsValue;
use jsonrpc_core::types::{MethodCall, Success, Version, Params, Id};
use serde::de::DeserializeOwned;
use futures_timer::Delay;
use std::time::Duration;
use futures::FutureExt;
wasm_bindgen_test_configure!(run_in_browser);
const CHAIN_SPEC: &str = include_str!("../../cli/res/flaming-fir.json");
fn rpc_call(method: &str) -> String {
serde_json::to_string(&MethodCall {
jsonrpc: Some(Version::V2),
@@ -59,26 +54,16 @@ fn deserialize_rpc_result<T: DeserializeOwned>(js_value: JsValue) -> T {
#[wasm_bindgen_test]
async fn runs() {
let mut client = node_cli::start_client(CHAIN_SPEC.into(), "info".into())
let mut client = node_cli::start_client(None, "info".into())
.await
.unwrap();
let mut test_timeout = Delay::new(Duration::from_secs(45));
loop {
// Check that timeout hasn't expired.
assert!((&mut test_timeout).now_or_never().is_none(), "Test timed out.");
// Let the node do a bit of work.
Delay::new(Duration::from_secs(5)).await;
let state: sc_rpc_api::system::Health = deserialize_rpc_result(
JsFuture::from(client.rpc_send(&rpc_call("system_health")))
.await
.unwrap()
);
if state.should_have_peers && state.peers > 0 && state.is_syncing {
break;
}
}
// Check that the node handles rpc calls.
// TODO: Re-add the code that checks if the node is syncing.
let chain_name: String = deserialize_rpc_result(
JsFuture::from(client.rpc_send(&rpc_call("system_chain")))
.await
.unwrap()
);
assert_eq!(chain_name, "Development");
}