Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- data HydraClient = HydraClient {
- hydraNodeId :: Int
- apiHost :: Host
- connection :: Connection
- tracer :: Tracer IO HydraNodeLog
- input :: Text -> [Pair] -> Value
- send :: HydraClient -> Value -> IO ()
- waitNext :: HasCallStack => HydraClient -> IO Value
- output :: Text -> [Pair] -> Value
- waitFor :: HasCallStack => Tracer IO HydraNodeLog -> NominalDiffTime -> [HydraClient] -> Value -> IO ()
- waitMatch :: HasCallStack => NominalDiffTime -> HydraClient -> (Value -> Maybe a) -> IO a
- waitForAllMatch :: (Eq a, Show a, HasCallStack) => NominalDiffTime -> [HydraClient] -> (Value -> Maybe a) -> IO a
- waitForAll :: HasCallStack => Tracer IO HydraNodeLog -> NominalDiffTime -> [HydraClient] -> [Value] -> IO ()
- requestCommitTx :: HydraClient -> UTxO -> IO Tx
- postDecommit :: HydraClient -> Tx -> IO ()
- getSnapshotUTxO :: HydraClient -> IO UTxO
- getMetrics :: HasCallStack => HydraClient -> IO ByteString
- withHydraCluster :: HasCallStack => Tracer IO HydraNodeLog -> FilePath -> SocketPath -> Int -> [(VerificationKey PaymentKey, SigningKey PaymentKey)] -> [SigningKey HydraKey] -> TxId -> ContestationPeriod -> (NonEmpty HydraClient -> IO a) -> IO a
- withHydraNode :: Tracer IO HydraNodeLog -> ChainConfig -> FilePath -> Int -> SigningKey HydraKey -> [VerificationKey HydraKey] -> [Int] -> (HydraClient -> IO a) -> IO a
- withHydraNode' :: Tracer IO HydraNodeLog -> ChainConfig -> FilePath -> Int -> SigningKey HydraKey -> [VerificationKey HydraKey] -> [Int] -> Maybe Handle -> (Handle -> Handle -> ProcessHandle -> IO a) -> IO a
- withConnectionToNode :: forall a. Tracer IO HydraNodeLog -> Int -> (HydraClient -> IO a) -> IO a
- withConnectionToNodeHost :: forall a. Tracer IO HydraNodeLog -> Int -> Host -> Maybe String -> (HydraClient -> IO a) -> IO a
- hydraNodeProcess :: RunOptions -> CreateProcess
- waitForNodesConnected :: HasCallStack => Tracer IO HydraNodeLog -> NominalDiffTime -> NonEmpty HydraClient -> IO ()
- data HydraNodeLog
- = HydraNodeCommandSpec { }
- | NodeStarted { }
- | SentMessage { }
- | StartWaiting { }
- | ReceivedMessage { }
- | EndWaiting { }
Client to interact with a hydra-node
data HydraClient Source #
HydraClient | |
|
send :: HydraClient -> Value -> IO () Source #
waitNext :: HasCallStack => HydraClient -> IO Value Source #
waitFor :: HasCallStack => Tracer IO HydraNodeLog -> NominalDiffTime -> [HydraClient] -> Value -> IO () Source #
Wait some time for a single API server output from each of given nodes.
This function waits for delay
seconds for message expected
to be seen by all
given nodes
.
waitMatch :: HasCallStack => NominalDiffTime -> HydraClient -> (Value -> Maybe a) -> IO a Source #
Wait up to some time for an API server output to match the given predicate.
waitForAllMatch :: (Eq a, Show a, HasCallStack) => NominalDiffTime -> [HydraClient] -> (Value -> Maybe a) -> IO a Source #
Wait up to some delay
for some JSON Value
to match given function.
This is a generalisation of waitMatch
to multiple nodes.
waitForAll :: HasCallStack => Tracer IO HydraNodeLog -> NominalDiffTime -> [HydraClient] -> [Value] -> IO () Source #
Wait some time for a list of outputs from each of given nodes.
This function is the generalised version of waitFor
, allowing several messages
to be waited for and received in any order.
requestCommitTx :: HydraClient -> UTxO -> IO Tx Source #
Helper to make it easy to obtain a commit tx using some wallet utxo. Create a commit tx using the hydra-node for later submission.
postDecommit :: HydraClient -> Tx -> IO () Source #
Submit a decommit transaction to the hydra-node.
getSnapshotUTxO :: HydraClient -> IO UTxO Source #
Get the latest snapshot UTxO from the hydra-node. NOTE: While we usually
avoid parsing responses using the same data types as the system under test,
this parses the response as a UTxO'
type as we often need to pick it apart.
getMetrics :: HasCallStack => HydraClient -> IO ByteString Source #
Start / connect to a cluster of nodes
:: HasCallStack | |
=> Tracer IO HydraNodeLog | |
-> FilePath | |
-> SocketPath | |
-> Int | First node id This sets the starting point for assigning ports |
-> [(VerificationKey PaymentKey, SigningKey PaymentKey)] | NOTE: This decides on the size of the cluster! |
-> [SigningKey HydraKey] | |
-> TxId | Transaction id at which Hydra scripts should have been published. |
-> ContestationPeriod | |
-> (NonEmpty HydraClient -> IO a) | |
-> IO a |
Start / connect to a hydra-node
withHydraNode :: Tracer IO HydraNodeLog -> ChainConfig -> FilePath -> Int -> SigningKey HydraKey -> [VerificationKey HydraKey] -> [Int] -> (HydraClient -> IO a) -> IO a Source #
Run a hydra-node with given ChainConfig
and using the config from
config/.
:: Tracer IO HydraNodeLog | |
-> ChainConfig | |
-> FilePath | |
-> Int | |
-> SigningKey HydraKey | |
-> [VerificationKey HydraKey] | |
-> [Int] | |
-> Maybe Handle | If given use this as std out. |
-> (Handle -> Handle -> ProcessHandle -> IO a) | |
-> IO a |
Run a hydra-node with given ChainConfig
and using the config from
config/.
withConnectionToNode :: forall a. Tracer IO HydraNodeLog -> Int -> (HydraClient -> IO a) -> IO a Source #
withConnectionToNodeHost :: forall a. Tracer IO HydraNodeLog -> Int -> Host -> Maybe String -> (HydraClient -> IO a) -> IO a Source #
hydraNodeProcess :: RunOptions -> CreateProcess Source #
waitForNodesConnected :: HasCallStack => Tracer IO HydraNodeLog -> NominalDiffTime -> NonEmpty HydraClient -> IO () Source #
data HydraNodeLog Source #