View on GitHub
File Changes
            (hsPkgs.ouroboros-consensus)
            (hsPkgs.io-sim-classes)
            (hsPkgs.io-sim)
+
            (hsPkgs.binary-search)
            (hsPkgs.cborg)
            (hsPkgs.containers)
            (hsPkgs.contra-tracer)
                    io-sim-classes,
                    io-sim,

                      
+
                    binary-search,
                    cborg,
                    containers,
                    contra-tracer,
import           Data.Maybe (fromJust)
import           Data.Time (Day (..), UTCTime (..))

                      
+
import           Numeric.Search.Range (searchFromTo)
import           Test.QuickCheck
import           Test.Tasty
import           Test.Tasty.QuickCheck
            -- *always* suffice?)
        let check s' =
                Ref.viable params lastSlot
-
                    (NodeJoinPlan (Map.insert nid s' m))
+
                    (NodeJoinPlan (Map.insert nid (SlotNo s') m))
                    st
-
        s' <- genSlot (Ref.nextSlot st) lastSlot
-
            `suchThat` check
+
            lo = Ref.nextSlot st
+
              -- @[email protected] is downward-closed, but 'searchFromTo' requires
+
              -- upward-closed, so we instead search to find the first slot
+
              -- that is /not/ /viable/ and then decrement it to find the
+
              -- latest slot that is /viable/
+
        s' <- case searchFromTo (not . check) (unSlotNo lo) (unSlotNo lastSlot) of
+
            Nothing                -> genSlot lo lastSlot
+
            Just succHi
+
              | SlotNo succHi > lo -> genSlot lo $ SlotNo $ pred succHi
+
              | otherwise          -> error $
+
                "Cannot find viable RealPBFT NodeJoinPlan: " ++
+
                show (SlotNo succHi, nodeJoinPlan, st)

                      
        let m'  = Map.insert nid s' m

                      
  , outs     :: !(Seq Outcome)
    -- ^ the outcome of each the last @[email protected] slots
  }
+
  deriving (Eq, Show)

                      
newtype NumNominals = NumNominals Int
+
  deriving (Eq, Ord, Show)

                      
emptyState :: State
emptyState = State Seq.empty (NumNominals 0) 0 Seq.empty