@@ -25,11 +25,9 @@ import Cardano.Wallet.Api.Types
2525 , WalletStyle (.. )
2626 )
2727import Cardano.Wallet.Primitive.AddressDerivation
28- ( PassphraseMaxLength (.. ), PassphraseMinLength ( .. ) )
28+ ( PassphraseMaxLength (.. ) )
2929import Cardano.Wallet.Primitive.Types
3030 ( Direction (.. ), FeePolicy (.. ), PoolId (.. ), TxStatus (.. ) )
31- import Control.Monad
32- ( forM_ )
3331import Data.Functor.Identity
3432 ( Identity (.. ) )
3533import Data.Generics.Internal.VL.Lens
@@ -476,27 +474,54 @@ spec = do
476474 [ expectField # delegation (`shouldBe` notDelegating [] )
477475 ]
478476
479- it " STAKE_POOLS_JOIN_02 - Passphrase must be correct to join" $ \ (_,_,ctx) -> do
480- (_, p: _) <- eventually " Stake pools are listed" $
481- unsafeRequest @ [ApiStakePool ] ctx Link. listStakePools Empty
482- w <- fixtureWallet ctx
483- r <- joinStakePool @ n ctx (p ^. # id ) (w, " Incorrect Passphrase" )
484- expectResponseCode HTTP. status403 r
485- expectErrorMessage errMsg403WrongPass r
477+ describe " STAKE_POOLS_JOIN_02 - Passphrase must be correct to join" $ do
478+ let verifyIt ctx wallet pass expectations = do
479+ (_, p: _) <- eventually " Stake pools are listed" $ do
480+ unsafeRequest @ [ApiStakePool ] ctx Link. listStakePools Empty
481+ w <- wallet ctx
482+ r <- joinStakePool @ n ctx (p ^. # id ) (w, pass)
483+ verify r expectations
484+
485+ it " Wallet with funds - incorrect pass" $ \ (_,_,ctx) -> do
486+ verifyIt ctx fixtureWallet
487+ " Incorrect Passphrase"
488+ [ expectResponseCode HTTP. status403
489+ , expectErrorMessage errMsg403WrongPass
490+ ]
491+
492+ it " Wallet with funds - empty pass" $ \ (_,_,ctx) -> do
493+ verifyIt ctx fixtureWallet
494+ " "
495+ [ expectResponseCode HTTP. status403
496+ , expectErrorMessage errMsg403WrongPass
497+ ]
498+
499+ it " Empty wallet - incorrect pass" $ \ (_,_,ctx) -> do
500+ verifyIt ctx emptyWallet
501+ " Incorrect Passphrase"
502+ [ expectResponseCode HTTP. status403
503+ , expectErrorMessage
504+ " I'm unable to select enough coins to pay for\
505+ \ a delegation certificate."
506+ ]
507+
508+ it " Empty wallet - empty pass" $ \ (_,_,ctx) -> do
509+ verifyIt ctx emptyWallet
510+ " "
511+ [ expectResponseCode HTTP. status403
512+ , expectErrorMessage
513+ " I'm unable to select enough coins to pay for\
514+ \ a delegation certificate."
515+ ]
486516
487517 describe " STAKE_POOLS_JOIN/QUIT_02 -\
488518 \ Passphrase must have appropriate length" $ do
489519
490- let pMax = passphraseMaxLength (Proxy @ " raw" )
491- let pMin = passphraseMinLength (Proxy @ " raw" )
492- let tooShort =
493- " passphrase is too short: expected at least 10 characters"
494- let tooLong =
520+ let pMax = passphraseMaxLength (Proxy @ " lenient" )
521+ let tooLongMsg =
495522 " passphrase is too long: expected at most 255 characters"
496- let tests =
497- [ (tooLong, replicate (pMax + 1 ) ' 1' )
498- , (tooShort, replicate (pMin - 1 ) ' 1' )
499- ]
523+ let passTooLong = replicate (pMax + 1 ) ' 1'
524+
500525 let verifyIt ctx doStakePool pass expec = do
501526 (_, p: _) <- eventually " Stake pools are listed" $ do
502527 unsafeRequest @ [ApiStakePool ] ctx Link. listStakePools Empty
@@ -505,12 +530,11 @@ spec = do
505530 expectResponseCode HTTP. status400 r
506531 expectErrorMessage expec r
507532
508- forM_ tests $ \ (expec, passphrase) -> do
509- it (" Join: " ++ expec) $ \ (_,_,ctx) -> do
510- verifyIt ctx (joinStakePool @ n ) passphrase expec
533+ it (" Join: " ++ tooLongMsg) $ \ (_,_,ctx) -> do
534+ verifyIt ctx (joinStakePool @ n ) passTooLong tooLongMsg
511535
512- it (" Quit: " ++ expec ) $ \ (_,_,ctx) -> do
513- verifyIt ctx (\ _ _ -> quitStakePool @ n ctx) passphrase expec
536+ it (" Quit: " ++ tooLongMsg ) $ \ (_,_,ctx) -> do
537+ verifyIt ctx (\ _ _ -> quitStakePool @ n ctx) passTooLong tooLongMsg
514538
515539 describe " STAKE_POOLS_JOIN/QUIT_02 - Passphrase must be text" $ do
516540 let verifyIt ctx sPoolEndp = do
0 commit comments