Skip to content

Commit

Permalink
Remove a now invalid mutation test
Browse files Browse the repository at this point in the history
  • Loading branch information
ch1bo committed Jul 10, 2024
1 parent 30b3677 commit 363bd2a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
15 changes: 5 additions & 10 deletions hydra-node/test/Hydra/Chain/Direct/Contract/Close/CloseCurrent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ data CloseMutation
MutateSnapshotNumberButNotSignature
| -- | Check the snapshot version is preserved from last open state.
MutateSnapshotVersion
| -- | Check that snapshot numbers = 0 need to close the head with the
-- initial UTxO hash.
MutateInitialSnapshotNumber
| -- | Ensures the close snapshot is multisigned by all Head participants by
-- changing the parties in the input head datum. If they do not align the
-- multisignature will not be valid anymore.
Expand Down Expand Up @@ -154,6 +151,11 @@ data CloseMutation
MutateContestationPeriod
deriving stock (Generic, Show, Enum, Bounded)

-- TODO: Add mutations which work "this way" around now. For example, before
-- we did mutate a close with signed snapshot to result in snapshot number 0,
-- which would trigger the validator. However, that would not be a faithful
-- representation of an "attack" anymore. Now, the tx creator needs to claim
-- what situation we are in now and how the snapshot signature is valid.
genCloseCurrentMutation :: (Tx, UTxO) -> Gen SomeMutation
genCloseCurrentMutation (tx, _utxo) =
oneof
Expand All @@ -163,13 +165,6 @@ genCloseCurrentMutation (tx, _utxo) =
, SomeMutation (pure $ toErrorCode SignatureVerificationFailed) MutateSignatureButNotSnapshotNumber . ChangeHeadRedeemer <$> do
signature <- toPlutusSignatures <$> (arbitrary :: Gen (MultiSignature (Snapshot Tx)))
pure $ Head.Close Head.CloseCurrent{signature}
, SomeMutation (pure $ toErrorCode ClosedWithNonInitialHash) MutateInitialSnapshotNumber <$> do
let mutatedSnapshotNumber = 0
pure $
Changes
[ ChangeOutput 0 $ modifyInlineDatum (replaceSnapshotNumber mutatedSnapshotNumber) headTxOut
, ChangeInputHeadDatum healthyCurrentOpenDatum{Head.utxoHash = ""}
]
, SomeMutation (pure $ toErrorCode SignatureVerificationFailed) MutateSnapshotNumberButNotSignature <$> do
mutatedSnapshotNumber <- arbitrarySizedNatural `suchThat` (> healthyCurrentSnapshotNumber)
pure $ ChangeOutput 0 $ modifyInlineDatum (replaceSnapshotNumber $ toInteger mutatedSnapshotNumber) headTxOut
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ data CloseMutation
MutateContestationPeriod
deriving stock (Generic, Show, Enum, Bounded)

-- TODO: Add mutations which work "this way" around now. For example, before
-- we did mutate a close with signed snapshot to result in snapshot number 0,
-- which would trigger the validator. However, that would not be a faithful
-- representation of an "attack" anymore. Now, the tx creator needs to claim
-- what situation we are in now and how the snapshot signature is valid.
genCloseOutdatedMutation :: (Tx, UTxO) -> Gen SomeMutation
genCloseOutdatedMutation (tx, _utxo) =
oneof
Expand All @@ -228,13 +233,6 @@ genCloseOutdatedMutation (tx, _utxo) =
, SomeMutation (pure $ toErrorCode SignatureVerificationFailed) MutateSignatureButNotSnapshotNumber . ChangeHeadRedeemer <$> do
signature <- toPlutusSignatures <$> (arbitrary :: Gen (MultiSignature (Snapshot Tx)))
pure $ Head.Close Head.CloseCurrent{signature}
, SomeMutation (pure $ toErrorCode ClosedWithNonInitialHash) MutateInitialSnapshotNumber <$> do
let mutatedSnapshotNumber = 0
pure $
Changes
[ ChangeOutput 0 $ modifyInlineDatum (replaceSnapshotNumber mutatedSnapshotNumber) headTxOut
, ChangeInputHeadDatum healthyOutdatedOpenDatum{Head.utxoHash = ""}
]
, SomeMutation (pure $ toErrorCode SignatureVerificationFailed) MutateSnapshotNumberButNotSignature <$> do
mutatedSnapshotNumber <- arbitrarySizedNatural `suchThat` (> healthyOutdatedSnapshotNumber)
pure $ ChangeOutput 0 $ modifyInlineDatum (replaceSnapshotNumber $ toInteger mutatedSnapshotNumber) headTxOut
Expand Down

0 comments on commit 363bd2a

Please sign in to comment.