4
4
5
5
#![ allow( non_snake_case) ] // Test names intentionally use double underscore.
6
6
7
- use bitcoin:: hex;
8
7
use bitcoin:: consensus:: encode;
8
+ use bitcoin:: hex;
9
9
use integration_test:: { Node , NodeExt as _, Wallet } ;
10
10
use node:: client:: client_sync;
11
- use node:: vtype:: * ; // All the version specific types.
12
- use node:: mtype;
13
- use node:: { Input , Output } ;
11
+ use node:: vtype:: * ; // All the version specific types.
12
+ use node:: { mtype, Input , Output } ;
14
13
15
14
#[ test]
16
15
#[ cfg( not( feature = "v25_and_below" ) ) ]
@@ -50,11 +49,13 @@ fn blockchain__get_block__modelled() {
50
49
let node = Node :: with_wallet ( Wallet :: None , & [ ] ) ;
51
50
let block_hash = node. client . best_block_hash ( ) . expect ( "best_block_hash failed" ) ;
52
51
53
- let json: GetBlockVerboseZero = node. client . get_block_verbose_zero ( block_hash) . expect ( "getblock verbose=0" ) ;
52
+ let json: GetBlockVerboseZero =
53
+ node. client . get_block_verbose_zero ( block_hash) . expect ( "getblock verbose=0" ) ;
54
54
let model: Result < mtype:: GetBlockVerboseZero , encode:: FromHexError > = json. into_model ( ) ;
55
55
model. unwrap ( ) ;
56
56
57
- let json: GetBlockVerboseOne = node. client . get_block_verbose_one ( block_hash) . expect ( "getblock verbose=1" ) ;
57
+ let json: GetBlockVerboseOne =
58
+ node. client . get_block_verbose_one ( block_hash) . expect ( "getblock verbose=1" ) ;
58
59
let model: Result < mtype:: GetBlockVerboseOne , GetBlockVerboseOneError > = json. into_model ( ) ;
59
60
model. unwrap ( ) ;
60
61
@@ -143,7 +144,8 @@ fn blockchain__get_block_header__modelled() {
143
144
model. unwrap ( ) ;
144
145
145
146
// verbose = true
146
- let json: GetBlockHeaderVerbose = node. client . get_block_header_verbose ( & block_hash) . expect ( "getblockheader" ) ;
147
+ let json: GetBlockHeaderVerbose =
148
+ node. client . get_block_header_verbose ( & block_hash) . expect ( "getblockheader" ) ;
147
149
let model: Result < mtype:: GetBlockHeaderVerbose , GetBlockHeaderVerboseError > = json. into_model ( ) ;
148
150
model. unwrap ( ) ;
149
151
}
@@ -169,7 +171,8 @@ fn getblockstats() {
169
171
170
172
// No need for explicit types, used explicitly in test below.
171
173
let block_hash = node. client . best_block_hash ( ) . expect ( "best_block_hash failed" ) ;
172
- let json: GetBlockStats = node. client . get_block_stats_by_block_hash ( & block_hash) . expect ( "getblockstats" ) ;
174
+ let json: GetBlockStats =
175
+ node. client . get_block_stats_by_block_hash ( & block_hash) . expect ( "getblockstats" ) ;
173
176
let model: Result < mtype:: GetBlockStats , GetBlockStatsError > = json. into_model ( ) ;
174
177
model. unwrap ( ) ;
175
178
}
@@ -185,7 +188,8 @@ fn getblockstats_txindex() {
185
188
186
189
// Get block stats by block hash.
187
190
let block_hash = node. client . best_block_hash ( ) . expect ( "best_block_hash failed" ) ;
188
- let json: GetBlockStats = node. client . get_block_stats_by_block_hash ( & block_hash) . expect ( "getblockstats" ) ;
191
+ let json: GetBlockStats =
192
+ node. client . get_block_stats_by_block_hash ( & block_hash) . expect ( "getblockstats" ) ;
189
193
let model: Result < mtype:: GetBlockStats , GetBlockStatsError > = json. into_model ( ) ;
190
194
model. unwrap ( ) ;
191
195
}
@@ -228,7 +232,8 @@ fn blockchain__get_deployment_info__modelled() {
228
232
let node = Node :: with_wallet ( Wallet :: None , & [ ] ) ;
229
233
let block_hash = node. client . best_block_hash ( ) . expect ( "best_block_hash failed" ) ;
230
234
231
- let json: GetDeploymentInfo = node. client . get_deployment_info ( & block_hash) . expect ( "getdeploymentinfo" ) ;
235
+ let json: GetDeploymentInfo =
236
+ node. client . get_deployment_info ( & block_hash) . expect ( "getdeploymentinfo" ) ;
232
237
let model: Result < mtype:: GetDeploymentInfo , GetDeploymentInfoError > = json. into_model ( ) ;
233
238
model. unwrap ( ) ;
234
239
}
@@ -238,7 +243,8 @@ fn blockchain__get_deployment_info__modelled() {
238
243
fn blockchain__get_descriptor_activity__modelled ( ) {
239
244
let node = Node :: with_wallet ( Wallet :: None , & [ "-coinstatsindex=1" , "-txindex=1" ] ) ;
240
245
241
- let json: GetDescriptorActivity = node. client . get_descriptor_activity ( ) . expect ( "getdescriptoractivity" ) ;
246
+ let json: GetDescriptorActivity =
247
+ node. client . get_descriptor_activity ( ) . expect ( "getdescriptoractivity" ) ;
242
248
let model: Result < mtype:: GetDescriptorActivity , GetDescriptorActivityError > = json. into_model ( ) ;
243
249
model. unwrap ( ) ;
244
250
}
@@ -273,10 +279,8 @@ fn blockchain__get_mempool_ancestors_verbose__modelled() {
273
279
let ( _address, parent_txid) = node. create_mempool_transaction ( ) ;
274
280
let child_txid = create_child_spending_parent ( & node, parent_txid) ;
275
281
276
- let json: GetMempoolAncestorsVerbose = node
277
- . client
278
- . get_mempool_ancestors_verbose ( child_txid)
279
- . expect ( "getmempoolancestors verbose" ) ;
282
+ let json: GetMempoolAncestorsVerbose =
283
+ node. client . get_mempool_ancestors_verbose ( child_txid) . expect ( "getmempoolancestors verbose" ) ;
280
284
let model: Result < mtype:: GetMempoolAncestorsVerbose , MapMempoolEntryError > = json. into_model ( ) ;
281
285
let ancestors = model. unwrap ( ) ;
282
286
@@ -309,7 +313,8 @@ fn blockchain__get_mempool_descendants_verbose__modelled() {
309
313
. client
310
314
. get_mempool_descendants_verbose ( parent_txid)
311
315
. expect ( "getmempooldescendants verbose" ) ;
312
- let model: Result < mtype:: GetMempoolDescendantsVerbose , MapMempoolEntryError > = json. into_model ( ) ;
316
+ let model: Result < mtype:: GetMempoolDescendantsVerbose , MapMempoolEntryError > =
317
+ json. into_model ( ) ;
313
318
let descendants = model. unwrap ( ) ;
314
319
315
320
assert ! ( descendants. 0 . contains_key( & child_txid) ) ;
@@ -406,17 +411,12 @@ fn blockchain__get_tx_spending_prevout__modelled() {
406
411
let ( _address2, txid_2) = node. create_mempool_transaction ( ) ;
407
412
408
413
let inputs = vec ! [
409
- bitcoin:: OutPoint {
410
- txid: txid_1,
411
- vout: 0 ,
412
- } ,
413
- bitcoin:: OutPoint {
414
- txid: txid_2,
415
- vout: 0 ,
416
- } ,
414
+ bitcoin:: OutPoint { txid: txid_1, vout: 0 } ,
415
+ bitcoin:: OutPoint { txid: txid_2, vout: 0 } ,
417
416
] ;
418
417
419
- let json: GetTxSpendingPrevout = node. client . get_tx_spending_prevout ( & inputs) . expect ( "gettxspendingprevout" ) ;
418
+ let json: GetTxSpendingPrevout =
419
+ node. client . get_tx_spending_prevout ( & inputs) . expect ( "gettxspendingprevout" ) ;
420
420
let model: Result < mtype:: GetTxSpendingPrevout , GetTxSpendingPrevoutError > = json. into_model ( ) ;
421
421
let spending_prevout = model. unwrap ( ) ;
422
422
@@ -454,8 +454,15 @@ fn blockchain__prune_blockchain() {
454
454
let node = Node :: with_wallet ( Wallet :: Default , & [ "-prune=550" ] ) ;
455
455
let address = node. client . new_address ( ) . expect ( "Failed to get new address" ) ;
456
456
457
- let gen_result = node. client . generate_to_address ( NBLOCKS , & address) . expect ( "generate_to_address RPC call failed" ) ;
458
- assert_eq ! ( gen_result. 0 . len( ) , NBLOCKS , "generate_to_address did not return the expected number of block hashes" ) ;
457
+ let gen_result = node
458
+ . client
459
+ . generate_to_address ( NBLOCKS , & address)
460
+ . expect ( "generate_to_address RPC call failed" ) ;
461
+ assert_eq ! (
462
+ gen_result. 0 . len( ) ,
463
+ NBLOCKS ,
464
+ "generate_to_address did not return the expected number of block hashes"
465
+ ) ;
459
466
460
467
let target_height: u64 = 500 ;
461
468
@@ -487,7 +494,8 @@ fn blockchain__scan_blocks_modelled() {
487
494
// Arbitrary scan descriptor
488
495
let scan_desc = "pkh(022afc20bf379bc96a2f4e9e63ffceb8652b2b6a097f63fbee6ecec2a49a48010e)" ;
489
496
490
- let json: ScanBlocksStart = node. client . scan_blocks_start ( & [ scan_desc] ) . expect ( "scanblocks start" ) ;
497
+ let json: ScanBlocksStart =
498
+ node. client . scan_blocks_start ( & [ scan_desc] ) . expect ( "scanblocks start" ) ;
491
499
let model: Result < mtype:: ScanBlocksStart , ScanBlocksStartError > = json. into_model ( ) ;
492
500
model. unwrap ( ) ;
493
501
@@ -552,7 +560,8 @@ fn create_child_spending_parent(node: &Node, parent_txid: bitcoin::Txid) -> bitc
552
560
. client
553
561
. sign_raw_transaction_with_wallet ( & funded_tx)
554
562
. expect ( "signrawtransactionwithwallet" ) ;
555
- let sign_raw_transaction = signed. into_model ( ) . expect ( "SignRawTransactionWithWallet into model" ) ;
563
+ let sign_raw_transaction =
564
+ signed. into_model ( ) . expect ( "SignRawTransactionWithWallet into model" ) ;
556
565
let child_txid = sign_raw_transaction. tx . compute_txid ( ) ;
557
566
let _ = node. client . send_raw_transaction ( & sign_raw_transaction. tx ) . expect ( "sendrawtransaction" ) ;
558
567
0 commit comments