1
1
{-# LANGUAGE DataKinds #-}
2
+ {-# LANGUAGE LambdaCase #-}
2
3
{-# LANGUAGE TypeApplications #-}
3
4
module Test.Spec.Wallets (
4
5
spec
@@ -23,6 +24,7 @@ import qualified Cardano.Wallet.Kernel.BIP39 as BIP39
23
24
import Cardano.Wallet.Kernel.DB.HdWallet (AssuranceLevel (.. ),
24
25
HdRootId (.. ), UnknownHdRoot (.. ), WalletName (.. ),
25
26
hdRootId )
27
+ import qualified Cardano.Wallet.Kernel.DB.HdWallet as HD
26
28
import Cardano.Wallet.Kernel.DB.HdWallet.Create
27
29
(CreateHdRootError (.. ))
28
30
import Cardano.Wallet.Kernel.DB.InDb (InDb (.. ))
@@ -327,6 +329,24 @@ spec = describe "Wallets" $ do
327
329
newKey `shouldSatisfy` isJust
328
330
(fmap hash newKey) `shouldSatisfy` (not . (==) (fmap hash oldKey))
329
331
332
+ prop " correctly updates hdRootHasPassword" $ do
333
+ monadicIO $ do
334
+ newPwd <- pick arbitrary
335
+ withNewWalletFixture $ \ _ _ wallet Fixture {.. } -> do
336
+ res <- Kernel. updatePassword wallet
337
+ fixtureHdRootId
338
+ (unV1 fixtureSpendingPassword)
339
+ newPwd
340
+ let passphraseIsEmpty = newPwd == emptyPassphrase
341
+ let satisfied = \ case
342
+ HD. NoSpendingPassword -> passphraseIsEmpty
343
+ HD. HasSpendingPassword _ -> not passphraseIsEmpty
344
+ case res of
345
+ Left e -> fail (show e)
346
+ Right (_, newRoot) -> do
347
+ (newRoot ^. HD. hdRootHasPassword) `shouldSatisfy` satisfied
348
+
349
+
330
350
describe " Wallet update password (Servant)" $ do
331
351
prop " works as expected in the happy path scenario" $ withMaxSuccess 50 $ do
332
352
monadicIO $ do
0 commit comments