hydra-cluster-0.20.0: Integration test suite using a local cluster of cardano and hydra nodes
Safe HaskellSafe-Inferred
LanguageGHC2021

HydraNode

Synopsis

Client to interact with a hydra-node

data HydraClient Source #

Constructors

HydraClient 

Fields

input :: Text -> [Pair] -> Value Source #

Create an input as expected by send.

send :: HydraClient -> Value -> IO () Source #

output :: Text -> [Pair] -> Value Source #

Create an output as expected by waitFor and waitForAll.

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.

Start / connect to a cluster of nodes

withHydraCluster Source #

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 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/.

withHydraNode' Source #

Arguments

:: 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 #

data HydraNodeLog Source #

Constructors

HydraNodeCommandSpec 

Fields

NodeStarted 

Fields

SentMessage 

Fields

StartWaiting 

Fields

ReceivedMessage 

Fields

EndWaiting 

Fields

Instances

Instances details
FromJSON HydraNodeLog Source # 
Instance details

Defined in HydraNode

Methods

parseJSON :: Value -> Parser HydraNodeLog

parseJSONList :: Value -> Parser [HydraNodeLog]

omittedField :: Maybe HydraNodeLog

ToJSON HydraNodeLog Source # 
Instance details

Defined in HydraNode

Methods

toJSON :: HydraNodeLog -> Value

toEncoding :: HydraNodeLog -> Encoding

toJSONList :: [HydraNodeLog] -> Value

toEncodingList :: [HydraNodeLog] -> Encoding

omitField :: HydraNodeLog -> Bool

Generic HydraNodeLog Source # 
Instance details

Defined in HydraNode

Associated Types

type Rep HydraNodeLog :: Type -> Type Source #

Show HydraNodeLog Source # 
Instance details

Defined in HydraNode

Eq HydraNodeLog Source # 
Instance details

Defined in HydraNode

ToObject HydraNodeLog Source # 
Instance details

Defined in HydraNode

Methods

toObject :: TracingVerbosity -> HydraNodeLog -> Object

textTransformer :: HydraNodeLog -> Object -> Text

type Rep HydraNodeLog Source # 
Instance details

Defined in HydraNode

type Rep HydraNodeLog = D1 ('MetaData "HydraNodeLog" "HydraNode" "hydra-cluster-0.20.0-8reP7QGo6wY8RVPOtXpPTl" 'False) ((C1 ('MetaCons "HydraNodeCommandSpec" 'PrefixI 'True) (S1 ('MetaSel ('Just "cmd") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: (C1 ('MetaCons "NodeStarted" 'PrefixI 'True) (S1 ('MetaSel ('Just "nodeId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :+: C1 ('MetaCons "SentMessage" 'PrefixI 'True) (S1 ('MetaSel ('Just "nodeId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "message") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)))) :+: (C1 ('MetaCons "StartWaiting" 'PrefixI 'True) (S1 ('MetaSel ('Just "nodeIds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Int]) :*: S1 ('MetaSel ('Just "messages") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Value])) :+: (C1 ('MetaCons "ReceivedMessage" 'PrefixI 'True) (S1 ('MetaSel ('Just "nodeId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int) :*: S1 ('MetaSel ('Just "message") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)) :+: C1 ('MetaCons "EndWaiting" 'PrefixI 'True) (S1 ('MetaSel ('Just "nodeId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))))