Skip to content

Commit

Permalink
Commit the pending utxo already seeded to party
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
v0d1ch committed Feb 19, 2024
1 parent 6754c11 commit f7c07b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
10 changes: 0 additions & 10 deletions hydra-node/test/Hydra/Model.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/test/Hydra/Model/MockChain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 (..),
Expand Down
14 changes: 10 additions & 4 deletions hydra-node/test/Hydra/ModelSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ import Hydra.Model (
RunMonad,
RunState (..),
WorldState (..),
genCommit',
genInit,
genPayment,
genSeed,
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit f7c07b0

Please sign in to comment.