| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Hydra.API.ServerSpec
Synopsis
- spec :: Spec
- sendsAnErrorWhenInputCannotBeDecoded :: Socket -> PortNumber -> Expectation
- matchGreetings :: Value -> Bool
- waitForClients :: (MonadSTM m, Ord a, Num a) => TVar m a -> m ()
- testClient :: TQueue IO Value -> TVar IO Int -> Connection -> IO ()
- dummyChainHandle :: Chain tx IO
- allowEverythingServerOutputFilter :: ServerOutputFilter tx
- noop :: Applicative m => a -> m ()
- withFreeServerSocket :: (Socket -> PortNumber -> IO a) -> IO a
- withTestAPIServer :: Socket -> PortNumber -> Party -> EventSource (StateEvent SimpleTx) IO -> Tracer IO APIServerLog -> ((EventSink (StateEvent SimpleTx) IO, Server SimpleTx IO) -> IO ()) -> IO ()
- withTestAPIServerBindingPort :: PortNumber -> Party -> EventSource (StateEvent SimpleTx) IO -> Tracer IO APIServerLog -> ((EventSink (StateEvent SimpleTx) IO, Server SimpleTx IO) -> IO ()) -> IO ()
- withTestAPIServerWithCallback :: Maybe Socket -> PortNumber -> Party -> EventSource (StateEvent SimpleTx) IO -> Tracer IO APIServerLog -> (ClientInput SimpleTx -> IO ()) -> ((EventSink (StateEvent SimpleTx) IO, Server SimpleTx IO) -> IO ()) -> IO ()
- withClient :: PortNumber -> String -> (Connection -> IO ()) -> IO ()
- mockSource :: Monad m => [a] -> EventSource a m
- waitForValue :: HasCallStack => PortNumber -> (Value -> Maybe ()) -> IO ()
- waitMatch :: HasCallStack => Natural -> Connection -> (Value -> Maybe a) -> IO a
- shouldSatisfyAll :: forall a. HasCallStack => Show a => [a] -> [a -> Bool] -> Expectation
- genStateEventForApi :: Gen (StateEvent SimpleTx)
Documentation
sendsAnErrorWhenInputCannotBeDecoded :: Socket -> PortNumber -> Expectation Source #
matchGreetings :: Value -> Bool Source #
waitForClients :: (MonadSTM m, Ord a, Num a) => TVar m a -> m () Source #
dummyChainHandle :: Chain tx 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 #