Skip to content

Commit

Permalink
Regenerate golden files and make XXX comments mention Spec instead
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1bo committed Jul 15, 2024
1 parent fd8c039 commit 38de24c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
10 changes: 5 additions & 5 deletions hydra-node/test/Hydra/Chain/Direct/Contract/Decrement.hs
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ data DecrementMutation
genDecrementMutation :: (Tx, UTxO) -> Gen SomeMutation
genDecrementMutation (tx, _utxo) =
oneof
[ -- XXX: parameters cid, ̃kH,n,T stay unchanged
[ -- Spec: parameters cid, ̃kH,n,T stay unchanged
SomeMutation (pure $ toErrorCode ChangedParameters) ChangePartiesInOuput <$> do
mutatedParties <- arbitrary `suchThat` (/= healthyOnChainParties)
pure $ ChangeOutput 0 $ modifyInlineDatum (replaceParties mutatedParties) headTxOut
, -- New version v′ is incremented correctly
SomeMutation (pure $ toErrorCode VersionNotIncremented) UseDifferentSnapshotVersion <$> do
mutatedSnapshotVersion <- arbitrarySizedNatural `suchThat` (/= healthySnapshotVersion + 1)
pure $ ChangeOutput 0 $ modifyInlineDatum (replaceSnapshotVersion $ toInteger mutatedSnapshotVersion) headTxOut
, -- XXX: ξ is a valid multi-signature of the currency id cid, the current snapshot state η,
-- the new snapshot number s′ and state η
, -- Spec: ξ is a valid multi-signature of the currency id cid, the current
-- snapshot state η, the new snapshot number s′ and state η
SomeMutation (pure $ toErrorCode SignatureVerificationFailed) ProduceInvalidSignatures . ChangeHeadRedeemer <$> do
invalidSignature <- toPlutusSignatures <$> (arbitrary :: Gen (MultiSignature (Snapshot Tx)))
pure $
Expand All @@ -186,7 +186,7 @@ genDecrementMutation (tx, _utxo) =
, snapshotNumber = fromIntegral healthySnapshotNumber
, numberOfDecommitOutputs = fromIntegral $ maybe 0 length $ utxoToDecommit healthySnapshot
}
, -- XXX: Transaction is signed by a participant
, -- Spec: Transaction is signed by a participant
SomeMutation (pure $ toErrorCode SignerIsNotAParticipant) AlterRequiredSigner <$> do
newSigner <- verificationKeyHash <$> genVerificationKey `suchThat` (/= somePartyCardanoVerificationKey)
pure $ ChangeRequiredSigners [newSigner]
Expand All @@ -196,7 +196,7 @@ genDecrementMutation (tx, _utxo) =
(ix, out) <- elements (zip [1 .. length outs - 1] outs)
value' <- genValue `suchThat` (/= txOutValue out)
pure $ ChangeOutput (fromIntegral ix) (modifyTxOutValue (const value') out)
, -- XXX: The value in the head output is decreased accordingly
, -- Spec: The value in the head output is decreased accordingly
SomeMutation (pure $ toErrorCode HeadValueIsNotPreserved) ChangeValueInOutput <$> do
newValue <- genValue
pure $ ChangeOutput 0 (headTxOut{txOutValue = newValue})
Expand Down
14 changes: 7 additions & 7 deletions hydra-node/test/Hydra/Chain/Direct/Contract/FanOut.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,19 @@ data FanoutMutation
genFanoutMutation :: (Tx, UTxO) -> Gen SomeMutation
genFanoutMutation (tx, _utxo) =
oneof
[ -- XXX: Transaction is posted after contestation deadline tmin > tfinal .
[ -- Spec: Transaction is posted after contestation deadline tmin > tfinal .
SomeMutation (pure $ toErrorCode LowerBoundBeforeContestationDeadline) MutateValidityBeforeDeadline . ChangeValidityInterval <$> do
lb <- genSlotBefore $ slotNoFromUTCTime systemStart slotLength healthyContestationDeadline
pure (TxValidityLowerBound lb, TxValidityNoUpperBound)
, -- XXX: All tokens are burnt |{cid 7→ · 7→ −1} ∈ mint| = m′ + 1.
, -- Spec: All tokens are burnt |{cid 7→ · 7→ −1} ∈ mint| = m′ + 1.
SomeMutation (pure $ toErrorCode BurntTokenNumberMismatch) MutateThreadTokenQuantity <$> do
(token, _) <- elements burntTokens
changeMintedTokens tx (valueFromList [(token, 1)])
, -- XXX: The first m outputs are distributing funds according to η. That is, the outputs exactly
, -- Spec: The first m outputs are distributing funds according to η. That is, the outputs exactly
-- correspond to the UTxO canonically combined U
SomeMutation (pure $ toErrorCode FanoutUTxOHashMismatch) MutateAddUnexpectedOutput . PrependOutput <$> do
arbitrary >>= genOutput
, -- XXX: The following n outputs are distributing funds according to η∆ .
, -- Spec: The following n outputs are distributing funds according to η∆.
-- That is, the outputs exactly # correspond to the UTxO canonically combined U∆
SomeMutation (pure $ toErrorCode FanoutUTxOToDecommitHashMismatch) MutateChangeOutputValue <$> do
let outs = txOuts' tx
Expand All @@ -144,7 +144,7 @@ genFanoutMutation (tx, _utxo) =
(ix, out) <- elements (zip [noOfUtxoToOutputs .. length outs - 1] outs)
value' <- genValue `suchThat` (/= txOutValue out)
pure $ ChangeOutput (fromIntegral ix) (modifyTxOutValue (const value') out)
, -- XXX: The following n outputs are distributing funds according to η∆ .
, -- Spec: The following n outputs are distributing funds according to η∆ .
-- That is, the outputs exactly # correspond to the UTxO canonically combined U∆
SomeMutation (pure $ toErrorCode FanoutUTxOHashMismatch) MutateChangeOutputValue <$> do
let outs = txOuts' tx
Expand All @@ -156,14 +156,14 @@ genFanoutMutation (tx, _utxo) =
(ix, out) <- elements (zip [0 .. (length outs - noOfUtxoToDecommitOutputs) - 1] outs)
value' <- genValue `suchThat` (/= txOutValue out)
pure $ ChangeOutput (fromIntegral ix) (modifyTxOutValue (const value') out)
, -- XXX: The following n outputs are distributing funds according to η∆ .
, -- Spec: The following n outputs are distributing funds according to η∆ .
-- That is, the outputs exactly # correspond to the UTxO canonically combined U∆
SomeMutation (pure $ toErrorCode FanoutUTxOToDecommitHashMismatch) MutateFanoutRedeemer . ChangeHeadRedeemer <$> do
let noOfUtxoToOutputs = fromIntegral . size $ toMap (fst healthyFanoutSnapshotUTxO)
let noOfUtxoDecommitToOutputs = fromIntegral . size $ toMap (snd healthyFanoutSnapshotUTxO)
n <- elements [1 .. 3]
pure (Head.Fanout noOfUtxoToOutputs (noOfUtxoDecommitToOutputs - n))
, -- XXX: The first m outputs are distributing funds according to η. That is, the outputs exactly
, -- Spec: The first m outputs are distributing funds according to η. That is, the outputs exactly
-- correspond to the UTxO canonically combined U
SomeMutation (pure $ toErrorCode FanoutUTxOHashMismatch) MutateFanoutRedeemer . ChangeHeadRedeemer <$> do
let noOfUtxoToOutputs = fromIntegral . size $ toMap (fst healthyFanoutSnapshotUTxO)
Expand Down
6 changes: 3 additions & 3 deletions hydra-node/test/Hydra/Chain/Direct/TxTraceSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import Hydra.Party (partyToChain)
import Hydra.Snapshot (ConfirmedSnapshot (..), Snapshot (..), SnapshotNumber (..), SnapshotVersion (..), number)
import PlutusTx.Builtins (toBuiltin)
import Test.Hydra.Fixture qualified as Fixture
import Test.QuickCheck (Property, Smart (..), checkCoverage, choose, cover, elements, forAll, frequency, ioProperty, oneof, shuffle, sublistOf, withMaxSuccess, (===))
import Test.QuickCheck (Property, Smart (..), choose, cover, elements, forAll, frequency, ioProperty, oneof, shuffle, sublistOf, withMaxSuccess, (===))
import Test.QuickCheck.Monadic (monadic)
import Test.QuickCheck.StateModel (
ActionWithPolarity (..),
Expand Down Expand Up @@ -83,7 +83,7 @@ spec = do
prop_traces :: Property
prop_traces =
forAll (arbitrary :: Gen (Actions Model)) $ \(Actions_ _ (Smart _ steps)) ->
-- FIXME: fix generators and minimums
-- FIXME: fix generators and minimums and re-enable coverage
-- checkCoverage $
True
& cover 1 (null steps) "empty"
Expand Down Expand Up @@ -279,7 +279,7 @@ initialAmount :: Natural
initialAmount = 10

initialModelUTxO :: ModelUTxO
initialModelUTxO = fromList $ [A, B, C, D, E] `zip` repeat initialAmount
initialModelUTxO = fromList $ map (,initialAmount) [A, B, C, D, E]

balanceUTxOInHead :: Ord k => Map k Natural -> Map k Natural -> Map k Natural
balanceUTxOInHead currentUtxoInHead someUTxOToDecrement =
Expand Down
4 changes: 2 additions & 2 deletions hydra-plutus/scripts/mHead.plutus

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions hydra-plutus/scripts/vHead.plutus

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions hydra-plutus/src/Hydra/Contract/Head.hs
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ checkClose ctx openBefore redeemer =
, headId = headId'
, contesters = contesters'
, version = version'
} = extractClosedDatum ctx
} = decodeHeadOutputClosedDatum ctx

-- (snapshotNumber', utxoHash', utxoDeltaHash', parties', deadline, cperiod', headId', contesters', version') =
-- extractClosedDatum ctx
-- decodeHeadOutputClosedDatum ctx

mustNotChangeVersion =
traceIfFalse $(errorCode MustNotChangeVersion) $
Expand Down Expand Up @@ -471,7 +471,7 @@ checkContest ctx closedDatum redeemer =
, headId = headId'
, contesters = contesters'
, version = version'
} = extractClosedDatum ctx
} = decodeHeadOutputClosedDatum ctx

ScriptContext{scriptContextTxInfo = txInfo} = ctx

Expand Down Expand Up @@ -657,7 +657,6 @@ hasPT headCurrencySymbol txOut =
in length pts == 1
{-# INLINEABLE hasPT #-}

-- TODO: use newtypes to not mix arguments?
verifySnapshotSignature :: [Party] -> (CurrencySymbol, SnapshotVersion, SnapshotNumber, Hash, Maybe Hash) -> [Signature] -> Bool
verifySnapshotSignature parties msg sigs =
traceIfFalse $(errorCode SignatureVerificationFailed) $
Expand Down Expand Up @@ -697,16 +696,17 @@ validatorScript = serialiseCompiledCode compiledValidator
validatorHash :: ScriptHash
validatorHash = scriptValidatorHash PlutusScriptV2 validatorScript

extractClosedDatum :: ScriptContext -> ClosedDatum
extractClosedDatum ctx =
decodeHeadOutputClosedDatum :: ScriptContext -> ClosedDatum
decodeHeadOutputClosedDatum ctx =
-- XXX: fromBuiltinData is super big (and also expensive?)
case fromBuiltinData @DatumType $ getDatum (headOutputDatum ctx) of
Just (Closed closedDatum) -> closedDatum
_ -> traceError $(errorCode WrongStateInOutputDatum)
{-# INLINEABLE extractClosedDatum #-}
{-# INLINEABLE decodeHeadOutputClosedDatum #-}

decodeHeadOutputOpenDatum :: ScriptContext -> OpenDatum
decodeHeadOutputOpenDatum ctx =
-- XXX: fromBuiltinData is super big (and also expensive?)
case fromBuiltinData @DatumType $ getDatum (headOutputDatum ctx) of
Just (Open openDatum) -> openDatum
_ -> traceError $(errorCode WrongStateInOutputDatum)
Expand Down
2 changes: 1 addition & 1 deletion hydra-plutus/src/Hydra/Contract/HeadTokens.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DuplicateRecordFields#-}
{-# OPTIONS_GHC -fno-specialize #-}
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:defer-errors #-}
-- Avoid trace calls to be optimized away when inlining functions.
Expand Down

0 comments on commit 38de24c

Please sign in to comment.