Skip to content

Commit

Permalink
Decrement mutation: check signature by altering redeemer
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed May 7, 2024
1 parent 8bfc4c0 commit c6f3975
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hydra-node/test/Hydra/Chain/Direct/Contract/Decrement.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ data DecrementMutation
--
-- Ensures the snapshot number is aligned.
MutateSnapshotNumber
| SnapshotSignatureInvalid
deriving stock (Generic, Show, Enum, Bounded)

genDecrementMutation :: (Tx, UTxO) -> Gen SomeMutation
Expand All @@ -164,6 +165,8 @@ genDecrementMutation (tx, _utxo) =
, SomeMutation (Just $ toErrorCode SnapshotNumberMismatch) MutateSnapshotNumber <$> do
mutatedSnapshotNumber <- arbitrarySizedNatural `suchThat` (< healthySnapshotNumber)
pure $ ChangeOutput 0 $ modifyInlineDatum (replaceSnapshotNumberInOpen $ toInteger mutatedSnapshotNumber) headTxOut
, SomeMutation (Just $ toErrorCode SignatureVerificationFailed) SnapshotSignatureInvalid . ChangeHeadRedeemer <$> do
Head.Decrement . toPlutusSignatures <$> (arbitrary :: Gen (MultiSignature (Snapshot Tx)))
]
where
headTxOut = fromJust $ txOuts' tx !!? 0

0 comments on commit c6f3975

Please sign in to comment.