44
55#![ allow( non_snake_case) ] // Test names intentionally use double underscore.
66
7+ use bitcoin:: hex;
8+ use bitcoin:: consensus:: encode;
79use integration_test:: { Node , NodeExt as _, Wallet } ;
810use node:: client:: client_sync;
911use node:: vtype:: * ; // All the version specific types.
@@ -38,8 +40,8 @@ fn blockchain__dump_tx_out_set__modelled() {
3840fn blockchain__get_best_block_hash__modelled ( ) {
3941 let node = Node :: with_wallet ( Wallet :: None , & [ ] ) ;
4042
41- let json = node. client . get_best_block_hash ( ) . expect ( "rpc " ) ;
42- let model: Result < mtype:: GetBestBlockHash , _ > = json. into_model ( ) ;
43+ let json: GetBestBlockHash = node. client . get_best_block_hash ( ) . expect ( "getbestblockhash " ) ;
44+ let model: Result < mtype:: GetBestBlockHash , hex :: HexToArrayError > = json. into_model ( ) ;
4345 model. unwrap ( ) ;
4446}
4547
@@ -49,12 +51,12 @@ fn blockchain__get_block__modelled() {
4951 let block_hash = node. client . best_block_hash ( ) . expect ( "best_block_hash failed" ) ;
5052
5153 let json: GetBlockVerboseZero = node. client . get_block_verbose_zero ( block_hash) . expect ( "getblock verbose=0" ) ;
52- let model: Result < mtype:: GetBlockVerboseZero , _ > = json. into_model ( ) ;
53- model. expect ( "GetBlock into model" ) ;
54+ let model: Result < mtype:: GetBlockVerboseZero , encode :: FromHexError > = json. into_model ( ) ;
55+ model. unwrap ( ) ;
5456
5557 let json: GetBlockVerboseOne = node. client . get_block_verbose_one ( block_hash) . expect ( "getblock verbose=1" ) ;
5658 let model: Result < mtype:: GetBlockVerboseOne , GetBlockVerboseOneError > = json. into_model ( ) ;
57- model. expect ( "GetBlockVerbose into model" ) ;
59+ model. unwrap ( ) ;
5860
5961 // TODO: Test getblock 2
6062 // let json = node.client.get_block_with_verbosity(block_hash, 2).expect("getblock verbosity 2");
@@ -126,7 +128,7 @@ fn blockchain__get_block_hash__modelled() {
126128 let node = Node :: with_wallet ( Wallet :: None , & [ ] ) ;
127129
128130 let json: GetBlockHash = node. client . get_block_hash ( 0 ) . expect ( "getblockhash" ) ;
129- let model: Result < mtype:: GetBlockHash , _ > = json. into_model ( ) ;
131+ let model: Result < mtype:: GetBlockHash , hex :: HexToArrayError > = json. into_model ( ) ;
130132 model. unwrap ( ) ;
131133}
132134
@@ -161,13 +163,15 @@ fn getblockstats() {
161163 let node = Node :: with_wallet ( Wallet :: Default , & [ ] ) ;
162164 node. fund_wallet ( ) ;
163165
164- let json = node. client . get_block_stats_by_height ( 1 ) . expect ( "getblockstats" ) ;
165- json. into_model ( ) . unwrap ( ) ;
166+ let json: GetBlockStats = node. client . get_block_stats_by_height ( 1 ) . expect ( "getblockstats" ) ;
167+ let model: Result < mtype:: GetBlockStats , GetBlockStatsError > = json. into_model ( ) ;
168+ model. unwrap ( ) ;
166169
167170 // No need for explicit types, used explicitly in test below.
168171 let block_hash = node. client . best_block_hash ( ) . expect ( "best_block_hash failed" ) ;
169- let json = node. client . get_block_stats_by_block_hash ( & block_hash) . expect ( "getblockstats" ) ;
170- json. into_model ( ) . unwrap ( ) ;
172+ let json: GetBlockStats = node. client . get_block_stats_by_block_hash ( & block_hash) . expect ( "getblockstats" ) ;
173+ let model: Result < mtype:: GetBlockStats , GetBlockStatsError > = json. into_model ( ) ;
174+ model. unwrap ( ) ;
171175}
172176
173177fn getblockstats_txindex ( ) {
@@ -177,12 +181,13 @@ fn getblockstats_txindex() {
177181 // Get block stats by height.
178182 let json: GetBlockStats = node. client . get_block_stats_by_height ( 101 ) . expect ( "getblockstats" ) ;
179183 let model: Result < mtype:: GetBlockStats , GetBlockStatsError > = json. into_model ( ) ;
180- model. expect ( "GetBlockStats into model" ) ;
184+ model. unwrap ( ) ;
181185
182186 // Get block stats by block hash.
183187 let block_hash = node. client . best_block_hash ( ) . expect ( "best_block_hash failed" ) ;
184- let json = node. client . get_block_stats_by_block_hash ( & block_hash) . expect ( "getblockstats" ) ;
185- json. into_model ( ) . unwrap ( ) ;
188+ let json: GetBlockStats = node. client . get_block_stats_by_block_hash ( & block_hash) . expect ( "getblockstats" ) ;
189+ let model: Result < mtype:: GetBlockStats , GetBlockStatsError > = json. into_model ( ) ;
190+ model. unwrap ( ) ;
186191}
187192
188193#[ test]
@@ -193,7 +198,7 @@ fn blockchain__get_chain_states__modelled() {
193198 let ( _address, _tx) = node. create_mined_transaction ( ) ;
194199
195200 let json: GetChainStates = node. client . get_chain_states ( ) . expect ( "getchainstates" ) ;
196- let model: Result < mtype:: GetChainStates , _ > = json. into_model ( ) ;
201+ let model: Result < mtype:: GetChainStates , GetChainStatesError > = json. into_model ( ) ;
197202 let chain_states = model. unwrap ( ) ;
198203
199204 assert ! ( chain_states. chain_states[ 0 ] . blocks > 0 ) ;
@@ -255,7 +260,7 @@ fn blockchain__get_mempool_ancestors__modelled() {
255260
256261 let json: GetMempoolAncestors =
257262 node. client . get_mempool_ancestors ( child_txid) . expect ( "getmempoolancestors" ) ;
258- let model: Result < mtype:: GetMempoolAncestors , _ > = json. into_model ( ) ;
263+ let model: Result < mtype:: GetMempoolAncestors , hex :: HexToArrayError > = json. into_model ( ) ;
259264 let ancestors = model. unwrap ( ) ;
260265
261266 assert ! ( ancestors. 0 . contains( & parent_txid) ) ;
@@ -272,7 +277,7 @@ fn blockchain__get_mempool_ancestors_verbose__modelled() {
272277 . client
273278 . get_mempool_ancestors_verbose ( child_txid)
274279 . expect ( "getmempoolancestors verbose" ) ;
275- let model: Result < mtype:: GetMempoolAncestorsVerbose , _ > = json. into_model ( ) ;
280+ let model: Result < mtype:: GetMempoolAncestorsVerbose , MapMempoolEntryError > = json. into_model ( ) ;
276281 let ancestors = model. unwrap ( ) ;
277282
278283 assert ! ( ancestors. 0 . contains_key( & parent_txid) ) ;
@@ -287,7 +292,7 @@ fn blockchain__get_mempool_descendants__modelled() {
287292
288293 let json: GetMempoolDescendants =
289294 node. client . get_mempool_descendants ( parent_txid) . expect ( "getmempooldescendants" ) ;
290- let model: Result < mtype:: GetMempoolDescendants , _ > = json. into_model ( ) ;
295+ let model: Result < mtype:: GetMempoolDescendants , hex :: HexToArrayError > = json. into_model ( ) ;
291296 let descendants = model. unwrap ( ) ;
292297
293298 assert ! ( descendants. 0 . contains( & child_txid) ) ;
@@ -304,7 +309,7 @@ fn blockchain__get_mempool_descendants_verbose__modelled() {
304309 . client
305310 . get_mempool_descendants_verbose ( parent_txid)
306311 . expect ( "getmempooldescendants verbose" ) ;
307- let model: Result < mtype:: GetMempoolDescendantsVerbose , _ > = json. into_model ( ) ;
312+ let model: Result < mtype:: GetMempoolDescendantsVerbose , MapMempoolEntryError > = json. into_model ( ) ;
308313 let descendants = model. unwrap ( ) ;
309314
310315 assert ! ( descendants. 0 . contains_key( & child_txid) ) ;
@@ -343,7 +348,7 @@ fn blockchain__get_raw_mempool__modelled() {
343348
344349 // verbose = false
345350 let json: GetRawMempool = node. client . get_raw_mempool ( ) . expect ( "getrawmempool" ) ;
346- let model: Result < mtype:: GetRawMempool , _ > = json. clone ( ) . into_model ( ) ;
351+ let model: Result < mtype:: GetRawMempool , hex :: HexToArrayError > = json. clone ( ) . into_model ( ) ;
347352 let mempool = model. unwrap ( ) ;
348353 // Sanity check.
349354 assert_eq ! ( mempool. 0 . len( ) , 1 ) ;
@@ -474,8 +479,8 @@ fn blockchain__savemempool() {
474479 }
475480}
476481
477- #[ cfg( not( feature = "v24_and_below" ) ) ]
478482#[ test]
483+ #[ cfg( not( feature = "v24_and_below" ) ) ]
479484fn blockchain__scan_blocks_modelled ( ) {
480485 let node = Node :: with_wallet ( Wallet :: None , & [ "-blockfilterindex=1" ] ) ;
481486
@@ -519,7 +524,7 @@ fn verify_tx_out_proof(node: &Node) -> Result<(), client_sync::Error> {
519524 let proof = node. client . get_tx_out_proof ( & [ txid] ) ?;
520525
521526 let json: VerifyTxOutProof = node. client . verify_tx_out_proof ( & proof) ?;
522- let model: Result < mtype:: VerifyTxOutProof , _ > = json. into_model ( ) ;
527+ let model: Result < mtype:: VerifyTxOutProof , hex :: HexToArrayError > = json. into_model ( ) ;
523528 let txids = model. unwrap ( ) ;
524529
525530 // sanity check
@@ -547,9 +552,9 @@ fn create_child_spending_parent(node: &Node, parent_txid: bitcoin::Txid) -> bitc
547552 . client
548553 . sign_raw_transaction_with_wallet ( & funded_tx)
549554 . expect ( "signrawtransactionwithwallet" ) ;
550- let model = signed. into_model ( ) . expect ( "SignRawTransactionWithWallet into model" ) ;
551- let child_txid = model . tx . compute_txid ( ) ;
552- let _ = node. client . send_raw_transaction ( & model . tx ) . expect ( "sendrawtransaction" ) ;
555+ let sign_raw_transaction = signed. into_model ( ) . expect ( "SignRawTransactionWithWallet into model" ) ;
556+ let child_txid = sign_raw_transaction . tx . compute_txid ( ) ;
557+ let _ = node. client . send_raw_transaction ( & sign_raw_transaction . tx ) . expect ( "sendrawtransaction" ) ;
553558
554559 child_txid
555560}
0 commit comments