@@ -37,28 +37,7 @@ import Data.Map qualified as Map
37
37
import Data.Set qualified as Set
38
38
import Data.Text qualified as Text
39
39
import Data.Time (secondsToDiffTime )
40
- import Hydra.Cardano.Api (
41
- AddressInEra ,
42
- GenesisParameters (.. ),
43
- NetworkId (Testnet ),
44
- NetworkMagic (NetworkMagic ),
45
- PaymentKey ,
46
- SlotNo (.. ),
47
- ToUTxOContext (toUTxOContext ),
48
- TxId ,
49
- TxIn (.. ),
50
- VerificationKey ,
51
- isVkTxOut ,
52
- lovelaceToValue ,
53
- mkTxIn ,
54
- mkVkAddress ,
55
- serialiseAddress ,
56
- signTx ,
57
- txOutValue ,
58
- txOuts' ,
59
- unEpochNo ,
60
- pattern TxValidityLowerBound ,
61
- )
40
+ import Hydra.Cardano.Api hiding (Value , cardanoEra , queryGenesisParameters )
62
41
import Hydra.Chain.Direct.Fixture (defaultPParams , testNetworkId )
63
42
import Hydra.Chain.Direct.State ()
64
43
import Hydra.Cluster.Faucet (
@@ -527,6 +506,7 @@ spec = around (showLogsOnFailure "EndToEndSpec") $ do
527
506
528
507
describe " forking eras" $ do
529
508
it " does report on unsupported era" $ \ tracer -> do
509
+ pendingWith " Currently supporting Conway era no future upcoming"
530
510
withClusterTempDir " unsupported-era" $ \ tmpDir -> do
531
511
args <- setupCardanoDevnet tmpDir
532
512
forkIntoConwayInEpoch tmpDir args 1
@@ -535,18 +515,19 @@ spec = around (showLogsOnFailure "EndToEndSpec") $ do
535
515
let node = RunningNode {nodeSocket, networkId = defaultNetworkId, pparams}
536
516
hydraScriptsTxId <- publishHydraScriptsAs node Faucet
537
517
chainConfig <- chainConfigFor Alice tmpDir nodeSocket hydraScriptsTxId [] cperiod
538
- withHydraNode' chainConfig tmpDir 1 aliceSk [] [1 ] pparams Nothing $ \ out mStdErr ph -> do
518
+ withHydraNode' chainConfig tmpDir 1 aliceSk [] [1 ] pparams Nothing $ \ out stdErr ph -> do
539
519
-- Assert nominal startup
540
520
waitForLog 5 out " missing NodeOptions" (Text. isInfixOf " NodeOptions" )
541
521
542
522
waitUntilEpoch tmpDir args node 1
543
523
544
524
waitForProcess ph `shouldReturn` ExitFailure 1
545
- errorOutputs <- hGetContents mStdErr
525
+ errorOutputs <- hGetContents stdErr
546
526
errorOutputs `shouldContain` " Received blocks in unsupported era"
547
527
errorOutputs `shouldContain` " upgrade your hydra-node"
548
528
549
529
it " does report on unsupported era on startup" $ \ tracer -> do
530
+ pendingWith " Currently supporting Conway era no future upcoming"
550
531
withClusterTempDir " unsupported-era-startup" $ \ tmpDir -> do
551
532
args <- setupCardanoDevnet tmpDir
552
533
forkIntoConwayInEpoch tmpDir args 1
@@ -558,25 +539,104 @@ spec = around (showLogsOnFailure "EndToEndSpec") $ do
558
539
559
540
waitUntilEpoch tmpDir args node 2
560
541
561
- withHydraNode' chainConfig tmpDir 1 aliceSk [] [1 ] pparams Nothing $ \ _out mStdErr ph -> do
542
+ withHydraNode' chainConfig tmpDir 1 aliceSk [] [1 ] pparams Nothing $ \ _out stdErr ph -> do
562
543
waitForProcess ph `shouldReturn` ExitFailure 1
563
- errorOutputs <- hGetContents mStdErr
544
+ errorOutputs <- hGetContents stdErr
564
545
errorOutputs `shouldContain` " Connected to cardano-node in unsupported era"
565
546
errorOutputs `shouldContain` " upgrade your hydra-node"
566
547
548
+ it " support new era" $ \ tracer -> do
549
+ withClusterTempDir " support-new-era" $ \ tmpDir -> do
550
+ args <- setupCardanoDevnet tmpDir
551
+
552
+ forkIntoConwayInEpoch tmpDir args 10
553
+ withCardanoNode (contramap FromCardanoNode tracer) tmpDir args defaultNetworkId $
554
+ \ nodeSocket -> do
555
+ let pparams = defaultPParams
556
+ node = RunningNode {nodeSocket, networkId = defaultNetworkId, pparams}
557
+ lovelaceBalanceValue = 100_000_000
558
+ -- Funds to be used as fuel by Hydra protocol transactions
559
+ (aliceCardanoVk, _) <- keysFor Alice
560
+ seedFromFaucet_ node aliceCardanoVk lovelaceBalanceValue (contramap FromFaucet tracer)
561
+ -- Get some UTXOs to commit to a head
562
+ (aliceExternalVk, aliceExternalSk) <- generate genKeyPair
563
+ committedUTxOByAlice <- seedFromFaucet node aliceExternalVk aliceCommittedToHead (contramap FromFaucet tracer)
564
+
565
+ hydraScriptsTxId <- publishHydraScriptsAs node Faucet
566
+ chainConfig <- chainConfigFor Alice tmpDir nodeSocket hydraScriptsTxId [] cperiod
567
+
568
+ let hydraTracer = contramap FromHydraNode tracer
569
+ withHydraNode hydraTracer chainConfig tmpDir 1 aliceSk [] [1 ] pparams $ \ n1 -> do
570
+ send n1 $ input " Init" []
571
+ headId <- waitForAllMatch 10 [n1] $ headIsInitializingWith (Set. fromList [alice])
572
+
573
+ requestCommitTx n1 committedUTxOByAlice <&> signTx aliceExternalSk >>= submitTx node
574
+
575
+ waitFor hydraTracer 3 [n1] $ output " HeadIsOpen" [" utxo" .= committedUTxOByAlice, " headId" .= headId]
576
+
577
+ waitUntilEpoch tmpDir args node 10
578
+
579
+ send n1 $ input " Close" []
580
+ waitMatch 3 n1 $ \ v -> do
581
+ guard $ v ^? key " tag" == Just " HeadIsClosed"
582
+ guard $ v ^? key " headId" == Just (toJSON headId)
583
+ snapshotNumber <- v ^? key " snapshotNumber"
584
+ guard $ snapshotNumber == Aeson. Number 0
585
+
586
+ it " support new era on restart" $ \ tracer -> do
587
+ withClusterTempDir " support-new-era-restart" $ \ tmpDir -> do
588
+ args <- setupCardanoDevnet tmpDir
589
+
590
+ forkIntoConwayInEpoch tmpDir args 10
591
+ withCardanoNode (contramap FromCardanoNode tracer) tmpDir args defaultNetworkId $
592
+ \ nodeSocket -> do
593
+ let pparams = defaultPParams
594
+ node = RunningNode {nodeSocket, networkId = defaultNetworkId, pparams}
595
+ lovelaceBalanceValue = 100_000_000
596
+ -- Funds to be used as fuel by Hydra protocol transactions
597
+ (aliceCardanoVk, _) <- keysFor Alice
598
+ seedFromFaucet_ node aliceCardanoVk lovelaceBalanceValue (contramap FromFaucet tracer)
599
+ -- Get some UTXOs to commit to a head
600
+ (aliceExternalVk, aliceExternalSk) <- generate genKeyPair
601
+ committedUTxOByAlice <- seedFromFaucet node aliceExternalVk aliceCommittedToHead (contramap FromFaucet tracer)
602
+
603
+ hydraScriptsTxId <- publishHydraScriptsAs node Faucet
604
+ chainConfig <- chainConfigFor Alice tmpDir nodeSocket hydraScriptsTxId [] cperiod
605
+
606
+ let hydraTracer = contramap FromHydraNode tracer
607
+ headId <- withHydraNode hydraTracer chainConfig tmpDir 1 aliceSk [] [1 ] pparams $ \ n1 -> do
608
+ send n1 $ input " Init" []
609
+ headId <- waitForAllMatch 10 [n1] $ headIsInitializingWith (Set. fromList [alice])
610
+
611
+ requestCommitTx n1 committedUTxOByAlice <&> signTx aliceExternalSk >>= submitTx node
612
+
613
+ waitFor hydraTracer 3 [n1] $ output " HeadIsOpen" [" utxo" .= committedUTxOByAlice, " headId" .= headId]
614
+
615
+ pure headId
616
+
617
+ waitUntilEpoch tmpDir args node 10
618
+
619
+ withHydraNode hydraTracer chainConfig tmpDir 1 aliceSk [] [1 ] pparams $ \ n1 -> do
620
+ send n1 $ input " Close" []
621
+ waitMatch 3 n1 $ \ v -> do
622
+ guard $ v ^? key " tag" == Just " HeadIsClosed"
623
+ guard $ v ^? key " headId" == Just (toJSON headId)
624
+ snapshotNumber <- v ^? key " snapshotNumber"
625
+ guard $ snapshotNumber == Aeson. Number 0
626
+
567
627
-- | Wait until given number of epoch. This uses the epoch and slot lengths from
568
628
-- the 'ShelleyGenesisFile' of the node args passed in.
569
629
waitUntilEpoch :: FilePath -> CardanoNodeArgs -> RunningNode -> Natural -> IO ()
570
630
waitUntilEpoch stateDirectory args RunningNode {networkId, nodeSocket} toEpochNo = do
571
631
fromEpochNo :: Natural <- fromIntegral . unEpochNo <$> queryEpochNo networkId nodeSocket QueryTip
572
632
toEpochNo `shouldSatisfy` (> fromEpochNo)
573
- shellyGenesisFile :: Aeson. Value <- unsafeDecodeJsonFile (stateDirectory </> nodeShelleyGenesisFile args)
633
+ shelleyGenesisFile :: Aeson. Value <- unsafeDecodeJsonFile (stateDirectory </> nodeShelleyGenesisFile args)
574
634
let slotLength =
575
635
fromMaybe (error " Field epochLength not found" ) $
576
- shellyGenesisFile ^? key " slotLength" . _Double
636
+ shelleyGenesisFile ^? key " slotLength" . _Double
577
637
epochLength =
578
638
fromMaybe (error " Field epochLength not found" ) $
579
- shellyGenesisFile ^? key " epochLength" . _Double
639
+ shelleyGenesisFile ^? key " epochLength" . _Double
580
640
threadDelay . realToFrac $ fromIntegral (toEpochNo - fromEpochNo) * epochLength * slotLength
581
641
582
642
waitForLog :: DiffTime -> Handle -> Text -> (Text -> Bool ) -> IO ()
0 commit comments