File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -394,6 +394,9 @@ macro_rules! bdk_blockchain_tests {
394
394
395
395
#[ test]
396
396
fn test_sync_simple( ) {
397
+ use std:: ops:: Deref ;
398
+ use crate :: database:: Database ;
399
+
397
400
let ( wallet, descriptors, mut test_client) = init_single_sig( ) ;
398
401
399
402
let tx = testutils! {
@@ -402,7 +405,13 @@ macro_rules! bdk_blockchain_tests {
402
405
println!( "{:?}" , tx) ;
403
406
let txid = test_client. receive( tx) ;
404
407
408
+ // the RPC blockchain needs to call `sync()` during initialization to import the
409
+ // addresses (see `init_single_sig()`), so we skip this assertion
410
+ #[ cfg( not( feature = "test-rpc" ) ) ]
411
+ assert!( wallet. database( ) . deref( ) . get_sync_time( ) . unwrap( ) . is_none( ) , "initial sync_time not none" ) ;
412
+
405
413
wallet. sync( noop_progress( ) , None ) . unwrap( ) ;
414
+ assert!( wallet. database( ) . deref( ) . get_sync_time( ) . unwrap( ) . is_some( ) , "sync_time hasn't been updated" ) ;
406
415
407
416
assert_eq!( wallet. get_balance( ) . unwrap( ) , 50_000 , "incorrect balance" ) ;
408
417
assert_eq!( wallet. list_unspent( ) . unwrap( ) [ 0 ] . keychain, KeychainKind :: External , "incorrect keychain kind" ) ;
Original file line number Diff line number Diff line change @@ -1554,6 +1554,15 @@ where
1554
1554
}
1555
1555
}
1556
1556
1557
+ let last_sync_time = ConfirmationTime {
1558
+ height : maybe_await ! ( self . client. get_height( ) ) ?,
1559
+ timestamp : time:: get_timestamp ( ) ,
1560
+ } ;
1561
+ debug ! ( "Saving `last_sync_time` = {:?}" , last_sync_time) ;
1562
+ self . database
1563
+ . borrow_mut ( )
1564
+ . set_last_sync_time ( last_sync_time) ?;
1565
+
1557
1566
Ok ( ( ) )
1558
1567
}
1559
1568
You can’t perform that action at this time.
0 commit comments