From 170b35d58491faf4775e14de63c4c1dff20682d0 Mon Sep 17 00:00:00 2001 From: Sasha Bogicevic Date: Mon, 19 Feb 2024 12:08:11 +0100 Subject: [PATCH] Commit the pending utxo already seeded to party When we want to commit we need to take the utxo that was already pre-seeded for our party and not just some arbitrary value not known to our mock chain. --- hydra-node/test/Hydra/Model.hs | 10 ---------- hydra-node/test/Hydra/Model/MockChain.hs | 2 +- hydra-node/test/Hydra/ModelSpec.hs | 14 ++++++++++---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/hydra-node/test/Hydra/Model.hs b/hydra-node/test/Hydra/Model.hs index 44940623a7b..a871f1abb72 100644 --- a/hydra-node/test/Hydra/Model.hs +++ b/hydra-node/test/Hydra/Model.hs @@ -391,16 +391,6 @@ genInit hydraParties = do let party = deriveParty key pure $ Init party -genCommit' :: - [(SigningKey HydraKey, CardanoSigningKey)] -> - (SigningKey HydraKey, CardanoSigningKey) -> - Gen (Action WorldState [(CardanoSigningKey, Value)]) -genCommit' hydraParties hydraParty = do - let (_, sk) = fromJust $ find (== hydraParty) hydraParties - value <- genAdaValue - let utxo = [(sk, value)] - pure $ Commit (deriveParty . fst $ hydraParty) utxo - genPayment :: WorldState -> Gen (Party, Payment) genPayment WorldState{hydraParties, hydraState} = case hydraState of diff --git a/hydra-node/test/Hydra/Model/MockChain.hs b/hydra-node/test/Hydra/Model/MockChain.hs index bf549954437..dce4e68b392 100644 --- a/hydra-node/test/Hydra/Model/MockChain.hs +++ b/hydra-node/test/Hydra/Model/MockChain.hs @@ -31,7 +31,7 @@ import Hydra.BehaviorSpec ( SimulatedChainNetwork (..), ) import Hydra.Cardano.Api.Pretty (renderTxWithUTxO) -import Hydra.Chain (Chain (..), PostTxError (..), initHistory) +import Hydra.Chain (Chain (..), initHistory) import Hydra.Chain.Direct.Fixture (testNetworkId) import Hydra.Chain.Direct.Handlers ( ChainSyncHandler (..), diff --git a/hydra-node/test/Hydra/ModelSpec.hs b/hydra-node/test/Hydra/ModelSpec.hs index eb7211bd40a..0dd04bad8df 100644 --- a/hydra-node/test/Hydra/ModelSpec.hs +++ b/hydra-node/test/Hydra/ModelSpec.hs @@ -135,7 +135,6 @@ import Hydra.Model ( RunMonad, RunState (..), WorldState (..), - genCommit', genInit, genPayment, genSeed, @@ -235,9 +234,16 @@ headOpensIfAllPartiesCommit = do forAllQ (withGenQ (genInit hydraParties) (const [])) >>= action_ everybodyCommit = do - WorldState{hydraParties} <- getModelStateDL - forM_ hydraParties $ \party -> - forAllQ (withGenQ (genCommit' hydraParties party) (const [])) >>= action + WorldState{hydraParties, hydraState} <- getModelStateDL + case hydraState of + Initial{pendingCommits} -> + forM_ hydraParties $ \p -> do + let party = deriveParty (fst p) + case Map.lookup party pendingCommits of + Nothing -> pure () + Just utxo -> + void $ action $ Model.Commit party utxo + _ -> pure () prop_checkConflictFreeLiveness :: Property prop_checkConflictFreeLiveness =