Skip to content

Commit

Permalink
ContestUsedDec AlterRedeemerDecommitHash
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch committed Oct 30, 2024
1 parent 85f4c36 commit 30303e8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
22 changes: 17 additions & 5 deletions hydra-tx/test/Hydra/Tx/Contract/Contest/ContestUsedDec.hs
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
{-# LANGUAGE DuplicateRecordFields #-}
{-# OPTIONS_GHC -Wno-orphans #-}

module Hydra.Tx.Contract.Contest.ContestUsedDec where

import Hydra.Cardano.Api
import Hydra.Prelude hiding (label)

import Hydra.Tx.Contract.Contest.Healthy ()
import Hydra.Contract.Error (toErrorCode)
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 Test.Hydra.Tx.Mutation (
Mutation (..),
SomeMutation (..),
)
import Test.QuickCheck (oneof)
import Test.QuickCheck.Instances ()

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

genContestUsedDecMutation :: (Tx, UTxO) -> Gen SomeMutation
genContestUsedDecMutation (_tx, _utxo) =
oneof []
SomeMutation (pure $ toErrorCode FailedContestUsedDec) AlterRedeemerDecommitHash <$> do
pure $
ChangeHeadRedeemer $
Head.Contest
Head.ContestUsedDec
{ signature = toPlutusSignatures (healthySignature healthyContestSnapshotNumber)
, alreadyDecommittedUTxOHash = mempty
}
6 changes: 6 additions & 0 deletions hydra-tx/test/Hydra/Tx/Contract/ContractSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Hydra.Tx.Contract.Close.CloseUsed (genCloseOutdatedMutation, healthyClose
import Hydra.Tx.Contract.CollectCom (genCollectComMutation, healthyCollectComTx)
import Hydra.Tx.Contract.Commit (genCommitMutation, healthyCommitTx)
import Hydra.Tx.Contract.Contest.ContestCurrent (genContestMutation)
import Hydra.Tx.Contract.Contest.ContestUsedDec (genContestUsedDecMutation)
import Hydra.Tx.Contract.Contest.Healthy (healthyContestTx)
import Hydra.Tx.Contract.Decrement (genDecrementMutation, healthyDecrementTx)
import Hydra.Tx.Contract.Deposit (healthyDepositTx)
Expand Down Expand Up @@ -148,6 +149,11 @@ spec = parallel $ do
propTransactionEvaluates healthyContestTx
prop "does not survive random adversarial mutations" $
propMutation healthyContestTx genContestMutation
describe "ContestUsedDec" $ do
prop "is healthy" $
propTransactionEvaluates healthyContestTx
prop "does not survive random adversarial mutations" $
propMutation healthyContestTx genContestUsedDecMutation
describe "Fanout" $ do
prop "is healthy" $
propTransactionEvaluates healthyFanoutTx
Expand Down

0 comments on commit 30303e8

Please sign in to comment.