Skip to content

Commit

Permalink
Sanity check for tentative followers in the ChainDB q-s-m test
Browse files Browse the repository at this point in the history
  • Loading branch information
amesgen authored and nfrisby committed Apr 4, 2022
1 parent fe1c34f commit 4cc618f
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ data Cmd blk it flr
| IteratorNextGCed it
-- ^ Only for blocks that may have been garbage collected.
| IteratorClose it
| NewFollower
| NewFollower ChainType
| FollowerInstruction flr
-- ^ 'followerInstructionBlocking' is excluded, as it requires multiple
-- threads. Its code path is pretty much the same as 'followerInstruction'
Expand Down Expand Up @@ -359,7 +359,7 @@ run env@ChainDBEnv { varDB, .. } cmd =
IteratorNext it -> IterResult <$> iteratorNext (unWithEq it)
IteratorNextGCed it -> iterResultGCed <$> iteratorNext (unWithEq it)
IteratorClose it -> Unit <$> iteratorClose (unWithEq it)
NewFollower -> follower =<< newFollower registry SelectedChain allComponents
NewFollower ct -> follower =<< newFollower registry ct allComponents
FollowerInstruction flr -> MbChainUpdate <$> followerInstruction (unWithEq flr)
FollowerForward flr pts -> MbPoint <$> followerForward (unWithEq flr) pts
FollowerClose flr -> Unit <$> followerClose (unWithEq flr)
Expand Down Expand Up @@ -587,7 +587,11 @@ runPure cfg = \case
IteratorNext it -> ok IterResult $ update (Model.iteratorNext it allComponents)
IteratorNextGCed it -> ok iterResultGCed $ update (Model.iteratorNext it allComponents)
IteratorClose it -> ok Unit $ update_ (Model.iteratorClose it)
NewFollower -> ok Flr $ update Model.newFollower
-- As tentative followers differ from normal followers only during chain
-- selection, this test can not distinguish between them due to its
-- sequential nature. Hence, we don't add a pure model for tentative
-- followers.
NewFollower _ -> ok Flr $ update Model.newFollower
FollowerInstruction flr -> err MbChainUpdate $ updateE (Model.followerInstruction flr allComponents)
FollowerForward flr pts -> err MbPoint $ updateE (Model.followerForward flr pts)
FollowerClose flr -> ok Unit $ update_ (Model.followerClose flr)
Expand Down Expand Up @@ -828,7 +832,7 @@ generator genBlock m@Model {..} = At <$> frequency
, (if null iterators then 0 else 2, genIteratorClose)

-- Followers
, (10, return NewFollower)
, (10, genNewFollower)
, (if null followers then 0 else 10, genFollowerInstruction)
, (if null followers then 0 else 10, genFollowerForward)
-- Use a lower frequency for closing, so that the chance increases that
Expand Down Expand Up @@ -951,6 +955,8 @@ generator genBlock m@Model {..} = At <$> frequency
then IteratorNextGCed it
else IteratorNext it

genNewFollower = NewFollower <$> elements [SelectedChain, TentativeChain]

genFollowerInstruction = FollowerInstruction <$> elements followers
genFollowerForward = FollowerForward <$> elements followers
<*> genFollowerForwardPoints
Expand Down

0 comments on commit 4cc618f

Please sign in to comment.