Skip to content

Commit

Permalink
All nodes wait to observe a commit
Browse files Browse the repository at this point in the history
We added a threadDelay in the performAbort and realised this fixed
one of the issues we had, pinpointing the fact that there's some race
conditions in the abort logic: It's perfectly possible that a party
Aborts while other parties Commited and the Abort fails.

We don't model this behaviour for now, but this could be done using
"Negative" actions
  • Loading branch information
abailly authored and ch1bo committed Feb 16, 2024
1 parent 4d4dfb9 commit 60024f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions hydra-node/test/Hydra/Model.hs
Original file line number Diff line number Diff line change
Expand Up @@ -617,17 +617,18 @@ performCommit parties party paymentUTxO = do
SimulatedChainNetwork{simulateCommit} <- gets chain
case Map.lookup party nodes of
Nothing -> throwIO $ UnexpectedParty party
Just actorNode -> do
Just{} -> do
let realUTxO = toRealUTxO paymentUTxO
lift $ simulateCommit (party, realUTxO)
observedUTxO <-
lift $
waitMatch actorNode $ \case
Committed{party = cp, utxo = committedUTxO}
| cp == party, committedUTxO == realUTxO -> Just committedUTxO
err@CommandFailed{} -> error $ show err
_ -> Nothing
pure $ fromUtxo observedUTxO
forM nodes $ \n ->
waitMatch n $ \case
Committed{party = cp, utxo = committedUTxO}
| cp == party, committedUTxO == realUTxO -> Just committedUTxO
err@CommandFailed{} -> error $ show err
_ -> Nothing
pure $ fromUtxo $ List.head $ toList observedUTxO
where
fromUtxo :: UTxO -> [(CardanoSigningKey, Value)]
fromUtxo utxo = findSigningKey . (txOutAddress &&& txOutValue) . snd <$> pairs utxo
Expand Down
2 changes: 1 addition & 1 deletion hydra-node/test/Hydra/ModelSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ import Hydra.Model (
import Hydra.Model qualified as Model
import Hydra.Model.Payment qualified as Payment
import Hydra.Party (Party (..), deriveParty)
import Test.QuickCheck (Property, Testable, counterexample, forAll, forAllShrink, property, withMaxSuccess, within)
import Test.QuickCheck (Property, Testable, counterexample, forAllShrink, property, withMaxSuccess, within)
import Test.QuickCheck.DynamicLogic (
DL,
Quantification,
Expand Down

0 comments on commit 60024f9

Please sign in to comment.