Skip to content

Commit 10913d0

Browse files
Add nodeCanSupportMultipleEtcdClusters test
1 parent 2dd5fea commit 10913d0

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

hydra-cluster/src/Hydra/Cluster/Scenarios.hs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,48 @@ threeNodesNoErrorsOnOpen tracer tmpDir node@RunningNode{nodeSocket} hydraScripts
10961096
Right _headIsOpen ->
10971097
pure ()
10981098

1099+
-- | Hydra nodes ABC run on ABC cluster and connect to each other.
1100+
-- Hydra nodes BC shut down.
1101+
-- Hydra nodes BC run on BC cluster and connect to each other.
1102+
-- Hydra nodes BC shut down.
1103+
-- Hydra nodes BC run and connect ABC cluster again.
1104+
nodeCanSupportMultipleEtcdClusters :: Tracer IO EndToEndLog -> FilePath -> RunningNode -> [TxId] -> IO ()
1105+
nodeCanSupportMultipleEtcdClusters tracer workDir RunningNode{networkId, nodeSocket} hydraScriptsTxId = do
1106+
let contestationPeriod = UnsafeContestationPeriod 2
1107+
let depositDeadline = UnsafeDepositDeadline 50
1108+
1109+
aliceChainConfig <-
1110+
chainConfigFor Alice workDir nodeSocket hydraScriptsTxId [Bob, Carol] contestationPeriod depositDeadline
1111+
<&> setNetworkId networkId
1112+
bobChainConfig <-
1113+
chainConfigFor Bob workDir nodeSocket hydraScriptsTxId [Alice, Carol] contestationPeriod depositDeadline
1114+
<&> setNetworkId networkId
1115+
carolChainConfig <-
1116+
chainConfigFor Carol workDir nodeSocket hydraScriptsTxId [Alice, Bob] contestationPeriod depositDeadline
1117+
<&> setNetworkId networkId
1118+
1119+
let hydraTracer = contramap FromHydraNode tracer
1120+
1121+
withHydraNode hydraTracer aliceChainConfig workDir 1 aliceSk [bobVk, carolVk] [1, 2, 3] $ \n1 -> do
1122+
withHydraNode hydraTracer bobChainConfig workDir 2 bobSk [aliceVk, carolVk] [1, 2, 3] $ \n2 -> do
1123+
withHydraNode hydraTracer carolChainConfig workDir 3 carolSk [aliceVk, bobVk] [1, 2, 3] $ \n3 -> do
1124+
waitForNodesConnected hydraTracer 30 $ n1 :| [n2, n3]
1125+
1126+
bobChainConfig' <-
1127+
chainConfigFor Bob workDir nodeSocket hydraScriptsTxId [Carol] contestationPeriod depositDeadline
1128+
<&> setNetworkId networkId
1129+
carolChainConfig' <-
1130+
chainConfigFor Carol workDir nodeSocket hydraScriptsTxId [Bob] contestationPeriod depositDeadline
1131+
<&> setNetworkId networkId
1132+
1133+
withHydraNode hydraTracer bobChainConfig' workDir 2 bobSk [carolVk] [2, 3] $ \n2 -> do
1134+
withHydraNode hydraTracer carolChainConfig' workDir 3 carolSk [bobVk] [2, 3] $ \n3 -> do
1135+
waitForNodesConnected hydraTracer 30 $ n2 :| [n3]
1136+
1137+
withHydraNode hydraTracer bobChainConfig workDir 2 bobSk [aliceVk, carolVk] [1, 2, 3] $ \n2 -> do
1138+
withHydraNode hydraTracer carolChainConfig workDir 3 carolSk [aliceVk, bobVk] [1, 2, 3] $ \n3 -> do
1139+
waitForNodesConnected hydraTracer 30 $ n1 :| [n2, n3]
1140+
10991141
-- | Two hydra node setup where Alice is wrongly configured to use Carol's
11001142
-- cardano keys instead of Bob's which will prevent him to be notified the
11011143
-- `HeadIsInitializing` but he should still receive some notification.

hydra-cluster/test/Test/EndToEndSpec.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import Hydra.Cluster.Scenarios (
6060
checkFanout,
6161
headIsInitializingWith,
6262
initWithWrongKeys,
63+
nodeCanSupportMultipleEtcdClusters,
6364
nodeReObservesOnChainTxs,
6465
oneOfThreeNodesStopsForAWhile,
6566
persistenceCanLoadWithEmptyCommit,
@@ -282,6 +283,13 @@ spec = around (showLogsOnFailure "EndToEndSpec") $ do
282283
publishHydraScriptsAs node Faucet
283284
>>= threeNodesNoErrorsOnOpen tracer tmpDir node
284285

286+
it "node can support multiple etcd clusters" $ \tracer ->
287+
failAfter 60 $
288+
withClusterTempDir $ \tmpDir -> do
289+
withCardanoNodeDevnet (contramap FromCardanoNode tracer) tmpDir $ \node -> do
290+
publishHydraScriptsAs node Faucet
291+
>>= nodeCanSupportMultipleEtcdClusters tracer tmpDir node
292+
285293
it "inits a Head, processes a single Cardano transaction and closes it again" $ \tracer ->
286294
failAfter 60 $
287295
withClusterTempDir $ \tmpDir -> do

0 commit comments

Comments
 (0)