Skip to content

Commit

Permalink
Merge pull request #3010 from input-output-hk/bolt12/dcoutts/p2p-loca…
Browse files Browse the repository at this point in the history
…l-peers

Documented GovernorMockEnvironment Generator
  • Loading branch information
bolt12 committed Mar 25, 2021
2 parents e673bc2 + 10cc732 commit c124383
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ instance Arbitrary GovernorMockEnvironmentWithoutAsyncDemotion where

-- | Invariant. Used to check the QC generator and shrinker.
--
-- NOTE: Local and Public Root Peers sets should be disjoint.
-- However we do not check for that invariant here. The goal
-- is to check if the actual Governor takes care of this and enforces
-- the invariant.
validGovernorMockEnvironment :: GovernorMockEnvironment -> Bool
validGovernorMockEnvironment GovernorMockEnvironment {
peerGraph,
Expand Down Expand Up @@ -457,8 +461,10 @@ instance Arbitrary GovernorMockEnvironment where
rootPeers = nub (map pick ixs)
-- divide into local and public, but with a bit of overlap:
local <- vectorOf (length rootPeers) (choose (0, 10 :: Int))
-- Deliberatly asking for a small intersection in order to test if
-- the Governor actually takes care of this invariant
let localRootsSet = Set.fromList [ x | (x, v) <- zip rootPeers local
, v <= 5 ]
, v < 5 ]
publicRootsSet = Set.fromList [ x | (x, v) <- zip rootPeers local
, v >= 5 ]
localRoots <- arbitraryLocalRootPeers localRootsSet
Expand Down

0 comments on commit c124383

Please sign in to comment.