@@ -223,27 +223,27 @@ pub mod test {
223223
224224 use super :: * ;
225225
226- pub fn test_script_pubkey < D : Database > ( mut tree : D ) {
226+ pub fn test_script_pubkey < D : Database > ( mut db : D ) {
227227 let script = Script :: from (
228228 Vec :: < u8 > :: from_hex ( "76a91402306a7c23f3e8010de41e9e591348bb83f11daa88ac" ) . unwrap ( ) ,
229229 ) ;
230230 let path = 42 ;
231231 let keychain = KeychainKind :: External ;
232232
233- tree . set_script_pubkey ( & script, keychain, path) . unwrap ( ) ;
233+ db . set_script_pubkey ( & script, keychain, path) . unwrap ( ) ;
234234
235235 assert_eq ! (
236- tree . get_script_pubkey_from_path( keychain, path) . unwrap( ) ,
236+ db . get_script_pubkey_from_path( keychain, path) . unwrap( ) ,
237237 Some ( script. clone( ) )
238238 ) ;
239239 assert_eq ! (
240- tree . get_path_from_script_pubkey( & script) . unwrap( ) ,
240+ db . get_path_from_script_pubkey( & script) . unwrap( ) ,
241241 Some ( ( keychain, path) )
242242 ) ;
243243 }
244244
245- pub fn test_batch_script_pubkey < D : BatchDatabase > ( mut tree : D ) {
246- let mut batch = tree . begin_batch ( ) ;
245+ pub fn test_batch_script_pubkey < D : BatchDatabase > ( mut db : D ) {
246+ let mut batch = db . begin_batch ( ) ;
247247
248248 let script = Script :: from (
249249 Vec :: < u8 > :: from_hex ( "76a91402306a7c23f3e8010de41e9e591348bb83f11daa88ac" ) . unwrap ( ) ,
@@ -254,50 +254,50 @@ pub mod test {
254254 batch. set_script_pubkey ( & script, keychain, path) . unwrap ( ) ;
255255
256256 assert_eq ! (
257- tree . get_script_pubkey_from_path( keychain, path) . unwrap( ) ,
257+ db . get_script_pubkey_from_path( keychain, path) . unwrap( ) ,
258258 None
259259 ) ;
260- assert_eq ! ( tree . get_path_from_script_pubkey( & script) . unwrap( ) , None ) ;
260+ assert_eq ! ( db . get_path_from_script_pubkey( & script) . unwrap( ) , None ) ;
261261
262- tree . commit_batch ( batch) . unwrap ( ) ;
262+ db . commit_batch ( batch) . unwrap ( ) ;
263263
264264 assert_eq ! (
265- tree . get_script_pubkey_from_path( keychain, path) . unwrap( ) ,
265+ db . get_script_pubkey_from_path( keychain, path) . unwrap( ) ,
266266 Some ( script. clone( ) )
267267 ) ;
268268 assert_eq ! (
269- tree . get_path_from_script_pubkey( & script) . unwrap( ) ,
269+ db . get_path_from_script_pubkey( & script) . unwrap( ) ,
270270 Some ( ( keychain, path) )
271271 ) ;
272272 }
273273
274- pub fn test_iter_script_pubkey < D : Database > ( mut tree : D ) {
274+ pub fn test_iter_script_pubkey < D : Database > ( mut db : D ) {
275275 let script = Script :: from (
276276 Vec :: < u8 > :: from_hex ( "76a91402306a7c23f3e8010de41e9e591348bb83f11daa88ac" ) . unwrap ( ) ,
277277 ) ;
278278 let path = 42 ;
279279 let keychain = KeychainKind :: External ;
280280
281- tree . set_script_pubkey ( & script, keychain, path) . unwrap ( ) ;
281+ db . set_script_pubkey ( & script, keychain, path) . unwrap ( ) ;
282282
283- assert_eq ! ( tree . iter_script_pubkeys( None ) . unwrap( ) . len( ) , 1 ) ;
283+ assert_eq ! ( db . iter_script_pubkeys( None ) . unwrap( ) . len( ) , 1 ) ;
284284 }
285285
286- pub fn test_del_script_pubkey < D : Database > ( mut tree : D ) {
286+ pub fn test_del_script_pubkey < D : Database > ( mut db : D ) {
287287 let script = Script :: from (
288288 Vec :: < u8 > :: from_hex ( "76a91402306a7c23f3e8010de41e9e591348bb83f11daa88ac" ) . unwrap ( ) ,
289289 ) ;
290290 let path = 42 ;
291291 let keychain = KeychainKind :: External ;
292292
293- tree . set_script_pubkey ( & script, keychain, path) . unwrap ( ) ;
294- assert_eq ! ( tree . iter_script_pubkeys( None ) . unwrap( ) . len( ) , 1 ) ;
293+ db . set_script_pubkey ( & script, keychain, path) . unwrap ( ) ;
294+ assert_eq ! ( db . iter_script_pubkeys( None ) . unwrap( ) . len( ) , 1 ) ;
295295
296- tree . del_script_pubkey_from_path ( keychain, path) . unwrap ( ) ;
297- assert_eq ! ( tree . iter_script_pubkeys( None ) . unwrap( ) . len( ) , 0 ) ;
296+ db . del_script_pubkey_from_path ( keychain, path) . unwrap ( ) ;
297+ assert_eq ! ( db . iter_script_pubkeys( None ) . unwrap( ) . len( ) , 0 ) ;
298298 }
299299
300- pub fn test_utxo < D : Database > ( mut tree : D ) {
300+ pub fn test_utxo < D : Database > ( mut db : D ) {
301301 let outpoint = OutPoint :: from_str (
302302 "5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456:0" ,
303303 )
@@ -316,21 +316,21 @@ pub mod test {
316316 is_spent : true ,
317317 } ;
318318
319- tree . set_utxo ( & utxo) . unwrap ( ) ;
320- tree . set_utxo ( & utxo) . unwrap ( ) ;
321- assert_eq ! ( tree . iter_utxos( ) . unwrap( ) . len( ) , 1 ) ;
322- assert_eq ! ( tree . get_utxo( & outpoint) . unwrap( ) , Some ( utxo) ) ;
319+ db . set_utxo ( & utxo) . unwrap ( ) ;
320+ db . set_utxo ( & utxo) . unwrap ( ) ;
321+ assert_eq ! ( db . iter_utxos( ) . unwrap( ) . len( ) , 1 ) ;
322+ assert_eq ! ( db . get_utxo( & outpoint) . unwrap( ) , Some ( utxo) ) ;
323323 }
324324
325- pub fn test_raw_tx < D : Database > ( mut tree : D ) {
325+ pub fn test_raw_tx < D : Database > ( mut db : D ) {
326326 let hex_tx = Vec :: < u8 > :: from_hex ( "02000000000101f58c18a90d7a76b30c7e47d4e817adfdd79a6a589a615ef36e360f913adce2cd0000000000feffffff0210270000000000001600145c9a1816d38db5cbdd4b067b689dc19eb7d930e2cf70aa2b080000001600140f48b63160043047f4f60f7f8f551f80458f693f024730440220413f42b7bc979945489a38f5221e5527d4b8e3aa63eae2099e01945896ad6c10022024ceec492d685c31d8adb64e935a06933877c5ae0e21f32efe029850914c5bad012102361caae96f0e9f3a453d354bb37a5c3244422fb22819bf0166c0647a38de39f21fca2300" ) . unwrap ( ) ;
327327 let mut tx: Transaction = deserialize ( & hex_tx) . unwrap ( ) ;
328328
329- tree . set_raw_tx ( & tx) . unwrap ( ) ;
329+ db . set_raw_tx ( & tx) . unwrap ( ) ;
330330
331331 let txid = tx. txid ( ) ;
332332
333- assert_eq ! ( tree . get_raw_tx( & txid) . unwrap( ) , Some ( tx. clone( ) ) ) ;
333+ assert_eq ! ( db . get_raw_tx( & txid) . unwrap( ) , Some ( tx. clone( ) ) ) ;
334334
335335 // mutate transaction's witnesses
336336 for tx_in in tx. input . iter_mut ( ) {
@@ -342,14 +342,14 @@ pub mod test {
342342 // verify that mutation was successful
343343 assert_ne ! ( hex_tx, updated_hex_tx) ;
344344
345- tree . set_raw_tx ( & tx) . unwrap ( ) ;
345+ db . set_raw_tx ( & tx) . unwrap ( ) ;
346346
347347 let txid = tx. txid ( ) ;
348348
349- assert_eq ! ( tree . get_raw_tx( & txid) . unwrap( ) , Some ( tx) ) ;
349+ assert_eq ! ( db . get_raw_tx( & txid) . unwrap( ) , Some ( tx) ) ;
350350 }
351351
352- pub fn test_tx < D : Database > ( mut tree : D ) {
352+ pub fn test_tx < D : Database > ( mut db : D ) {
353353 let hex_tx = Vec :: < u8 > :: from_hex ( "0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000" ) . unwrap ( ) ;
354354 let tx: Transaction = deserialize ( & hex_tx) . unwrap ( ) ;
355355 let txid = tx. txid ( ) ;
@@ -365,28 +365,28 @@ pub mod test {
365365 } ) ,
366366 } ;
367367
368- tree . set_tx ( & tx_details) . unwrap ( ) ;
368+ db . set_tx ( & tx_details) . unwrap ( ) ;
369369
370370 // get with raw tx too
371371 assert_eq ! (
372- tree . get_tx( & tx_details. txid, true ) . unwrap( ) ,
372+ db . get_tx( & tx_details. txid, true ) . unwrap( ) ,
373373 Some ( tx_details. clone( ) )
374374 ) ;
375375 // get only raw_tx
376376 assert_eq ! (
377- tree . get_raw_tx( & tx_details. txid) . unwrap( ) ,
377+ db . get_raw_tx( & tx_details. txid) . unwrap( ) ,
378378 tx_details. transaction
379379 ) ;
380380
381381 // now get without raw_tx
382382 tx_details. transaction = None ;
383383 assert_eq ! (
384- tree . get_tx( & tx_details. txid, false ) . unwrap( ) ,
384+ db . get_tx( & tx_details. txid, false ) . unwrap( ) ,
385385 Some ( tx_details)
386386 ) ;
387387 }
388388
389- pub fn test_list_transaction < D : Database > ( mut tree : D ) {
389+ pub fn test_list_transaction < D : Database > ( mut db : D ) {
390390 let hex_tx = Vec :: < u8 > :: from_hex ( "0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000" ) . unwrap ( ) ;
391391 let tx: Transaction = deserialize ( & hex_tx) . unwrap ( ) ;
392392 let txid = tx. txid ( ) ;
@@ -402,60 +402,57 @@ pub mod test {
402402 } ) ,
403403 } ;
404404
405- tree . set_tx ( & tx_details) . unwrap ( ) ;
405+ db . set_tx ( & tx_details) . unwrap ( ) ;
406406
407407 // get raw tx
408- assert_eq ! ( tree . iter_txs( true ) . unwrap( ) , vec![ tx_details. clone( ) ] ) ;
408+ assert_eq ! ( db . iter_txs( true ) . unwrap( ) , vec![ tx_details. clone( ) ] ) ;
409409
410410 // now get without raw tx
411411 tx_details. transaction = None ;
412412
413413 // get not raw tx
414- assert_eq ! ( tree . iter_txs( false ) . unwrap( ) , vec![ tx_details. clone( ) ] ) ;
414+ assert_eq ! ( db . iter_txs( false ) . unwrap( ) , vec![ tx_details. clone( ) ] ) ;
415415 }
416416
417- pub fn test_last_index < D : Database > ( mut tree : D ) {
418- tree . set_last_index ( KeychainKind :: External , 1337 ) . unwrap ( ) ;
417+ pub fn test_last_index < D : Database > ( mut db : D ) {
418+ db . set_last_index ( KeychainKind :: External , 1337 ) . unwrap ( ) ;
419419
420420 assert_eq ! (
421- tree . get_last_index( KeychainKind :: External ) . unwrap( ) ,
421+ db . get_last_index( KeychainKind :: External ) . unwrap( ) ,
422422 Some ( 1337 )
423423 ) ;
424- assert_eq ! ( tree . get_last_index( KeychainKind :: Internal ) . unwrap( ) , None ) ;
424+ assert_eq ! ( db . get_last_index( KeychainKind :: Internal ) . unwrap( ) , None ) ;
425425
426- let res = tree . increment_last_index ( KeychainKind :: External ) . unwrap ( ) ;
426+ let res = db . increment_last_index ( KeychainKind :: External ) . unwrap ( ) ;
427427 assert_eq ! ( res, 1338 ) ;
428- let res = tree . increment_last_index ( KeychainKind :: Internal ) . unwrap ( ) ;
428+ let res = db . increment_last_index ( KeychainKind :: Internal ) . unwrap ( ) ;
429429 assert_eq ! ( res, 0 ) ;
430430
431431 assert_eq ! (
432- tree . get_last_index( KeychainKind :: External ) . unwrap( ) ,
432+ db . get_last_index( KeychainKind :: External ) . unwrap( ) ,
433433 Some ( 1338 )
434434 ) ;
435- assert_eq ! (
436- tree. get_last_index( KeychainKind :: Internal ) . unwrap( ) ,
437- Some ( 0 )
438- ) ;
435+ assert_eq ! ( db. get_last_index( KeychainKind :: Internal ) . unwrap( ) , Some ( 0 ) ) ;
439436 }
440437
441- pub fn test_sync_time < D : Database > ( mut tree : D ) {
442- assert ! ( tree . get_sync_time( ) . unwrap( ) . is_none( ) ) ;
438+ pub fn test_sync_time < D : Database > ( mut db : D ) {
439+ assert ! ( db . get_sync_time( ) . unwrap( ) . is_none( ) ) ;
443440
444- tree . set_sync_time ( SyncTime {
441+ db . set_sync_time ( SyncTime {
445442 block_time : BlockTime {
446443 height : 100 ,
447444 timestamp : 1000 ,
448445 } ,
449446 } )
450447 . unwrap ( ) ;
451448
452- let extracted = tree . get_sync_time ( ) . unwrap ( ) ;
449+ let extracted = db . get_sync_time ( ) . unwrap ( ) ;
453450 assert ! ( extracted. is_some( ) ) ;
454451 assert_eq ! ( extracted. as_ref( ) . unwrap( ) . block_time. height, 100 ) ;
455452 assert_eq ! ( extracted. as_ref( ) . unwrap( ) . block_time. timestamp, 1000 ) ;
456453
457- tree . del_sync_time ( ) . unwrap ( ) ;
458- assert ! ( tree . get_sync_time( ) . unwrap( ) . is_none( ) ) ;
454+ db . del_sync_time ( ) . unwrap ( ) ;
455+ assert ! ( db . get_sync_time( ) . unwrap( ) . is_none( ) ) ;
459456 }
460457
461458 pub fn test_iter_raw_txs < D : Database > ( mut db : D ) {
0 commit comments