| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
HydraNode
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 ()
- waitNoMatch :: HasCallStack => NominalDiffTime -> HydraClient -> (Value -> Maybe a) -> 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 ()
- getProtocolParameters :: HydraClient -> IO (PParams LedgerEra)
- getSnapshotUTxO :: HydraClient -> IO UTxO
- getSnapshotConfirmed :: HydraClient -> IO (ConfirmedSnapshot Tx)
- getSnapshotLastSeen :: HydraClient -> IO (SeenSnapshot Tx)
- 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
- preparePParams :: ChainConfig -> FilePath -> (Value -> Value) -> IO FilePath
- prepareHydraNode :: HasCallStack => ChainConfig -> FilePath -> Int -> SigningKey HydraKey -> [VerificationKey HydraKey] -> [Int] -> (Value -> Value) -> IO RunOptions
- withPreparedHydraNode :: HasCallStack => Tracer IO HydraNodeLog -> FilePath -> Int -> RunOptions -> (HydraClient -> IO a) -> IO a
- withHydraNode :: HasCallStack => Tracer IO HydraNodeLog -> ChainConfig -> FilePath -> Int -> SigningKey HydraKey -> [VerificationKey HydraKey] -> [Int] -> (HydraClient -> 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
- waitForNodesConnected :: Tracer IO HydraNodeLog -> NominalDiffTime -> NonEmpty HydraClient -> IO ()
- waitForNodesDisconnected :: 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 #
Constructors
| HydraClient | |
Fields
| |
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.
waitNoMatch :: HasCallStack => NominalDiffTime -> HydraClient -> (Value -> Maybe a) -> IO () Source #
Wait up to some time and succeed if no API server output matches the given predicate.
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.
getProtocolParameters :: HydraClient -> IO (PParams LedgerEra) Source #
Get the protocol-parameters from 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.
getSnapshotConfirmed :: HydraClient -> IO (ConfirmedSnapshot Tx) Source #
Get the latest snapshot 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 ConfirmedSnapshot type as we often need to pick it apart.
getSnapshotLastSeen :: HydraClient -> IO (SeenSnapshot Tx) Source #
Get the latest seen snapshot from the hydra-node.
getMetrics :: HasCallStack => HydraClient -> IO ByteString Source #
Start / connect to a cluster of nodes
Arguments
| :: 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 ids at which Hydra scripts should have been published. |
| -> ContestationPeriod | |
| -> (NonEmpty HydraClient -> IO a) | |
| -> IO a |
Start / connect to a hydra-node
preparePParams :: ChainConfig -> FilePath -> (Value -> Value) -> IO FilePath Source #
Prepare protocol-parameters to run a hydra-node with given ChainConfig and using the config from
config/.
prepareHydraNode :: HasCallStack => ChainConfig -> FilePath -> Int -> SigningKey HydraKey -> [VerificationKey HydraKey] -> [Int] -> (Value -> Value) -> IO RunOptions Source #
Prepare RunOptions to run a hydra-node with given ChainConfig and using the config from
config/.
withPreparedHydraNode :: HasCallStack => Tracer IO HydraNodeLog -> FilePath -> Int -> RunOptions -> (HydraClient -> IO a) -> IO a Source #
Run a hydra-node with given RunOptions.
withHydraNode :: HasCallStack => 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/.
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 #
waitForNodesConnected :: Tracer IO HydraNodeLog -> NominalDiffTime -> NonEmpty HydraClient -> IO () Source #
waitForNodesDisconnected :: Tracer IO HydraNodeLog -> NominalDiffTime -> NonEmpty HydraClient -> IO () Source #
data HydraNodeLog Source #