mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 02:21:14 +00:00
Convert spaces to tabs (#6799)
This commit is contained in:
@@ -93,26 +93,26 @@ pub enum Mode {
|
||||
}
|
||||
|
||||
impl std::str::FromStr for Mode {
|
||||
type Err = &'static str;
|
||||
fn from_str(day: &str) -> Result<Self, Self::Err> {
|
||||
match day {
|
||||
"regular" => Ok(Mode::Regular),
|
||||
"profile" => Ok(Mode::Profile),
|
||||
_ => Err("Could not parse mode"),
|
||||
}
|
||||
}
|
||||
type Err = &'static str;
|
||||
fn from_str(day: &str) -> Result<Self, Self::Err> {
|
||||
match day {
|
||||
"regular" => Ok(Mode::Regular),
|
||||
"profile" => Ok(Mode::Profile),
|
||||
_ => Err("Could not parse mode"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for BenchmarkOutput {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}: avg {}, w_avg {}",
|
||||
self.name,
|
||||
NsFormatter(self.raw_average),
|
||||
NsFormatter(self.average),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run_benchmark(
|
||||
@@ -159,4 +159,4 @@ macro_rules! matrix(
|
||||
}
|
||||
};
|
||||
() => { vec![] }
|
||||
);
|
||||
);
|
||||
|
||||
@@ -32,7 +32,7 @@ use sp_transaction_pool::{TransactionPool, TransactionSource};
|
||||
use crate::core::{self, Path, Mode};
|
||||
|
||||
pub struct PoolBenchmarkDescription {
|
||||
pub database_type: DatabaseType,
|
||||
pub database_type: DatabaseType,
|
||||
}
|
||||
|
||||
pub struct PoolBenchmark {
|
||||
@@ -41,7 +41,7 @@ pub struct PoolBenchmark {
|
||||
|
||||
impl core::BenchmarkDescription for PoolBenchmarkDescription {
|
||||
fn path(&self) -> Path {
|
||||
Path::new(&["node", "txpool"])
|
||||
Path::new(&["node", "txpool"])
|
||||
}
|
||||
|
||||
fn setup(self: Box<Self>) -> Box<dyn core::Benchmark> {
|
||||
@@ -55,7 +55,7 @@ impl core::BenchmarkDescription for PoolBenchmarkDescription {
|
||||
}
|
||||
|
||||
fn name(&self) -> Cow<'static, str> {
|
||||
"Transaction pool benchmark".into()
|
||||
"Transaction pool benchmark".into()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,34 +37,34 @@ use serde::de::DeserializeOwned;
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
fn rpc_call(method: &str) -> String {
|
||||
serde_json::to_string(&MethodCall {
|
||||
jsonrpc: Some(Version::V2),
|
||||
method: method.into(),
|
||||
params: Params::None,
|
||||
id: Id::Num(1)
|
||||
}).unwrap()
|
||||
serde_json::to_string(&MethodCall {
|
||||
jsonrpc: Some(Version::V2),
|
||||
method: method.into(),
|
||||
params: Params::None,
|
||||
id: Id::Num(1)
|
||||
}).unwrap()
|
||||
}
|
||||
|
||||
fn deserialize_rpc_result<T: DeserializeOwned>(js_value: JsValue) -> T {
|
||||
let string = js_value.as_string().unwrap();
|
||||
let value = serde_json::from_str::<Success>(&string).unwrap().result;
|
||||
// We need to convert a `Value::Object` into a proper type.
|
||||
let value_string = serde_json::to_string(&value).unwrap();
|
||||
serde_json::from_str(&value_string).unwrap()
|
||||
let string = js_value.as_string().unwrap();
|
||||
let value = serde_json::from_str::<Success>(&string).unwrap().result;
|
||||
// We need to convert a `Value::Object` into a proper type.
|
||||
let value_string = serde_json::to_string(&value).unwrap();
|
||||
serde_json::from_str(&value_string).unwrap()
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
async fn runs() {
|
||||
let mut client = node_cli::start_client(None, "info".into())
|
||||
.await
|
||||
.unwrap();
|
||||
let mut client = node_cli::start_client(None, "info".into())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// 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");
|
||||
// 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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user