Skip to content

Commit

Permalink
Inline closeRedeemer
Browse files Browse the repository at this point in the history
  • Loading branch information
v0d1ch authored and ch1bo committed Jan 24, 2023
1 parent f56d05c commit ef28398
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions hydra-node/test/Hydra/Chain/Direct/Contract/Close.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Hydra.Ledger (hashUTxO)
import Hydra.Ledger.Cardano (genOneUTxOFor, genVerificationKey)
import Hydra.Ledger.Cardano.Evaluate (genValidityBoundsFromContestationPeriod, slotNoToUTCTime)
import Hydra.Party (Party, deriveParty, partyToChain)
import Hydra.Snapshot (Snapshot (..), SnapshotNumber (UnsafeSnapshotNumber))
import Hydra.Snapshot (Snapshot (..), SnapshotNumber)
import Plutus.Orphans ()
import Plutus.V2.Ledger.Api (BuiltinByteString, toBuiltin, toData)
import Test.Hydra.Fixture (aliceSk, bobSk, carolSk)
Expand Down Expand Up @@ -168,15 +168,11 @@ data CloseMutation

genCloseMutation :: (Tx, UTxO) -> Gen SomeMutation
genCloseMutation (tx, _utxo) =
-- FIXME: using 'closeRedeemer' here is actually too high-level and reduces
-- the power of the mutators, we should test at the level of the validator.
-- That is, using the on-chain types. 'closeRedeemer' is also not used
-- anywhere after changing this and can be moved into the closeTx
oneof
[ SomeMutation Nothing MutateSignatureButNotSnapshotNumber . ChangeHeadRedeemer <$> do
closeRedeemer <$> (arbitrary :: Gen (MultiSignature (Snapshot Tx)))
Head.Close . toPlutusSignatures <$> (arbitrary :: Gen (MultiSignature (Snapshot Tx)))
, SomeMutation Nothing MutateSnapshotNumberButNotSignature . ChangeHeadDatum <$> do
(UnsafeSnapshotNumber mutatedSnapshotNumber) <- arbitrarySizedNatural `suchThat` (\n -> n /= healthySnapshotNumber && n > 0)
mutatedSnapshotNumber <- arbitrarySizedNatural `suchThat` (\n -> n /= healthySnapshotNumber && n > 0)
pure $
Head.Closed
{ snapshotNumber = toInteger mutatedSnapshotNumber
Expand Down Expand Up @@ -243,11 +239,6 @@ genCloseMutation (tx, _utxo) =
where
headTxOut = fromJust $ txOuts' tx !!? 0

closeRedeemer sig =
Head.Close
{ signature = toPlutusSignatures sig
}

mutateCloseUTxOHash :: Gen (TxOut CtxTx)
mutateCloseUTxOHash = do
mutatedUTxOHash <- genHash
Expand Down

0 comments on commit ef28398

Please sign in to comment.