diff --git a/hydra-cluster/bench/Bench/EndToEnd.hs b/hydra-cluster/bench/Bench/EndToEnd.hs index bcdb9d93827..b788c410e2a 100644 --- a/hydra-cluster/bench/Bench/EndToEnd.hs +++ b/hydra-cluster/bench/Bench/EndToEnd.hs @@ -18,10 +18,10 @@ import Control.Concurrent.Class.MonadSTM ( tryReadTBQueue, writeTBQueue, ) -import Control.Lens (to, (^?)) +import Control.Lens (to, (^..), (^?)) import Control.Monad.Class.MonadAsync (mapConcurrently) import Data.Aeson (Result (Error, Success), Value, encode, fromJSON, (.=)) -import Data.Aeson.Lens (key, _Array, _JSON, _Number, _String) +import Data.Aeson.Lens (key, values, _JSON, _Number, _String) import Data.Aeson.Types (parseMaybe) import Data.List qualified as List import Data.Map qualified as Map @@ -424,7 +424,7 @@ newTx registry client tx = do data WaitResult = TxInvalid {transactionId :: TxId, reason :: Text} | TxValid {transactionId :: TxId} - | SnapshotConfirmed {txIds :: [Value], snapshotNumber :: Scientific} + | SnapshotConfirmed {txIds :: [Value], number :: Scientific} data Registry tx = Registry { processedTxs :: TVar IO (Map.Map TxId Event) @@ -486,7 +486,7 @@ waitForAllConfirmations n1 Registry{processedTxs} allIds = do maybeTxValid v = do guard (v ^? key "tag" == Just "TxValid") v - ^? key "transaction" . key "txId" . to fromJSON >>= \case + ^? key "transactionId" . to fromJSON >>= \case Error _ -> Nothing Success txid -> pure $ TxValid txid @@ -501,14 +501,12 @@ waitForAllConfirmations n1 Registry{processedTxs} allIds = do maybeSnapshotConfirmed v = do guard (v ^? key "tag" == Just "SnapshotConfirmed") snapshot <- v ^? key "snapshot" - SnapshotConfirmed - <$> snapshot - ^? key "confirmedTransactions" - . _Array - . to toList - <*> snapshot - ^? key "snapshotNumber" - . _Number + number <- snapshot ^? key "number" . _Number + pure $ + SnapshotConfirmed + { txIds = snapshot ^.. key "confirmed" . values . key "txId" + , number + } confirmTx :: TVar IO (Map.Map TxId Event) -> diff --git a/hydra-cluster/src/Hydra/Cluster/Scenarios.hs b/hydra-cluster/src/Hydra/Cluster/Scenarios.hs index 4dbd23b6d17..e17d6920c8a 100644 --- a/hydra-cluster/src/Hydra/Cluster/Scenarios.hs +++ b/hydra-cluster/src/Hydra/Cluster/Scenarios.hs @@ -1025,8 +1025,8 @@ respendUTxO client sk delay = do waitMatch 10 client $ \v -> do guard $ v ^? key "tag" == Just "SnapshotConfirmed" guard $ - toJSON (txId tx) - `elem` (v ^.. key "snapshot" . key "confirmedTransactions" . values) + toJSON tx + `elem` (v ^.. key "snapshot" . key "confirmed" . values) v ^? key "snapshot" . key "utxo" >>= parseMaybe parseJSON -- * Utilities diff --git a/hydra-cluster/test/Test/EndToEndSpec.hs b/hydra-cluster/test/Test/EndToEndSpec.hs index c541fdfd03c..dda754e6fe0 100644 --- a/hydra-cluster/test/Test/EndToEndSpec.hs +++ b/hydra-cluster/test/Test/EndToEndSpec.hs @@ -632,12 +632,12 @@ timedTx tmpDir tracer node@RunningNode{networkId, nodeSocket} hydraScriptsTxId = -- Second submission: now valid send n1 $ input "NewTx" ["transaction" .= tx] waitFor hydraTracer 3 [n1] $ - output "TxValid" ["transaction" .= tx, "headId" .= headId] + output "TxValid" ["transactionId" .= txId tx, "headId" .= headId] confirmedTransactions <- waitMatch 3 n1 $ \v -> do guard $ v ^? key "tag" == Just "SnapshotConfirmed" - v ^? key "snapshot" . key "confirmedTransactions" - confirmedTransactions ^.. values `shouldBe` [toJSON $ txId tx] + v ^? key "snapshot" . key "confirmed" + confirmedTransactions ^.. values `shouldBe` [toJSON tx] initAndClose :: FilePath -> Tracer IO EndToEndLog -> Int -> TxId -> RunningNode -> IO () initAndClose tmpDir tracer clusterIx hydraScriptsTxId node@RunningNode{nodeSocket} = do @@ -687,7 +687,7 @@ initAndClose tmpDir tracer clusterIx hydraScriptsTxId node@RunningNode{nodeSocke aliceExternalSk send n1 $ input "NewTx" ["transaction" .= tx] waitFor hydraTracer 10 [n1, n2, n3] $ - output "TxValid" ["transaction" .= tx, "headId" .= headId] + output "TxValid" ["transactionId" .= txId tx, "headId" .= headId] -- The expected new utxo set is the created payment to bob, -- alice's remaining utxo in head and whatever bot has @@ -724,12 +724,12 @@ initAndClose tmpDir tracer clusterIx hydraScriptsTxId node@RunningNode{nodeSocke waitMatch 10 n1 $ \v -> do guard $ v ^? key "tag" == Just "SnapshotConfirmed" guard $ v ^? key "headId" == Just (toJSON headId) - snapshotNumber <- v ^? key "snapshot" . key "snapshotNumber" + snapshotNumber <- v ^? key "snapshot" . key "number" guard $ snapshotNumber == toJSON expectedSnapshotNumber utxo <- v ^? key "snapshot" . key "utxo" guard $ utxo == toJSON newUTxO - confirmedTransactions <- v ^? key "snapshot" . key "confirmedTransactions" - guard $ confirmedTransactions == toJSON [txId tx] + confirmedTransactions <- v ^? key "snapshot" . key "confirmed" + guard $ confirmedTransactions == toJSON [tx] (toJSON <$> getSnapshotUTxO n1) `shouldReturn` toJSON newUTxO