Skip to content

Commit

Permalink
tests: Add availability test for RPC.
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyhunsen committed Aug 26, 2024
1 parent c688ed4 commit 27b1744
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
use bitcoin_mock_rpc::rpc::spawn_rpc_server;
use bitcoincore_rpc::RpcApi;
use jsonrpsee::core::client::ClientT;
use jsonrpsee::{http_client::HttpClient, rpc_params};

#[tokio::test]
async fn check_server_availability() {
let server_addr = spawn_rpc_server(None, None).await.unwrap();
let url = format!("http://{}", server_addr);
println!("Server URL: {url}");

let client = HttpClient::builder().build(url).unwrap();
let params = rpc_params![];

let response: String = client.request("getnewaddress", params).await.unwrap();
println!("Server response: {:?}", response);
}

#[tokio::test]
async fn create_connection() {
Expand Down

0 comments on commit 27b1744

Please sign in to comment.