Skip to content

Commit

Permalink
Resolve TODOs and update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1bo committed Apr 5, 2024
1 parent e5d79be commit 7e59387
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
10 changes: 3 additions & 7 deletions hydra-node/src/Hydra/Chain/Direct/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,9 @@ collect ctx headId headParameters utxoToCollect spendableUTxO = do

ChainContext{networkId, ownVerificationKey, scriptRegistry} = ctx

-- | Construct a close transaction based on the 'OpenState' and a confirmed
-- snapshot.
-- - 'SlotNo' parameter will be used as the 'Tx' lower bound.
-- - 'PointInTime' parameter will be used as an upper validity bound and
-- will define the start of the contestation period.
-- NB: lower and upper bound slot difference should not exceed contestation period
-- FIXME: wrong haddocks
-- | Construct a close transaction spending the head output in given 'UTxO',
-- head parameters, and a confirmed snapshot. NOTE: Lower and upper bound slot
-- difference should not exceed contestation period.
close ::
ChainContext ->
-- | Spendable UTxO containing head, initial and commit outputs
Expand Down
13 changes: 3 additions & 10 deletions hydra-node/test/Hydra/Chain/Direct/TxTraceSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ instance StateModel Model where
case headState of
Open ->
oneof
[ -- TODO: non-continuous snapshot numbers
[ -- NOTE: non-continuous snapshot numbers are allowed in this model
Some . ProduceSnapshots <$> arbitrary
, do
actor <- elements allActors
Expand All @@ -152,13 +152,11 @@ instance StateModel Model where
snapshotNumber <- elements snapshots
pure $ Some Contest{actor, snapshotNumber}

-- TODO: shrinkAction to have small snapshots?

initialState =
Model
{ snapshots = []
, headState = Open
, utxoV = mkVar 1 -- TODO: what does '1' mean here?
, utxoV = mkVar (-1)
, alreadyContested = []
}

Expand Down Expand Up @@ -208,17 +206,13 @@ instance RunModel Model IO where
tx <- newCloseTx actor $ correctlySignedSnapshot snapshotNumber
validateTx openHeadUTxO tx
observeTxMatching openHeadUTxO tx $ \case
Tx.Close{} -> Just () -- TODO: check more things here (or in postcondition)?
Tx.Close{} -> Just ()
_ -> Nothing
pure $ adjustUTxO tx openHeadUTxO
Contest{actor, snapshotNumber} -> do
-- NOTE: Should not happen anymore
when (snapshotNumber == 0) $
failure "Cannot contest initial snapshot"
let utxo = lookupVar utxoV
tx <- newContestTx utxo actor $ correctlySignedSnapshot snapshotNumber
validateTx utxo tx

observation@Tx.ContestObservation{contesters} <-
observeTxMatching utxo tx $ \case
Tx.Contest obs -> Just obs
Expand All @@ -231,7 +225,6 @@ instance RunModel Model IO where
, toString $ pShowNoColor observation
, "Transaction: " <> renderTxWithUTxO utxo tx
]

pure $ adjustUTxO tx utxo
Fanout -> pure ()
Stop -> pure ()
Expand Down

0 comments on commit 7e59387

Please sign in to comment.