Skip to content

Commit

Permalink
fetch system chain, name and version (#385)
Browse files Browse the repository at this point in the history
* fetch system chain, name and version

* add fetch system tests

* fix fetch system test

* fix cargo fmt

* fix cargo clippy
  • Loading branch information
paulormart authored Jan 10, 2022
1 parent e8cbe46 commit ea8c4dd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,21 @@ impl<T: Config> Rpc<T> {
Ok(self.client.request("system_properties", &[]).await?)
}

/// Fetch system chain
pub async fn system_chain(&self) -> Result<String, Error> {
Ok(self.client.request("system_chain", &[]).await?)
}

/// Fetch system name
pub async fn system_name(&self) -> Result<String, Error> {
Ok(self.client.request("system_name", &[]).await?)
}

/// Fetch system version
pub async fn system_version(&self) -> Result<String, Error> {
Ok(self.client.request("system_version", &[]).await?)
}

/// Get a header
pub async fn header(
&self,
Expand Down
9 changes: 9 additions & 0 deletions tests/integration/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,12 @@ async fn test_iter() {
}
assert_eq!(i, 13);
}

#[async_std::test]
async fn fetch_system_info() {
let node_process = test_node_process().await;
let client = node_process.client();
assert_eq!(client.rpc().system_chain().await.unwrap(), "Development");
assert_eq!(client.rpc().system_name().await.unwrap(), "Substrate Node");
assert!(!client.rpc().system_version().await.unwrap().is_empty());
}

0 comments on commit ea8c4dd

Please sign in to comment.