@@ -50,13 +50,13 @@ impl RpcClient {
50
50
/// Creates a new RPC client connected to the given endpoint with the provided credentials. The
51
51
/// credentials should be a base64 encoding of a user name and password joined by a colon, as is
52
52
/// required for HTTP basic access authentication.
53
- pub fn new ( credentials : & str , endpoint : HttpEndpoint ) -> std :: io :: Result < Self > {
54
- Ok ( Self {
53
+ pub fn new ( credentials : & str , endpoint : HttpEndpoint ) -> Self {
54
+ Self {
55
55
basic_auth : "Basic " . to_string ( ) + credentials,
56
56
endpoint,
57
57
client : Mutex :: new ( None ) ,
58
58
id : AtomicUsize :: new ( 0 ) ,
59
- } )
59
+ }
60
60
}
61
61
62
62
/// Calls a method with the response encoded in JSON format and interpreted as type `T`.
@@ -204,7 +204,7 @@ mod tests {
204
204
#[ tokio:: test]
205
205
async fn call_method_returning_unknown_response ( ) {
206
206
let server = HttpServer :: responding_with_not_found ( ) ;
207
- let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) . unwrap ( ) ;
207
+ let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) ;
208
208
209
209
match client. call_method :: < u64 > ( "getblockcount" , & [ ] ) . await {
210
210
Err ( e) => assert_eq ! ( e. kind( ) , std:: io:: ErrorKind :: Other ) ,
@@ -216,7 +216,7 @@ mod tests {
216
216
async fn call_method_returning_malfomred_response ( ) {
217
217
let response = serde_json:: json!( "foo" ) ;
218
218
let server = HttpServer :: responding_with_ok ( MessageBody :: Content ( response) ) ;
219
- let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) . unwrap ( ) ;
219
+ let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) ;
220
220
221
221
match client. call_method :: < u64 > ( "getblockcount" , & [ ] ) . await {
222
222
Err ( e) => {
@@ -233,7 +233,7 @@ mod tests {
233
233
"error" : { "code" : -8 , "message" : "invalid parameter" } ,
234
234
} ) ;
235
235
let server = HttpServer :: responding_with_server_error ( response) ;
236
- let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) . unwrap ( ) ;
236
+ let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) ;
237
237
238
238
let invalid_block_hash = serde_json:: json!( "foo" ) ;
239
239
match client. call_method :: < u64 > ( "getblock" , & [ invalid_block_hash] ) . await {
@@ -251,7 +251,7 @@ mod tests {
251
251
async fn call_method_returning_missing_result ( ) {
252
252
let response = serde_json:: json!( { } ) ;
253
253
let server = HttpServer :: responding_with_ok ( MessageBody :: Content ( response) ) ;
254
- let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) . unwrap ( ) ;
254
+ let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) ;
255
255
256
256
match client. call_method :: < u64 > ( "getblockcount" , & [ ] ) . await {
257
257
Err ( e) => {
@@ -266,7 +266,7 @@ mod tests {
266
266
async fn call_method_returning_malformed_result ( ) {
267
267
let response = serde_json:: json!( { "result" : "foo" } ) ;
268
268
let server = HttpServer :: responding_with_ok ( MessageBody :: Content ( response) ) ;
269
- let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) . unwrap ( ) ;
269
+ let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) ;
270
270
271
271
match client. call_method :: < u64 > ( "getblockcount" , & [ ] ) . await {
272
272
Err ( e) => {
@@ -281,7 +281,7 @@ mod tests {
281
281
async fn call_method_returning_valid_result ( ) {
282
282
let response = serde_json:: json!( { "result" : 654470 } ) ;
283
283
let server = HttpServer :: responding_with_ok ( MessageBody :: Content ( response) ) ;
284
- let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) . unwrap ( ) ;
284
+ let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) ;
285
285
286
286
match client. call_method :: < u64 > ( "getblockcount" , & [ ] ) . await {
287
287
Err ( e) => panic ! ( "Unexpected error: {:?}" , e) ,
@@ -293,7 +293,7 @@ mod tests {
293
293
async fn fails_to_fetch_spent_utxo ( ) {
294
294
let response = serde_json:: json!( { "result" : null } ) ;
295
295
let server = HttpServer :: responding_with_ok ( MessageBody :: Content ( response) ) ;
296
- let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) . unwrap ( ) ;
296
+ let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) ;
297
297
let outpoint = OutPoint :: new ( bitcoin:: Txid :: from_byte_array ( [ 0 ; 32 ] ) , 0 ) ;
298
298
let unspent_output = client. is_output_unspent ( outpoint) . await . unwrap ( ) ;
299
299
assert_eq ! ( unspent_output, false ) ;
@@ -303,7 +303,7 @@ mod tests {
303
303
async fn fetches_utxo ( ) {
304
304
let response = serde_json:: json!( { "result" : { "bestblock" : 1 , "confirmations" : 42 } } ) ;
305
305
let server = HttpServer :: responding_with_ok ( MessageBody :: Content ( response) ) ;
306
- let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) . unwrap ( ) ;
306
+ let client = RpcClient :: new ( CREDENTIALS , server. endpoint ( ) ) ;
307
307
let outpoint = OutPoint :: new ( bitcoin:: Txid :: from_byte_array ( [ 0 ; 32 ] ) , 0 ) ;
308
308
let unspent_output = client. is_output_unspent ( outpoint) . await . unwrap ( ) ;
309
309
assert_eq ! ( unspent_output, true ) ;
0 commit comments