Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseAbram committed May 8, 2024
1 parent 6cc108a commit 1854a85
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ hex ={ version="0.4.3", optional=true }
# Only for the browser
js-sys={ version="0.3.68", optional=true }

[dev-dependencies]
tokio={ version="1.36" }

[features]
default=["native", "full-client-native"]
native=[
Expand Down
43 changes: 43 additions & 0 deletions crates/client/src/chain_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,46 @@ pub async fn get_rpc(url: &str) -> Result<LegacyRpcMethods<EntropyConfig>, subxt
let rpc_methods = LegacyRpcMethods::<EntropyConfig>::new(rpc_client);
Ok(rpc_methods)
}

#[cfg(test)]
#[tokio::test]
async fn test_get_api_rpc() {
let insecure_url = "ws://1234:9944";
let secure_url = "ws://localhost:9944";

let insecure_result_rpc = get_rpc(insecure_url).await;
assert_eq!(
insecure_result_rpc
.unwrap_err()
.to_string()
.contains("Rpc error: RPC error: Error when opening the TCP socket:"),
true
);

let secure_result_rpc = get_rpc(secure_url).await;
assert_eq!(
secure_result_rpc
.unwrap_err()
.to_string()
.contains("Rpc error: RPC error: Error when opening the TCP socket:"),
true
);

let insecure_result_api = get_api(insecure_url).await;
assert_eq!(
insecure_result_api
.unwrap_err()
.to_string()
.contains("Rpc error: RPC error: Error when opening the TCP socket:"),
true
);

let secure_result_api = get_api(secure_url).await;
assert_eq!(
secure_result_api
.unwrap_err()
.to_string()
.contains("Rpc error: RPC error: Error when opening the TCP socket:"),
true
);
}

0 comments on commit 1854a85

Please sign in to comment.