Skip to content

Commit

Permalink
Decrement mutation: participant signed decrement tx check
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed May 7, 2024
1 parent 56a74a1 commit 32de7e7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hydra-node/test/Hydra/Chain/Direct/Contract/Decrement.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ data DecrementMutation
-- Ensures the snapshot number is aligned.
MutateSnapshotNumber
| SnapshotSignatureInvalid
| -- | Produce invalid signature by changing signers in the redeemer
SnapshotSignatureInvalid
| -- | Ensures decrement is authenticated by one of the Head members by changing
-- the signer used on the tx to not be one of PTs.
MutateRequiredSigner
deriving stock (Generic, Show, Enum, Bounded)

genDecrementMutation :: (Tx, UTxO) -> Gen SomeMutation
Expand All @@ -169,6 +174,9 @@ genDecrementMutation (tx, _utxo) =
pure $ ChangeOutput 0 $ modifyInlineDatum (replaceSnapshotNumberInOpen $ toInteger mutatedSnapshotNumber) headTxOut
, SomeMutation (Just $ toErrorCode SignatureVerificationFailed) SnapshotSignatureInvalid . ChangeHeadRedeemer <$> do
Head.Decrement . toPlutusSignatures <$> (arbitrary :: Gen (MultiSignature (Snapshot Tx)))
, SomeMutation (Just $ toErrorCode SignerIsNotAParticipant) MutateRequiredSigner <$> do
newSigner <- verificationKeyHash <$> genVerificationKey `suchThat` (/= somePartyCardanoVerificationKey)
pure $ ChangeRequiredSigners [newSigner]
]
where
headTxOut = fromJust $ txOuts' tx !!? 0

0 comments on commit 32de7e7

Please sign in to comment.