View on GitHub
File Changes
    (
      utxoSize
    , utxoMap
-
    , genBool
    , genNatural
    , genNonEmptyAndAdvanceTx
    , genNonEmptyAndAdvanceTx'

                      
import           BaseTypes
import           Coin
-
import           Generator.Core (findPayKeyPair, genNatural)
+
import           Generator.Core (findPayKeyPair, genInteger, genNatural)
import           Keys (pattern KeyPair, hashKey, hashKeyVRF, vKey)
import           LedgerState (DState (..), pattern LedgerValidation, ValidationError (..),
                     asStateTransition, asStateTransition', dstate, genesisCoins, genesisState,
addrTxins :: KeyPairs -> [Addr]
addrTxins keyPairs = uncurry AddrBase <$> hashKeyPairs keyPairs

                      
-
genBool :: Gen Bool
-
genBool = Gen.enumBounded
-

                      
-
genInteger :: Integer -> Integer -> Gen Integer
-
genInteger lower upper = Gen.integral $ Range.linear lower upper
-

                      
-- | Generator for List of 'Coin' values. Generates between 'lower' and 'upper'
-- coins, with values between 'minCoin' and 'maxCoin'.
genCoinList :: Integer -> Integer -> Int -> Int -> Gen [Coin]

                      
module Generator.Core
  ( findPayKeyPair
+
  , genBool
  , genCoin
+
  , genInteger
  , genNatural
  , genTxOut
  , genUtxo0
+
  , increasingProbabilityAt
  , mkGenesisLedgerState
  , traceKeyPairs
  , someKeyPairs
import           Tx (pattern TxOut)
import           TxData (pattern AddrBase, pattern KeyHashObj)

                      
+
genBool :: Gen Bool
+
genBool = Gen.enumBounded
+

                      
+
genInteger :: Integer -> Integer -> Gen Integer
+
genInteger lower upper = Gen.integral $ Range.linear lower upper
+

                      
-- | Generator for a natural number between 'lower' and 'upper'
genNatural :: Natural -> Natural -> Gen Natural
genNatural lower upper = Gen.integral $ Range.linear lower upper
  utxo0 <- genUtxo0 5 10
  let (LedgerState utxoSt dpSt _) = genesisState utxo0
  pure (utxoSt, dpSt)
+

                      
+
-- | Generate values the given distribution in 90% of the cases, and values at
+
-- the bounds of the range in 10% of the cases.
+
--
+
-- This can be used to generate enough extreme values. The exponential and
+
-- linear distributions provided by @[email protected] will generate a small percentage
+
-- of these (0-1%).
+
increasingProbabilityAt
+
  :: Gen a
+
  -> (a, a)
+
  -> Gen a
+
increasingProbabilityAt gen (lower, upper)
+
  = Gen.frequency [ (5, pure lower)
+
                  , (90, gen)
+
                  , (5, pure upper)
+
                  ]
import           BaseTypes (Nonce (NeutralNonce), UnitInterval, mkNonce)
import           Coin (Coin (..))
import           Examples (unsafeMkUnitInterval)
-
import           Generator.Core (genNatural)
+
import           Generator.Core (genInteger, genNatural, increasingProbabilityAt)
import qualified Hedgehog.Range as Range
import           Numeric.Natural (Natural)
import           PParams (PParams (..))
                       <*> pure 0 -- _minfeeB
                       <*> szGen  -- (maxBBSize, maxBHSize, maxTxSize)
                       -- keyDeposit
-
                       <*> (Coin <$> Gen.integral (Range.linear 0 50))
+
                       <*> increasingProbabilityAt
+
                             (Coin <$> genInteger 0 50)
+
                             (Coin 0, Coin 50)
                       -- keyMinRefund: 0.1-0.5
                       <*> genIntervalInThousands 100 500
                       -- keyDecayRate: 0.001-0.1
                       <*> genRationalInThousands 1 100
                       -- poolDeposit
-
                       <*> Gen.integral (Range.linear 0 500)
+
                       <*> increasingProbabilityAt
+
                             (Coin <$> genInteger 0 500)
+
                             (Coin 0, Coin 500)
                       -- poolMinRefund: 0.1-0.7
                       <*> genIntervalInThousands 100 700
                       -- poolDecayRate: 0.001-0.1
                       <*> genRationalInThousands 1 100
-
                       -- eMax
-
                       <*> (Epoch <$> Gen.integral (Range.linear 20 500))
+
                       -- eMax (for an epoch per 5 days, say, this is between a month and 7yrs)
+
                       <*> (Epoch <$> genNatural 6 500)
                       -- nOpt
                       <*> Gen.integral (Range.linear 1 100)
                       -- a0: 0.01-1.0
                       -- tau: 0.1-0.3
                       <*> genIntervalInThousands 100 300
                       -- activeSlotCoeff: 0-1
-
                       <*> genIntervalInThousands 0 1000
-
                       -- decentralisation param: 0-1
-
                       <*> genIntervalInThousands 0 1000
+
                       <*> increasingProbabilityAt
+
                             (genIntervalInThousands 0 1000)
+
                             (unsafeMkUnitInterval 0, unsafeMkUnitInterval 1)
+
                       -- decentralisation param: 0,0.1,0.2..1
+
                       <*> (unsafeMkUnitInterval <$> Gen.element [0, 0.1 .. 1])
                       <*> genExtraEntropy
                       -- protocolVersion
                       <*> ((,,) <$> genNatural 1 10 <*> genNatural 1 50 <*> genNatural 1 100)