@@ -75,6 +75,7 @@ import Ouroboros.Consensus.Util hiding (Some)
75
75
import Ouroboros.Consensus.Util.Args
76
76
import Ouroboros.Consensus.Util.IOLike
77
77
import qualified Ouroboros.Network.AnchoredSeq as AS
78
+ import Ouroboros.Network.Protocol.LocalStateQuery.Type
78
79
import qualified System.Directory as Dir
79
80
import System.FS.API
80
81
import qualified System.FS.IO as FSIO
@@ -325,6 +326,7 @@ instance StateModel Model where
325
326
Action Model (ExtLedgerState TestBlock EmptyMK , ExtLedgerState TestBlock EmptyMK )
326
327
Init :: SecurityParam -> LSM. Salt -> Action Model ()
327
328
ValidateAndCommit :: Word64 -> [TestBlock ] -> Action Model ()
329
+ OpenAndCloseForker :: Action Model ()
328
330
329
331
actionName WipeLedgerDB {} = " WipeLedgerDB"
330
332
actionName TruncateSnapshots {} = " TruncateSnapshots"
@@ -333,6 +335,7 @@ instance StateModel Model where
333
335
actionName GetState {} = " GetState"
334
336
actionName Init {} = " Init"
335
337
actionName ValidateAndCommit {} = " ValidateAndCommit"
338
+ actionName OpenAndCloseForker = " OpenAndCloseForker"
336
339
337
340
arbitraryAction _ UnInit = Some <$> (Init <$> QC. arbitrary <*> QC. arbitrary)
338
341
arbitraryAction _ model@ (Model chain secParam) =
@@ -361,6 +364,7 @@ instance StateModel Model where
361
364
)
362
365
, (1 , pure $ Some WipeLedgerDB )
363
366
, (1 , pure $ Some TruncateSnapshots )
367
+ , (1 , pure $ Some OpenAndCloseForker )
364
368
]
365
369
366
370
initialState = UnInit
@@ -402,6 +406,7 @@ instance StateModel Model where
402
406
nextState state WipeLedgerDB _var = state
403
407
nextState state TruncateSnapshots _var = state
404
408
nextState state (DropAndRestore n _) _var = modelRollback n state
409
+ nextState state OpenAndCloseForker _var = state
405
410
nextState UnInit _ _ = error " Uninitialized model created a command different than Init"
406
411
407
412
precondition UnInit Init {} = True
@@ -635,6 +640,12 @@ instance RunModel Model (StateT Environment IO) where
635
640
atomically $ modifyTVar (dbChain chainDb) (drop (fromIntegral n))
636
641
closeLedgerDB testInternals
637
642
perform state (Init secParam salt) lk
643
+ perform _ OpenAndCloseForker _ = do
644
+ Environment ldb _ _ _ _ _ _ rr <- get
645
+ eFrk <- lift $ LedgerDB. getForkerAtTarget ldb rr VolatileTip
646
+ case eFrk of
647
+ Left err -> error $ " Impossible: can't acquire forker at tip: " <> show err
648
+ Right frk -> lift $ forkerClose frk
638
649
perform _ TruncateSnapshots _ = do
639
650
Environment _ testInternals _ _ _ _ _ _ <- get
640
651
lift $ truncateSnapshots testInternals
0 commit comments