From fc916e2bbcaa1f9cb9614fbe676f002b18559fee Mon Sep 17 00:00:00 2001 From: Paulo Date: Thu, 6 Jan 2022 00:53:37 +0000 Subject: [PATCH 1/5] fetch system chain, name and version --- src/rpc.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/rpc.rs b/src/rpc.rs index 206aabbed2..470a4166c0 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -391,6 +391,21 @@ impl Rpc { Ok(self.client.request("system_properties", &[]).await?) } + /// Fetch system chain + pub async fn system_chain(&self) -> Result { + Ok(self.client.request("system_chain", &[]).await?) + } + + /// Fetch system name + pub async fn system_name(&self) -> Result { + Ok(self.client.request("system_name", &[]).await?) + } + + /// Fetch system version + pub async fn system_version(&self) -> Result { + Ok(self.client.request("system_version", &[]).await?) + } + /// Get a header pub async fn header( &self, From 054ccfa68cff7f8f04f688ab16ab5d20f87c030c Mon Sep 17 00:00:00 2001 From: Paulo Date: Thu, 6 Jan 2022 11:13:25 +0000 Subject: [PATCH 2/5] add fetch system tests --- tests/integration/client.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/integration/client.rs b/tests/integration/client.rs index a3c0dd085a..0eb0d71cdd 100644 --- a/tests/integration/client.rs +++ b/tests/integration/client.rs @@ -122,3 +122,21 @@ async fn test_iter() { } assert_eq!(i, 13); } + +#[async_std::test] +async fn fetch_system_chain() { + let node_process = test_node_process().await; + node_process.client().rpc().system_chain().await.unwrap(); +} + +#[async_std::test] +async fn fetch_system_name() { + let node_process = test_node_process().await; + node_process.client().rpc().system_name().await.unwrap(); +} + +#[async_std::test] +async fn fetch_system_version() { + let node_process = test_node_process().await; + node_process.client().rpc().system_version().await.unwrap(); +} From 2056339b6270ab35cdcdc5d1025e94420155cfd4 Mon Sep 17 00:00:00 2001 From: Paulo Date: Thu, 6 Jan 2022 13:05:30 +0000 Subject: [PATCH 3/5] fix fetch system test --- tests/integration/client.rs | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/tests/integration/client.rs b/tests/integration/client.rs index 0eb0d71cdd..6992bd0c6e 100644 --- a/tests/integration/client.rs +++ b/tests/integration/client.rs @@ -124,19 +124,10 @@ async fn test_iter() { } #[async_std::test] -async fn fetch_system_chain() { +async fn fetch_system_info() { let node_process = test_node_process().await; - node_process.client().rpc().system_chain().await.unwrap(); -} - -#[async_std::test] -async fn fetch_system_name() { - let node_process = test_node_process().await; - node_process.client().rpc().system_name().await.unwrap(); -} - -#[async_std::test] -async fn fetch_system_version() { - let node_process = test_node_process().await; - node_process.client().rpc().system_version().await.unwrap(); -} + 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_eq!(client.rpc().system_version().await.unwrap().is_empty(), false); +} \ No newline at end of file From a9420d83a7f7daf60f4ef8bdfde0600984fc1009 Mon Sep 17 00:00:00 2001 From: Paulo Date: Thu, 6 Jan 2022 13:09:42 +0000 Subject: [PATCH 4/5] fix cargo fmt --- tests/integration/client.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/integration/client.rs b/tests/integration/client.rs index 6992bd0c6e..05a3b17bfd 100644 --- a/tests/integration/client.rs +++ b/tests/integration/client.rs @@ -129,5 +129,8 @@ async fn fetch_system_info() { 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_eq!(client.rpc().system_version().await.unwrap().is_empty(), false); -} \ No newline at end of file + assert_eq!( + client.rpc().system_version().await.unwrap().is_empty(), + false + ); +} From 6d30c2668898fea30ab2b6f17695f4f5fb56cb7e Mon Sep 17 00:00:00 2001 From: Paulo Date: Thu, 6 Jan 2022 13:47:57 +0000 Subject: [PATCH 5/5] fix cargo clippy --- tests/integration/client.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/integration/client.rs b/tests/integration/client.rs index 05a3b17bfd..47676fb6ee 100644 --- a/tests/integration/client.rs +++ b/tests/integration/client.rs @@ -129,8 +129,5 @@ async fn fetch_system_info() { 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_eq!( - client.rpc().system_version().await.unwrap().is_empty(), - false - ); + assert!(!client.rpc().system_version().await.unwrap().is_empty()); }