Skip to content

Commit

Permalink
Slightly increase the probability of generating empty UTxO indices.
Browse files Browse the repository at this point in the history
This change alters the `genUTxOIndexSmall` generator to slightly
increase the probability of generating empty and singleton UTxO indices.

This is useful because it allows greater coverage of boundary conditions
that occur only when indices are very small.
  • Loading branch information
jonathanknowles committed Jan 14, 2021
1 parent fe2c1d9 commit 38e8bd2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/core/src/Cardano/Wallet/Primitive/Types/UTxOIndex/Gen.hs
Expand Up @@ -18,15 +18,19 @@ import Cardano.Wallet.Primitive.Types.UTxOIndex
import Control.Monad
( replicateM )
import Test.QuickCheck
( Gen, choose, shrinkList )
( Gen, choose, frequency, shrinkList )
import Test.QuickCheck.Extra
( shrinkInterleaved )

import qualified Cardano.Wallet.Primitive.Types.UTxOIndex as UTxOIndex

genUTxOIndexSmall :: Gen UTxOIndex
genUTxOIndexSmall = do
entryCount <- choose (0, 64)
entryCount <- frequency
[ (1, pure 0)
, (1, pure 1)
, (32, choose (2, 64))
]
UTxOIndex.fromSequence <$> replicateM entryCount genEntrySmallRange

shrinkUTxOIndexSmall :: UTxOIndex -> [UTxOIndex]
Expand Down

0 comments on commit 38e8bd2

Please sign in to comment.