diff --git a/walletunlocker/service_test.go b/walletunlocker/service_test.go index 0d9984174..7de2961cc 100644 --- a/walletunlocker/service_test.go +++ b/walletunlocker/service_test.go @@ -527,6 +527,12 @@ func TestChangeWalletPasswordNewRootKey(t *testing.T) { t.Fatal("file exists but it shouldn't") } } + + // Close the old db first. + require.NoError(t, store.Backend.Close()) + + // Check that the new password can be used to open the db. + assertPasswordChanged(t, testDir, req.NewPassword) } // TestChangeWalletPasswordStateless checks that trying to change the password @@ -630,6 +636,12 @@ func TestChangeWalletPasswordStateless(t *testing.T) { case <-time.After(defaultTestTimeout): t.Fatalf("ChangePassword timed out") } + + // Close the old db first. + require.NoError(t, store.Backend.Close()) + + // Check that the new password can be used to open the db. + assertPasswordChanged(t, testDir, req.NewPassword) } func doChangePassword(service *walletunlocker.UnlockerService, @@ -653,3 +665,21 @@ func doChangePassword(service *walletunlocker.UnlockerService, close(errChan) } + +// assertPasswordChanged asserts that the new password can be used to open the +// store. +func assertPasswordChanged(t *testing.T, testDir string, newPassword []byte) { + // Open it and read the root key with the new password. + store, err := openOrCreateTestMacStore( + testDir, &newPassword, testNetParams, + ) + require.NoError(t, err) + + // Assert that we can read the root key. + _, _, err = store.RootKey(defaultRootKeyIDContext) + require.NoError(t, err) + + // Close the db once done. + require.NoError(t, store.Close()) + require.NoError(t, store.Backend.Close()) +}