-
Notifications
You must be signed in to change notification settings - Fork 412
Drop unnecessary Result
in RpcClient::new
#3353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop unnecessary Result
in RpcClient::new
#3353
Conversation
Needs corresponding test updates. |
.. as it's infallible
3c8f728
to
4cdb12f
Compare
Ah, sorry, duh. Now force pushed the following changes: > git diff-tree -U2 3c8f728b3 4cdb12f91
diff --git a/lightning-block-sync/src/rpc.rs b/lightning-block-sync/src/rpc.rs
index f0d4051a3..3df50a226 100644
--- a/lightning-block-sync/src/rpc.rs
+++ b/lightning-block-sync/src/rpc.rs
@@ -205,5 +205,5 @@ mod tests {
async fn call_method_returning_unknown_response() {
let server = HttpServer::responding_with_not_found();
- let client = RpcClient::new(CREDENTIALS, server.endpoint()).unwrap();
+ let client = RpcClient::new(CREDENTIALS, server.endpoint());
match client.call_method::<u64>("getblockcount", &[]).await {
@@ -217,5 +217,5 @@ mod tests {
let response = serde_json::json!("foo");
let server = HttpServer::responding_with_ok(MessageBody::Content(response));
- let client = RpcClient::new(CREDENTIALS, server.endpoint()).unwrap();
+ let client = RpcClient::new(CREDENTIALS, server.endpoint());
match client.call_method::<u64>("getblockcount", &[]).await {
@@ -234,5 +234,5 @@ mod tests {
});
let server = HttpServer::responding_with_server_error(response);
- let client = RpcClient::new(CREDENTIALS, server.endpoint()).unwrap();
+ let client = RpcClient::new(CREDENTIALS, server.endpoint());
let invalid_block_hash = serde_json::json!("foo");
@@ -252,5 +252,5 @@ mod tests {
let response = serde_json::json!({});
let server = HttpServer::responding_with_ok(MessageBody::Content(response));
- let client = RpcClient::new(CREDENTIALS, server.endpoint()).unwrap();
+ let client = RpcClient::new(CREDENTIALS, server.endpoint());
match client.call_method::<u64>("getblockcount", &[]).await {
@@ -267,5 +267,5 @@ mod tests {
let response = serde_json::json!({ "result": "foo" });
let server = HttpServer::responding_with_ok(MessageBody::Content(response));
- let client = RpcClient::new(CREDENTIALS, server.endpoint()).unwrap();
+ let client = RpcClient::new(CREDENTIALS, server.endpoint());
match client.call_method::<u64>("getblockcount", &[]).await {
@@ -282,5 +282,5 @@ mod tests {
let response = serde_json::json!({ "result": 654470 });
let server = HttpServer::responding_with_ok(MessageBody::Content(response));
- let client = RpcClient::new(CREDENTIALS, server.endpoint()).unwrap();
+ let client = RpcClient::new(CREDENTIALS, server.endpoint());
match client.call_method::<u64>("getblockcount", &[]).await {
@@ -294,5 +294,5 @@ mod tests {
let response = serde_json::json!({ "result": null });
let server = HttpServer::responding_with_ok(MessageBody::Content(response));
- let client = RpcClient::new(CREDENTIALS, server.endpoint()).unwrap();
+ let client = RpcClient::new(CREDENTIALS, server.endpoint());
let outpoint = OutPoint::new(bitcoin::Txid::from_byte_array([0; 32]), 0);
let unspent_output = client.is_output_unspent(outpoint).await.unwrap();
@@ -304,5 +304,5 @@ mod tests {
let response = serde_json::json!({ "result": {"bestblock": 1, "confirmations": 42}});
let server = HttpServer::responding_with_ok(MessageBody::Content(response));
- let client = RpcClient::new(CREDENTIALS, server.endpoint()).unwrap();
+ let client = RpcClient::new(CREDENTIALS, server.endpoint());
let outpoint = OutPoint::new(bitcoin::Txid::from_byte_array([0; 32]), 0);
let unspent_output = client.is_output_unspent(outpoint).await.unwrap(); |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3353 +/- ##
==========================================
- Coverage 89.61% 89.60% -0.01%
==========================================
Files 127 127
Lines 103531 103531
Branches 103531 103531
==========================================
- Hits 92782 92774 -8
- Misses 8052 8055 +3
- Partials 2697 2702 +5 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you do the same for RestClient
?
.. as it's infallible
Sure, added another commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I was looking in doing the same thing yesterday!
Why did no one merge this? |
Usually, the problem is the opposite 😄 |
.. as it's infallible. Just a trivial change that spares the user a dangerous looking
unwrap
.