Skip to content

Commit 88cbb4f

Browse files
committed
Drop unnecessary Result in RestClient::new
.. as it's infallible
1 parent 4cdb12f commit 88cbb4f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lightning-block-sync/src/rest.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ impl RestClient {
2323
/// Creates a new REST client connected to the given endpoint.
2424
///
2525
/// The endpoint should contain the REST path component (e.g., http://127.0.0.1:8332/rest).
26-
pub fn new(endpoint: HttpEndpoint) -> std::io::Result<Self> {
27-
Ok(Self { endpoint, client: Mutex::new(None) })
26+
pub fn new(endpoint: HttpEndpoint) -> Self {
27+
Self { endpoint, client: Mutex::new(None) }
2828
}
2929

3030
/// Requests a resource encoded in `F` format and interpreted as type `T`.
@@ -120,7 +120,7 @@ mod tests {
120120
#[tokio::test]
121121
async fn request_unknown_resource() {
122122
let server = HttpServer::responding_with_not_found();
123-
let client = RestClient::new(server.endpoint()).unwrap();
123+
let client = RestClient::new(server.endpoint());
124124

125125
match client.request_resource::<BinaryResponse, u32>("/").await {
126126
Err(e) => assert_eq!(e.kind(), std::io::ErrorKind::Other),
@@ -131,7 +131,7 @@ mod tests {
131131
#[tokio::test]
132132
async fn request_malformed_resource() {
133133
let server = HttpServer::responding_with_ok(MessageBody::Content("foo"));
134-
let client = RestClient::new(server.endpoint()).unwrap();
134+
let client = RestClient::new(server.endpoint());
135135

136136
match client.request_resource::<BinaryResponse, u32>("/").await {
137137
Err(e) => assert_eq!(e.kind(), std::io::ErrorKind::InvalidData),
@@ -142,7 +142,7 @@ mod tests {
142142
#[tokio::test]
143143
async fn request_valid_resource() {
144144
let server = HttpServer::responding_with_ok(MessageBody::Content(42));
145-
let client = RestClient::new(server.endpoint()).unwrap();
145+
let client = RestClient::new(server.endpoint());
146146

147147
match client.request_resource::<BinaryResponse, u32>("/").await {
148148
Err(e) => panic!("Unexpected error: {:?}", e),
@@ -157,7 +157,7 @@ mod tests {
157157
// "bitmap" field, so this should suffice for testing
158158
"{\"chainHeight\": 1, \"bitmap\":\"0\",\"utxos\":[]}",
159159
));
160-
let client = RestClient::new(server.endpoint()).unwrap();
160+
let client = RestClient::new(server.endpoint());
161161

162162
let outpoint = OutPoint::new(bitcoin::Txid::from_byte_array([0; 32]), 0);
163163
let unspent_output = client.is_output_unspent(outpoint).await.unwrap();
@@ -171,7 +171,7 @@ mod tests {
171171
// field, so this should suffice for testing
172172
"{\"chainHeight\": 1, \"bitmap\":\"1\",\"utxos\":[]}",
173173
));
174-
let client = RestClient::new(server.endpoint()).unwrap();
174+
let client = RestClient::new(server.endpoint());
175175

176176
let outpoint = OutPoint::new(bitcoin::Txid::from_byte_array([0; 32]), 0);
177177
let unspent_output = client.is_output_unspent(outpoint).await.unwrap();

0 commit comments

Comments
 (0)