hydra-node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.API.ServerSpec

Synopsis

Documentation

spec :: Spec Source #

sendsAnErrorWhenInputCannotBeDecoded :: Socket -> PortNumber -> Expectation Source #

waitForClients :: (MonadSTM m, Ord a, Num a) => TVar m a -> m () Source #

testClient :: TQueue IO Value -> TVar IO Int -> Connection -> IO () Source #

allowEverythingServerOutputFilter :: ServerOutputFilter tx Source #

noop :: Applicative m => a -> m () Source #

withFreeServerSocket :: (Socket -> PortNumber -> IO a) -> IO a Source #

Allocate a listening socket on a free port and hand both it and its port to the action. The server is then given the very socket it serves on, so the port cannot be taken in the gap between choosing it and binding it. That gap used to surface as a flaky RunServerException carrying "Address already in use".

withTestAPIServer :: Socket -> PortNumber -> Party -> EventSource (StateEvent SimpleTx) IO -> Tracer IO APIServerLog -> ((EventSink (StateEvent SimpleTx) IO, Server SimpleTx IO) -> IO ()) -> IO () Source #

withTestAPIServerBindingPort :: PortNumber -> Party -> EventSource (StateEvent SimpleTx) IO -> Tracer IO APIServerLog -> ((EventSink (StateEvent SimpleTx) IO, Server SimpleTx IO) -> IO ()) -> IO () Source #

Like withTestAPIServer but lets the server bind port itself. Only for the test that asserts a second server on the same port is refused: handing both servers one socket would let them both succeed.

withTestAPIServerWithCallback :: Maybe Socket -> PortNumber -> Party -> EventSource (StateEvent SimpleTx) IO -> Tracer IO APIServerLog -> (ClientInput SimpleTx -> IO ()) -> ((EventSink (StateEvent SimpleTx) IO, Server SimpleTx IO) -> IO ()) -> IO () Source #

Like withTestAPIServer, but with an explicit callback invoked for every ClientInput received by the server.

withClient :: PortNumber -> String -> (Connection -> IO ()) -> IO () Source #

Connect to a websocket server running at given path. Fails if not connected within 2 seconds.

mockSource :: Monad m => [a] -> EventSource a m Source #

waitForValue :: HasCallStack => PortNumber -> (Value -> Maybe ()) -> IO () Source #

waitMatch :: HasCallStack => Natural -> Connection -> (Value -> Maybe a) -> IO a Source #

Wait up to some time for an API server output to match the given predicate.

shouldSatisfyAll :: forall a. HasCallStack => Show a => [a] -> [a -> Bool] -> Expectation Source #

genStateEventForApi :: Gen (StateEvent SimpleTx) Source #