@@ -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 ! {
@@ -246,7 +246,8 @@ fn test_get_new_address(cl: &Client) {
246246 let addr = cl. get_new_address ( None , Some ( json:: AddressType :: Bech32 ) ) . unwrap ( ) . assume_checked ( ) ;
247247 assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2wpkh ) ) ;
248248
249- let addr = cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
249+ let addr =
250+ cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
250251 assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2sh ) ) ;
251252}
252253
@@ -257,7 +258,8 @@ fn test_get_raw_change_address(cl: &Client) {
257258 let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: Bech32 ) ) . unwrap ( ) . assume_checked ( ) ;
258259 assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2wpkh ) ) ;
259260
260- let addr = cl. get_raw_change_address ( Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
261+ let addr =
262+ cl. get_raw_change_address ( Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
261263 assert_eq ! ( addr. address_type( ) , Some ( bitcoin:: AddressType :: P2sh ) ) ;
262264}
263265
@@ -287,7 +289,9 @@ fn test_generate(cl: &Client) {
287289fn test_get_balance_generate_to_address ( cl : & Client ) {
288290 let initial = cl. get_balance ( None , None ) . unwrap ( ) ;
289291
290- let blocks = cl. generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
292+ let blocks = cl
293+ . generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
294+ . unwrap ( ) ;
291295 assert_eq ! ( blocks. len( ) , 500 ) ;
292296 assert_ne ! ( cl. get_balance( None , None ) . unwrap( ) , initial) ;
293297}
@@ -296,7 +300,9 @@ fn test_get_balances_generate_to_address(cl: &Client) {
296300 if version ( ) >= 190000 {
297301 let initial = cl. get_balances ( ) . unwrap ( ) ;
298302
299- let blocks = cl. generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
303+ let blocks = cl
304+ . generate_to_address ( 500 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
305+ . unwrap ( ) ;
300306 assert_eq ! ( blocks. len( ) , 500 ) ;
301307 assert_ne ! ( cl. get_balances( ) . unwrap( ) , initial) ;
302308 }
@@ -372,7 +378,8 @@ fn test_get_address_info(cl: &Client) {
372378 let info = cl. get_address_info ( & addr) . unwrap ( ) ;
373379 assert ! ( !info. witness_program. unwrap( ) . is_empty( ) ) ;
374380
375- let addr = cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
381+ let addr =
382+ cl. get_new_address ( None , Some ( json:: AddressType :: P2shSegwit ) ) . unwrap ( ) . assume_checked ( ) ;
376383 let info = cl. get_address_info ( & addr) . unwrap ( ) ;
377384 assert ! ( !info. hex. unwrap( ) . is_empty( ) ) ;
378385}
@@ -428,27 +435,33 @@ fn test_get_received_by_address(cl: &Client) {
428435 let _ = cl. send_to_address ( & addr, btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
429436 assert_eq ! ( cl. get_received_by_address( & addr, Some ( 0 ) ) . unwrap( ) , btc( 1 ) ) ;
430437 assert_eq ! ( cl. get_received_by_address( & addr, Some ( 1 ) ) . unwrap( ) , btc( 0 ) ) ;
431- let _ = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
438+ let _ = cl
439+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
440+ . unwrap ( ) ;
432441 assert_eq ! ( cl. get_received_by_address( & addr, Some ( 6 ) ) . unwrap( ) , btc( 1 ) ) ;
433442 assert_eq ! ( cl. get_received_by_address( & addr, None ) . unwrap( ) , btc( 1 ) ) ;
434443}
435444
436445fn test_list_unspent ( cl : & Client ) {
437446 let addr = cl. get_new_address ( None , None ) . unwrap ( ) ;
438447 let addr_checked = addr. clone ( ) . assume_checked ( ) ;
439- let txid = cl. send_to_address ( & addr. clone ( ) . assume_checked ( ) , btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
440- let unspent = cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , None ) . unwrap ( ) ;
448+ let txid = cl
449+ . send_to_address ( & addr. clone ( ) . assume_checked ( ) , btc ( 1 ) , None , None , None , None , None , None )
450+ . unwrap ( ) ;
451+ let unspent = cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , None ) . unwrap ( ) ;
441452 assert_eq ! ( unspent[ 0 ] . txid, txid) ;
442453 assert_eq ! ( unspent[ 0 ] . address. as_ref( ) , Some ( & addr) ) ;
443454 assert_eq ! ( unspent[ 0 ] . amount, btc( 1 ) ) ;
444455
445- let txid = cl. send_to_address ( & addr_checked, btc ( 7 ) , None , None , None , None , None , None ) . unwrap ( ) ;
456+ let txid =
457+ cl. send_to_address ( & addr_checked, btc ( 7 ) , None , None , None , None , None , None ) . unwrap ( ) ;
446458 let options = json:: ListUnspentQueryOptions {
447459 minimum_amount : Some ( btc ( 7 ) ) ,
448460 maximum_amount : Some ( btc ( 7 ) ) ,
449461 ..Default :: default ( )
450462 } ;
451- let unspent = cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , Some ( options) ) . unwrap ( ) ;
463+ let unspent =
464+ cl. list_unspent ( Some ( 0 ) , None , Some ( & [ & addr_checked] ) , None , Some ( options) ) . unwrap ( ) ;
452465 assert_eq ! ( unspent. len( ) , 1 ) ;
453466 assert_eq ! ( unspent[ 0 ] . txid, txid) ;
454467 assert_eq ! ( unspent[ 0 ] . address. as_ref( ) , Some ( & addr) ) ;
@@ -474,7 +487,9 @@ fn test_get_raw_transaction(cl: &Client) {
474487 let info = cl. get_raw_transaction_info ( & txid, None ) . unwrap ( ) ;
475488 assert_eq ! ( info. txid, txid) ;
476489
477- let blocks = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
490+ let blocks = cl
491+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
492+ . unwrap ( ) ;
478493 let _ = cl. get_raw_transaction_info ( & txid, Some ( & blocks[ 0 ] ) ) . unwrap ( ) ;
479494}
480495
@@ -530,7 +545,9 @@ fn test_get_tx_out_proof(cl: &Client) {
530545 cl. send_to_address ( & RANDOM_ADDRESS , btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
531546 let txid2 =
532547 cl. send_to_address ( & RANDOM_ADDRESS , btc ( 1 ) , None , None , None , None , None , None ) . unwrap ( ) ;
533- let blocks = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
548+ let blocks = cl
549+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
550+ . unwrap ( ) ;
534551 let proof = cl. get_tx_out_proof ( & [ txid1, txid2] , Some ( & blocks[ 0 ] ) ) . unwrap ( ) ;
535552 assert ! ( !proof. is_empty( ) ) ;
536553}
@@ -557,7 +574,9 @@ fn test_lock_unspent_unlock_unspent(cl: &Client) {
557574}
558575
559576fn test_get_block_filter ( cl : & Client ) {
560- let blocks = cl. generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) ) . unwrap ( ) ;
577+ let blocks = cl
578+ . generate_to_address ( 7 , & cl. get_new_address ( None , None ) . unwrap ( ) . assume_checked ( ) )
579+ . unwrap ( ) ;
561580 if version ( ) >= 190000 {
562581 let _ = cl. get_block_filter ( & blocks[ 0 ] ) . unwrap ( ) ;
563582 } else {
@@ -628,7 +647,12 @@ fn test_sign_raw_transaction_with_send_raw_transaction(cl: &Client) {
628647 } ;
629648
630649 let res = cl
631- . sign_raw_transaction_with_key ( & tx, & [ sk] , None , Some ( sighash:: EcdsaSighashType :: All . into ( ) ) )
650+ . sign_raw_transaction_with_key (
651+ & tx,
652+ & [ sk] ,
653+ None ,
654+ Some ( sighash:: EcdsaSighashType :: All . into ( ) ) ,
655+ )
632656 . unwrap ( ) ;
633657 assert ! ( res. complete) ;
634658 let _ = cl. send_raw_transaction ( & res. transaction ( ) . unwrap ( ) ) . unwrap ( ) ;
@@ -1273,9 +1297,7 @@ fn test_getblocktemplate(cl: &Client) {
12731297fn test_unloadwallet ( cl : & Client ) {
12741298 cl. create_wallet ( "testunloadwallet" , None , None , None , None ) . unwrap ( ) ;
12751299
1276- let res = new_wallet_client ( "testunloadwallet" )
1277- . unload_wallet ( None )
1278- . unwrap ( ) ;
1300+ let res = new_wallet_client ( "testunloadwallet" ) . unload_wallet ( None ) . unwrap ( ) ;
12791301
12801302 if version ( ) >= 210000 {
12811303 assert ! ( res. is_some( ) ) ;
@@ -1308,18 +1330,21 @@ fn test_get_zmq_notifications(cl: &Client) {
13081330 }
13091331 } ) ;
13101332
1311- assert ! ( zmq_info == vec![
1312- GetZmqNotificationsResult {
1313- notification_type: "pubrawblock" . to_owned( ) ,
1314- address: "tcp://0.0.0.0:28332" . to_owned( ) ,
1315- hwm: 1000
1316- } ,
1317- GetZmqNotificationsResult {
1318- notification_type: "pubrawtx" . to_owned( ) ,
1319- address: "tcp://0.0.0.0:28333" . to_owned( ) ,
1320- hwm: 1000
1321- } ,
1322- ] ) ;
1333+ assert ! (
1334+ zmq_info
1335+ == vec![
1336+ GetZmqNotificationsResult {
1337+ notification_type: "pubrawblock" . to_owned( ) ,
1338+ address: "tcp://0.0.0.0:28332" . to_owned( ) ,
1339+ hwm: 1000
1340+ } ,
1341+ GetZmqNotificationsResult {
1342+ notification_type: "pubrawtx" . to_owned( ) ,
1343+ address: "tcp://0.0.0.0:28333" . to_owned( ) ,
1344+ hwm: 1000
1345+ } ,
1346+ ]
1347+ ) ;
13231348}
13241349
13251350fn test_stop ( cl : Client ) {
0 commit comments