Skip to content

Commit

Permalink
Decrement mutation: Remove random decommit output
Browse files Browse the repository at this point in the history
This should trigger the snapshot sig validation since we sign
whatever we decommit.
  • Loading branch information
v0d1ch authored and ch1bo committed Apr 17, 2024
1 parent 71c4bea commit 2e6d5b2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hydra-node/test/Hydra/Chain/Direct/Contract/Decrement.hs
Expand Up @@ -41,7 +41,7 @@ import Hydra.Plutus.Orphans ()
import Hydra.Snapshot (Snapshot (..), SnapshotNumber)
import PlutusTx.Builtins (toBuiltin)
import Test.Hydra.Fixture (aliceSk, bobSk, carolSk, genForParty)
import Test.QuickCheck (arbitrarySizedNatural, elements, oneof)
import Test.QuickCheck (arbitrarySizedNatural, choose, elements, oneof)
import Test.QuickCheck.Gen (suchThat)
import Test.QuickCheck.Instances ()

Expand Down Expand Up @@ -155,6 +155,8 @@ data DecrementMutation
--
-- Ensures values are preserved between head input and output.
MutateValueInOutput
| -- | Drop one of the decommit outputs from the tx. This should trigger snapshot signature validation to fail.
DropDecommitOutput
deriving stock (Generic, Show, Enum, Bounded)

genDecrementMutation :: (Tx, UTxO) -> Gen SomeMutation
Expand All @@ -180,6 +182,9 @@ genDecrementMutation (tx, _utxo) =
, SomeMutation (Just $ toErrorCode HeadValueIsNotPreserved) MutateValueInOutput <$> do
newValue <- genValue
pure $ ChangeOutput 0 (headTxOut{txOutValue = newValue})
, SomeMutation (Just $ toErrorCode SignatureVerificationFailed) DropDecommitOutput <$> do
ix <- choose (1, length (txOuts' tx) - 1)
pure $ RemoveOutput (fromIntegral ix)
]
where
headTxOut = fromJust $ txOuts' tx !!? 0

0 comments on commit 2e6d5b2

Please sign in to comment.