Skip to content
Permalink
Browse files

remove 'suchThat' in 'Arbitrary' instance for 'Passphrase "seed"'

'suchThat' is usually not a good idea as it forces the generators to retry and retry and make them
needlessly long. Instead, picking better bounds and reviewing how bytes are generated makes the instance
easier to read and, faster
  • Loading branch information...
KtorZ committed Jun 12, 2019
1 parent 937edf4 commit 5b4dfd94990097e16a731b9101ee1d4870c5b75e
Showing with 3 additions and 8 deletions.
  1. +3 −8 lib/core/test/unit/Cardano/Wallet/Primitive/AddressDerivationSpec.hs
@@ -62,7 +62,7 @@ import Test.QuickCheck
, elements
, expectFailure
, property
, suchThat
, vectorOf
, (.&&.)
, (===)
, (==>)
@@ -343,13 +343,8 @@ instance {-# OVERLAPS #-} Arbitrary (Passphrase "encryption") where

instance {-# OVERLAPS #-} Arbitrary (Passphrase "seed") where
arbitrary = do
n <- choose (5, 255)
bytes <-
T.encodeUtf8 . T.pack <$> replicateM n arbitraryPrintableChar
`suchThat`
(\bs ->
let bsLength = (BS.length . T.encodeUtf8 . T.pack) bs
in bsLength >= 16 && bsLength <= 255)
n <- choose (16, 64)
bytes <- BS.pack <$> vectorOf n arbitrary
return $ Passphrase $ BA.convert bytes

instance Arbitrary ChangeChain where

0 comments on commit 5b4dfd9

Please sign in to comment.
You can’t perform that action at this time.