Skip to content

Commit

Permalink
Set the depositDeadline field in hydra-cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed Jan 22, 2025
1 parent a0405bd commit d131ffb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion hydra-cluster/bench/Bench/EndToEnd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Test.Hydra.Prelude
import Bench.Summary (Summary (..), makeQuantiles)
import CardanoClient (RunningNode (..), awaitTransaction, submitTransaction, submitTx)
import CardanoNode (findRunningCardanoNode', withCardanoNodeDevnet)
import Hydra.Tx.DepositDeadline (DepositDeadline (UnsafeDepositDeadline))
import Control.Concurrent.Class.MonadSTM (
MonadSTM (readTVarIO),
check,
Expand Down Expand Up @@ -89,7 +90,8 @@ bench startingNodeId timeoutSeconds workDir dataset = do
putStrLn $ "Starting hydra cluster in " <> workDir
let hydraTracer = contramap FromHydraNode tracer
let contestationPeriod = UnsafeContestationPeriod 10
withHydraCluster hydraTracer workDir nodeSocket startingNodeId cardanoKeys hydraKeys hydraScriptsTxId contestationPeriod $ \clients -> do
let depositDeadline = UnsafeDepositDeadline 10
withHydraCluster hydraTracer workDir nodeSocket startingNodeId cardanoKeys hydraKeys hydraScriptsTxId contestationPeriod depositDeadline $ \clients -> do
waitForNodesConnected hydraTracer 20 clients
scenario hydraTracer node workDir dataset clients

Expand Down
4 changes: 3 additions & 1 deletion hydra-cluster/src/Hydra/Cluster/Scenarios.hs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ import System.FilePath ((</>))
import Test.Hydra.Tx.Fixture (testNetworkId)
import Test.Hydra.Tx.Gen (genKeyPair)
import Test.QuickCheck (choose, elements, generate)
import Hydra.Tx.DepositDeadline (DepositDeadline(..))

data EndToEndLog
= ClusterOptions {options :: Options}
Expand Down Expand Up @@ -828,8 +829,9 @@ threeNodesNoErrorsOnOpen tracer tmpDir node@RunningNode{nodeSocket} hydraScripts
hydraKeys = [aliceSk, bobSk, carolSk]

let contestationPeriod = UnsafeContestationPeriod 2
let depositDeadline = UnsafeDepositDeadline 50
let hydraTracer = contramap FromHydraNode tracer
withHydraCluster hydraTracer tmpDir nodeSocket 1 cardanoKeys hydraKeys hydraScriptsTxId contestationPeriod $ \clients -> do
withHydraCluster hydraTracer tmpDir nodeSocket 1 cardanoKeys hydraKeys hydraScriptsTxId contestationPeriod depositDeadline $ \clients -> do
let leader = head clients
waitForNodesConnected hydraTracer 20 clients

Expand Down
5 changes: 4 additions & 1 deletion hydra-cluster/src/HydraNode.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import System.Process (
)
import Test.Hydra.Prelude (checkProcessHasNotDied, failAfter, failure, shouldNotBe, withLogFile)
import Prelude qualified
import Hydra.Tx.DepositDeadline (DepositDeadline)

-- * Client to interact with a hydra-node

Expand Down Expand Up @@ -249,9 +250,10 @@ withHydraCluster ::
-- | Transaction ids at which Hydra scripts should have been published.
[TxId] ->
ContestationPeriod ->
DepositDeadline ->
(NonEmpty HydraClient -> IO a) ->
IO a
withHydraCluster tracer workDir nodeSocket firstNodeId allKeys hydraKeys hydraScriptsTxId contestationPeriod action = do
withHydraCluster tracer workDir nodeSocket firstNodeId allKeys hydraKeys hydraScriptsTxId contestationPeriod depositDeadline action = do
when (clusterSize == 0) $
failure "Cannot run a cluster with 0 number of nodes"
when (length allKeys /= length hydraKeys) $
Expand Down Expand Up @@ -282,6 +284,7 @@ withHydraCluster tracer workDir nodeSocket firstNodeId allKeys hydraKeys hydraSc
, cardanoSigningKey
, cardanoVerificationKeys
, contestationPeriod
, depositDeadline
}
withHydraNode
tracer
Expand Down
7 changes: 5 additions & 2 deletions hydra-cluster/test/Test/EndToEndSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Control.Concurrent.STM.TVar (modifyTVar')
import Control.Lens ((^..), (^?))
import Data.Aeson (Result (..), Value (Null, Object, String), fromJSON, object, (.=))
import Data.Aeson qualified as Aeson
import Hydra.Tx.DepositDeadline (DepositDeadline (UnsafeDepositDeadline))
import Data.Aeson.Lens (AsJSON (_JSON), key, values, _JSON)
import Data.ByteString qualified as BS
import Data.List qualified as List
Expand Down Expand Up @@ -256,8 +257,9 @@ spec = around (showLogsOnFailure "EndToEndSpec") $ do

hydraScriptsTxId <- publishHydraScriptsAs node Faucet
let contestationPeriod = UnsafeContestationPeriod 2
let depositDeadline = UnsafeDepositDeadline 20
let hydraTracer = contramap FromHydraNode tracer
withHydraCluster hydraTracer tmpDir nodeSocket firstNodeId cardanoKeys hydraKeys hydraScriptsTxId contestationPeriod $ \nodes -> do
withHydraCluster hydraTracer tmpDir nodeSocket firstNodeId cardanoKeys hydraKeys hydraScriptsTxId contestationPeriod depositDeadline $ \nodes -> do
let [n1, n2, n3] = toList nodes
waitForNodesConnected hydraTracer 20 $ n1 :| [n2, n3]

Expand Down Expand Up @@ -636,8 +638,9 @@ initAndClose tmpDir tracer clusterIx hydraScriptsTxId node@RunningNode{nodeSocke

let firstNodeId = clusterIx * 3
let contestationPeriod = UnsafeContestationPeriod 2
let depositDeadline = UnsafeDepositDeadline 20
let hydraTracer = contramap FromHydraNode tracer
withHydraCluster hydraTracer tmpDir nodeSocket firstNodeId cardanoKeys hydraKeys hydraScriptsTxId contestationPeriod $ \nodes -> do
withHydraCluster hydraTracer tmpDir nodeSocket firstNodeId cardanoKeys hydraKeys hydraScriptsTxId contestationPeriod depositDeadline $ \nodes -> do
let [n1, n2, n3] = toList nodes
waitForNodesConnected hydraTracer 20 $ n1 :| [n2, n3]

Expand Down
4 changes: 3 additions & 1 deletion hydra-cluster/test/Test/Hydra/Cluster/HydraClientSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import Hydra.Ledger.Cardano (mkSimpleTx, mkTransferTx)
import Hydra.Logging (Tracer, showLogsOnFailure)
import Hydra.Tx (HeadId, IsTx (..))
import Hydra.Tx.ContestationPeriod (ContestationPeriod (UnsafeContestationPeriod))
import Hydra.Tx.DepositDeadline (DepositDeadline (UnsafeDepositDeadline))
import HydraNode (HydraClient (..), HydraNodeLog, input, output, requestCommitTx, send, waitFor, waitForAllMatch, waitForNodesConnected, waitMatch, waitNoMatch, withConnectionToNodeHost, withHydraCluster)
import Test.Hydra.Tx.Fixture (testNetworkId)
import Test.Hydra.Tx.Gen (genKeyPair)
Expand Down Expand Up @@ -286,8 +287,9 @@ scenarioSetup tracer tmpDir action = do
let firstNodeId = 1
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
let contestationPeriod = UnsafeContestationPeriod 2
let depositDeadline = UnsafeDepositDeadline 20
let hydraTracer = contramap FromHydraNode tracer
withHydraCluster hydraTracer tmpDir nodeSocket firstNodeId cardanoKeys hydraKeys hydraScriptsTxId contestationPeriod $ \nodes -> do
withHydraCluster hydraTracer tmpDir nodeSocket firstNodeId cardanoKeys hydraKeys hydraScriptsTxId contestationPeriod depositDeadline $ \nodes -> do
let [n1, n2, n3] = toList nodes
waitForNodesConnected hydraTracer 20 $ n1 :| [n2, n3]

Expand Down

0 comments on commit d131ffb

Please sign in to comment.