1414{-# LANGUAGE UndecidableInstances #-}
1515{-# OPTIONS_GHC -Wno-orphans #-}
1616
17- module Test.Cardano.Ledger.Dijkstra.Arbitrary (genNonEmptyAccountBalanceIntervals ) where
17+ module Test.Cardano.Ledger.Dijkstra.Arbitrary (genNonEmptyAccountBalanceIntervals , genSmallDijkstraBlockBody ) where
1818
1919import Cardano.Ledger.Allegra.Scripts (
2020 pattern RequireTimeExpire ,
@@ -40,6 +40,7 @@ import Cardano.Ledger.Shelley.Scripts (pattern RequireSignature)
4040import Data.Functor.Identity (Identity )
4141import qualified Data.Map.Strict as Map
4242import qualified Data.OMap.Strict as OMap
43+ import qualified Data.Sequence.Strict as SSeq
4344import Data.Typeable (Typeable )
4445import Generic.Random (genericArbitraryU )
4546import Test.Cardano.Ledger.Allegra.Arbitrary (maxTimelockDepth )
@@ -303,6 +304,21 @@ instance
303304 where
304305 arbitrary = DijkstraBlockBody <$> arbitrary <*> arbitrary
305306
307+ genSmallDijkstraBlockBody ::
308+ ( AlonzoEraTx era
309+ , Arbitrary (Tx TopTx era )
310+ ) =>
311+ Gen (DijkstraBlockBody era )
312+ genSmallDijkstraBlockBody = DijkstraBlockBody <$> genFewTxs <*> arbitrary
313+ where
314+ genFewTxs = sized $ \ sz -> do
315+ numTxs <-
316+ frequency
317+ [ (99 , choose (1 , max 1 $ sz `div` 20 ))
318+ , (1 , pure 0 )
319+ ]
320+ SSeq. fromList <$> vectorOf numTxs (scale (`div` numTxs) arbitrary)
321+
306322deriving newtype instance Arbitrary (ApplyTxError DijkstraEra )
307323
308324instance Arbitrary (DijkstraMempoolPredFailure DijkstraEra ) where
0 commit comments