Skip to content

Commit

Permalink
ContestUsedDec MutateSnapshotVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed Oct 30, 2024
1 parent 814bd2c commit 65680bb
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions hydra-tx/test/Hydra/Tx/Contract/Contest/ContestUsedDec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,25 @@ import Hydra.Contract.HeadError (HeadError (..))
import Hydra.Contract.HeadState qualified as Head
import Hydra.Tx.Crypto (toPlutusSignatures)

import Hydra.Tx.Contract.Contest.Healthy (healthyContestSnapshotNumber, healthySignature)
import Hydra.Tx.Contract.Contest.Healthy (
healthyCloseSnapshotVersion,
healthyContestSnapshotNumber,
healthySignature,
)
import Test.Hydra.Tx.Mutation (
Mutation (..),
SomeMutation (..),
modifyInlineDatum,
replaceDeltaUTxOHash,
replaceSnapshotVersion,
)
import Test.QuickCheck (oneof, suchThat)
import Test.QuickCheck (arbitrarySizedNatural, oneof, suchThat)
import Test.QuickCheck.Instances ()

data ContestUsedDecMutation
= AlterRedeemerDecommitHash
| AlterDatumDeltaUTxOHash
| MutateSnapshotVersion
deriving stock (Generic, Show, Enum, Bounded)

genContestUsedDecMutation :: (Tx, UTxO) -> Gen SomeMutation
Expand All @@ -50,6 +56,9 @@ genContestUsedDecMutation (tx, _utxo) =
, SomeMutation (pure $ toErrorCode SignatureVerificationFailed) AlterDatumDeltaUTxOHash . ChangeOutput 0 <$> do
mutatedHash <- arbitrary `suchThat` (/= mempty)
pure $ headTxOut & modifyInlineDatum (replaceDeltaUTxOHash mutatedHash)
, SomeMutation (pure $ toErrorCode MustNotChangeVersion) MutateSnapshotVersion <$> do
mutatedSnapshotVersion <- arbitrarySizedNatural `suchThat` (/= healthyCloseSnapshotVersion)
pure $ ChangeOutput 0 $ modifyInlineDatum (replaceSnapshotVersion $ toInteger mutatedSnapshotVersion) headTxOut
]
where
headTxOut = fromJust $ txOuts' tx !!? 0

0 comments on commit 65680bb

Please sign in to comment.