ouroboros-network:sim-tests-lib
Safe HaskellNone
LanguageHaskell2010

Test.Ouroboros.Network.PeerSelection.MockEnvironment

Synopsis

Documentation

newtype PeerGraph Source #

The peer graph is the graph of all the peers in the mock p2p network, in traditional adjacency representation.

Constructors

PeerGraph [(PeerAddr, [PeerAddr], PeerInfo)] 

data GovernorMockEnvironment Source #

The data needed to execute the peer selection governor in a test with a mock network environment. It contains the data needed to provide the PeerSelectionActions and PeerSelectionPolicy to run the governor.

The representations are chosen to be easily shrinkable. See the Arbitrary instances.

runGovernorInMockEnvironment :: GovernorMockEnvironment -> SimTrace Void Source #

Run the peerSelectionGovernor in the mock environment dictated by the data in the GovernorMockEnvironment.

The result is an execution trace.

newtype Script a #

Constructors

Script (NonEmpty a) 

Instances

Instances details
Functor Script 
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Methods

fmap :: (a -> b) -> Script a -> Script b #

(<$) :: a -> Script b -> Script a #

Foldable Script 
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Methods

fold :: Monoid m => Script m -> m #

foldMap :: Monoid m => (a -> m) -> Script a -> m #

foldMap' :: Monoid m => (a -> m) -> Script a -> m #

foldr :: (a -> b -> b) -> b -> Script a -> b #

foldr' :: (a -> b -> b) -> b -> Script a -> b #

foldl :: (b -> a -> b) -> b -> Script a -> b #

foldl' :: (b -> a -> b) -> b -> Script a -> b #

foldr1 :: (a -> a -> a) -> Script a -> a #

foldl1 :: (a -> a -> a) -> Script a -> a #

toList :: Script a -> [a] #

null :: Script a -> Bool #

length :: Script a -> Int #

elem :: Eq a => a -> Script a -> Bool #

maximum :: Ord a => Script a -> a #

minimum :: Ord a => Script a -> a #

sum :: Num a => Script a -> a #

product :: Num a => Script a -> a #

Traversable Script 
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Methods

traverse :: Applicative f => (a -> f b) -> Script a -> f (Script b) #

sequenceA :: Applicative f => Script (f a) -> f (Script a) #

mapM :: Monad m => (a -> m b) -> Script a -> m (Script b) #

sequence :: Monad m => Script (m a) -> m (Script a) #

Arbitrary a => Arbitrary (Script a) 
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Methods

arbitrary :: Gen (Script a) #

shrink :: Script a -> [Script a] #

Show a => Show (Script a) 
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Methods

showsPrec :: Int -> Script a -> ShowS #

show :: Script a -> String #

showList :: [Script a] -> ShowS #

Eq a => Eq (Script a) 
Instance details

Defined in Ouroboros.Network.Testing.Data.Script

Methods

(==) :: Script a -> Script a -> Bool #

(/=) :: Script a -> Script a -> Bool #

arbitraryPickScript :: Gen (Set peeraddr) -> Gen (PickScript peeraddr) #

initScript :: MonadSTM m => Script a -> m (TVar m (Script a)) #

initScript' :: MonadSTM m => Script a -> m (StrictTVar m (Script a)) #

interpretPickScript :: forall (m :: Type -> Type) peeraddr. (MonadSTM m, Ord peeraddr) => StrictTVar m (PickScript peeraddr) -> Set peeraddr -> Int -> STM m (Set peeraddr) #

playTimedScript :: (MonadAsync m, MonadDelay m) => Tracer m a -> TimedScript a -> m (TVar m a) #

shrinkScriptWith :: (a -> [a]) -> Script a -> [Script a] #

singletonTimedScript :: a -> TimedScript a #

Timed script which consists of a single element.

stepScript :: MonadSTM m => TVar m (Script a) -> m a #

stepScriptSTM :: forall (m :: Type -> Type) a. MonadSTM m => TVar m (Script a) -> STM m a #

stepScriptSTM' :: forall (m :: Type -> Type) a. MonadSTM m => StrictTVar m (Script a) -> STM m a #

type PickScript peeraddr = Script (PickMembers peeraddr) #

A pick script is used to interpret the policyPickKnownPeersForPeerShare and the policyPickColdPeersToForget. It selects elements from the given choices by their index (modulo the number of choices). This representation was chosen because it allows easy shrinking.

data PeerStatus #

Constructors

PeerCold

Peer is in true cold which means no connection to exists and the outbound governor is safe to promote it.

PeerCooling

Peer is in cold state but its connection still lingers. I.e. it is still in progress to be fully demoted.

Note: The `PeerCooling -> PeerCold` state transition is an `outbound-governor` reflection of the connection-manager's `TerminatingSt -> TerminatedSt` state transition (our version of tcp's TimeWait). It is only triggered in case of a clean connection shutdown, not in the case of errors.

PeerWarm 
PeerHot