@@ -27,13 +27,13 @@ use crate::json::BlockStatsFields as BsFields;
2727use bitcoin:: consensus:: encode:: { deserialize, serialize_hex} ;
2828use bitcoin:: hashes:: hex:: FromHex ;
2929use bitcoin:: hashes:: Hash ;
30- use bitcoin:: { secp256k1, ScriptBuf , sighash } ;
30+ use bitcoin:: { secp256k1, sighash , ScriptBuf } ;
3131use bitcoin:: {
32- Address , Amount , Network , OutPoint , PrivateKey ,
33- Sequence , SignedAmount , Transaction , TxIn , TxOut , Txid , Witness ,
32+ Address , Amount , Network , OutPoint , PrivateKey , Sequence , SignedAmount , Transaction , TxIn ,
33+ TxOut , Txid , Witness ,
3434} ;
3535use bitcoincore_rpc:: bitcoincore_rpc_json:: {
36- GetBlockTemplateModes , GetBlockTemplateRules , ScanTxOutRequest , GetZmqNotificationsResult ,
36+ GetBlockTemplateModes , GetBlockTemplateRules , GetZmqNotificationsResult , ScanTxOutRequest ,
3737} ;
3838
3939lazy_static ! {
@@ -250,7 +250,8 @@ fn test_get_new_address(cl: &Client) {
250250 let addr = cl. get_new_address ( None , Some ( json:: AddressType :: Bech32 ) ) . unwrap ( ) . assume_checked ( ) ;
251251 assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2wpkh ) ) ;
252252
253- let addr = cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
253+ let addr =
254+ cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
254255 assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2sh ) ) ;
255256}
256257
@@ -261,7 +262,8 @@ fn test_get_raw_change_address(cl: &Client) {
261262 let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: Bech32 ) ) . unwrap ( ) . assume_checked ( ) ;
262263 assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2wpkh ) ) ;
263264
264- let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
265+ let addr =
266+ cl. get_raw_change_address ( Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
265267 assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2sh ) ) ;
266268}
267269
@@ -291,7 +293,9 @@ fn test_generate(cl: &Client) {
291293fn test_get_balance_generate_to_address ( cl : & Client ) {
292294 let initial = cl. get_balance ( None , None ) . unwrap ( ) ;
293295
294- let blocks = cl. generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
296+ let blocks = cl
297+ . generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
298+ . unwrap ( ) ;
295299 assert_eq ! ( blocks. len( ) , 500 ) ;
296300 assert_ne ! ( cl. get_balance( None , None ) . unwrap( ) , initial) ;
297301}
@@ -300,7 +304,9 @@ fn test_get_balances_generate_to_address(cl: &Client) {
300304 if version ( ) >= 190000 {
301305 let initial = cl. get_balances ( ) . unwrap ( ) ;
302306
303- let blocks = cl. generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
307+ let blocks = cl
308+ . generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
309+ . unwrap ( ) ;
304310 assert_eq ! ( blocks. len( ) , 500 ) ;
305311 assert_ne ! ( cl. get_balances( ) . unwrap( ) , initial) ;
306312 }
@@ -376,7 +382,8 @@ fn test_get_address_info(cl: &Client) {
376382 let info = cl. get_address_info ( & addr) . unwrap ( ) ;
377383 assert ! ( !info. witness_program. unwrap( ) . is_empty( ) ) ;
378384
379- let addr = cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
385+ let addr =
386+ cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
380387 let info = cl. get_address_info ( & addr) . unwrap ( ) ;
381388 assert ! ( !info. hex. unwrap( ) . is_empty( ) ) ;
382389}
@@ -432,27 +439,33 @@ fn test_get_received_by_address(cl: &Client) {
432439 let _ = cl. send_to_address ( & addr, btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
433440 assert_eq ! ( cl. get_received_by_address( & addr, Some ( 0 ) ) . unwrap( ) , btc( 1 ) ) ;
434441 assert_eq ! ( cl. get_received_by_address( & addr, Some ( 1 ) ) . unwrap( ) , btc( 0 ) ) ;
435- let _ = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
442+ let _ = cl
443+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
444+ . unwrap ( ) ;
436445 assert_eq ! ( cl. get_received_by_address( & addr, Some ( 6 ) ) . unwrap( ) , btc( 1 ) ) ;
437446 assert_eq ! ( cl. get_received_by_address( & addr, None ) . unwrap( ) , btc( 1 ) ) ;
438447}
439448
440449fn test_list_unspent ( cl : & Client ) {
441450 let addr = cl. get_new_address ( None , None ) . unwrap ( ) ;
442451 let addr_checked = addr. clone ( ) . assume_checked ( ) ;
443- let txid = cl. send_to_address ( & addr. clone ( ) . assume_checked ( ) , btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
444- let unspent = cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , None ) . unwrap ( ) ;
452+ let txid = cl
453+ . send_to_address ( & addr. clone ( ) . assume_checked ( ) , btc ( 1 ) , None , None , None , None , None , None )
454+ . unwrap ( ) ;
455+ let unspent = cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , None ) . unwrap ( ) ;
445456 assert_eq ! ( unspent[ 0 ] . txid, txid) ;
446457 assert_eq ! ( unspent[ 0 ] . address. as_ref( ) , Some ( & addr) ) ;
447458 assert_eq ! ( unspent[ 0 ] . amount, btc( 1 ) ) ;
448459
449- let txid = cl. send_to_address ( & addr_checked, btc ( 7 ) , None , None , None , None , None , None ) . unwrap ( ) ;
460+ let txid =
461+ cl. send_to_address ( & addr_checked, btc ( 7 ) , None , None , None , None , None , None ) . unwrap ( ) ;
450462 let options = json:: ListUnspentQueryOptions {
451463 minimum_amount : Some ( btc ( 7 ) ) ,
452464 maximum_amount : Some ( btc ( 7 ) ) ,
453465 ..Default :: default ( )
454466 } ;
455- let unspent = cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , Some ( options) ) . unwrap ( ) ;
467+ let unspent =
468+ cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , Some ( options) ) . unwrap ( ) ;
456469 assert_eq ! ( unspent. len( ) , 1 ) ;
457470 assert_eq ! ( unspent[ 0 ] . txid, txid) ;
458471 assert_eq ! ( unspent[ 0 ] . address. as_ref( ) , Some ( & addr) ) ;
@@ -478,7 +491,9 @@ fn test_get_raw_transaction(cl: &Client) {
478491 let info = cl. get_raw_transaction_info ( & txid, None ) . unwrap ( ) ;
479492 assert_eq ! ( info. txid, txid) ;
480493
481- let blocks = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
494+ let blocks = cl
495+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
496+ . unwrap ( ) ;
482497 let _ = cl. get_raw_transaction_info ( & txid, Some ( & blocks[ 0 ] ) ) . unwrap ( ) ;
483498}
484499
@@ -534,7 +549,9 @@ fn test_get_tx_out_proof(cl: &Client) {
534549 cl. send_to_address ( & RANDOM_ADDRESS , btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
535550 let txid2 =
536551 cl. send_to_address ( & RANDOM_ADDRESS , btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
537- let blocks = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
552+ let blocks = cl
553+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
554+ . unwrap ( ) ;
538555 let proof = cl. get_tx_out_proof ( & [ txid1, txid2] , Some ( & blocks[ 0 ] ) ) . unwrap ( ) ;
539556 assert ! ( !proof. is_empty( ) ) ;
540557}
@@ -561,7 +578,9 @@ fn test_lock_unspent_unlock_unspent(cl: &Client) {
561578}
562579
563580fn test_get_block_filter ( cl : & Client ) {
564- let blocks = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
581+ let blocks = cl
582+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
583+ . unwrap ( ) ;
565584 if version ( ) >= 190000 {
566585 let _ = cl. get_block_filter ( & blocks[ 0 ] ) . unwrap ( ) ;
567586 } else {
@@ -632,7 +651,12 @@ fn test_sign_raw_transaction_with_send_raw_transaction(cl: &Client) {
632651 } ;
633652
634653 let res = cl
635- . sign_raw_transaction_with_key ( & tx, & [ sk] , None , Some ( sighash:: EcdsaSighashType :: All . into ( ) ) )
654+ . sign_raw_transaction_with_key (
655+ & tx,
656+ & [ sk] ,
657+ None ,
658+ Some ( sighash:: EcdsaSighashType :: All . into ( ) ) ,
659+ )
636660 . unwrap ( ) ;
637661 assert ! ( res. complete) ;
638662 let _ = cl. send_raw_transaction ( & res. transaction ( ) . unwrap ( ) ) . unwrap ( ) ;
@@ -1277,9 +1301,7 @@ fn test_getblocktemplate(cl: &Client) {
12771301fn test_unloadwallet ( cl : & Client ) {
12781302 cl. create_wallet ( "testunloadwallet" , None , None , None , None ) . unwrap ( ) ;
12791303
1280- let res = new_wallet_client ( "testunloadwallet" )
1281- . unload_wallet ( None )
1282- . unwrap ( ) ;
1304+ let res = new_wallet_client ( "testunloadwallet" ) . unload_wallet ( None ) . unwrap ( ) ;
12831305
12841306 if version ( ) >= 210000 {
12851307 assert ! ( res. is_some( ) ) ;
@@ -1337,18 +1359,21 @@ fn test_get_zmq_notifications(cl: &Client) {
13371359 }
13381360 } ) ;
13391361
1340- assert ! ( zmq_info == vec![
1341- GetZmqNotificationsResult {
1342- notification_type: "pubrawblock" . to_owned( ) ,
1343- address: "tcp://0.0.0.0:28332" . to_owned( ) ,
1344- hwm: 1000
1345- } ,
1346- GetZmqNotificationsResult {
1347- notification_type: "pubrawtx" . to_owned( ) ,
1348- address: "tcp://0.0.0.0:28333" . to_owned( ) ,
1349- hwm: 1000
1350- } ,
1351- ] ) ;
1362+ assert ! (
1363+ zmq_info
1364+ == vec![
1365+ GetZmqNotificationsResult {
1366+ notification_type: "pubrawblock" . to_owned( ) ,
1367+ address: "tcp://0.0.0.0:28332" . to_owned( ) ,
1368+ hwm: 1000
1369+ } ,
1370+ GetZmqNotificationsResult {
1371+ notification_type: "pubrawtx" . to_owned( ) ,
1372+ address: "tcp://0.0.0.0:28333" . to_owned( ) ,
1373+ hwm: 1000
1374+ } ,
1375+ ]
1376+ ) ;
13521377}
13531378
13541379fn test_stop ( cl : Client ) {
0 commit comments