@@ -527,6 +527,12 @@ func TestChangeWalletPasswordNewRootKey(t *testing.T) {
527
527
t .Fatal ("file exists but it shouldn't" )
528
528
}
529
529
}
530
+
531
+ // Close the old db first.
532
+ require .NoError (t , store .Backend .Close ())
533
+
534
+ // Check that the new password can be used to open the db.
535
+ assertPasswordChanged (t , testDir , req .NewPassword )
530
536
}
531
537
532
538
// TestChangeWalletPasswordStateless checks that trying to change the password
@@ -630,6 +636,12 @@ func TestChangeWalletPasswordStateless(t *testing.T) {
630
636
case <- time .After (defaultTestTimeout ):
631
637
t .Fatalf ("ChangePassword timed out" )
632
638
}
639
+
640
+ // Close the old db first.
641
+ require .NoError (t , store .Backend .Close ())
642
+
643
+ // Check that the new password can be used to open the db.
644
+ assertPasswordChanged (t , testDir , req .NewPassword )
633
645
}
634
646
635
647
func doChangePassword (service * walletunlocker.UnlockerService ,
@@ -653,3 +665,21 @@ func doChangePassword(service *walletunlocker.UnlockerService,
653
665
654
666
close (errChan )
655
667
}
668
+
669
+ // assertPasswordChanged asserts that the new password can be used to open the
670
+ // store.
671
+ func assertPasswordChanged (t * testing.T , testDir string , newPassword []byte ) {
672
+ // Open it and read the root key with the new password.
673
+ store , err := openOrCreateTestMacStore (
674
+ testDir , & newPassword , testNetParams ,
675
+ )
676
+ require .NoError (t , err )
677
+
678
+ // Assert that we can read the root key.
679
+ _ , _ , err = store .RootKey (defaultRootKeyIDContext )
680
+ require .NoError (t , err )
681
+
682
+ // Close the db once done.
683
+ require .NoError (t , store .Close ())
684
+ require .NoError (t , store .Backend .Close ())
685
+ }
0 commit comments