Skip to content

Commit

Permalink
Generate blueprints spending from key AND script
Browse files Browse the repository at this point in the history
This was not covered before and seems like we have failing transactions now.
  • Loading branch information
ch1bo committed May 6, 2024
1 parent 26e6e97 commit 226edac
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions hydra-node/test/Hydra/Chain/Direct/TxSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ import Test.Cardano.Ledger.Shelley.Arbitrary (genMetadata')
import Test.Hydra.Fixture (genForParty)
import Test.Hydra.Prelude
import Test.QuickCheck (
Positive (..),
Property,
checkCoverage,
choose,
Expand Down Expand Up @@ -290,11 +289,10 @@ genBlueprintTxWithUTxO =
>>= addSomeReferenceInputs
>>= addValidityRange
>>= addRandomMetadata
>>= removeRandomInputs
>>= addCollateralInput
where
spendingPubKeyOutput (utxo, txbody) = do
utxoToSpend <- (genUTxOAdaOnlyOfSize . getPositive) . Positive =<< choose (0, 50)
utxoToSpend <- genUTxOAdaOnlyOfSize =<< choose (0, 3)
pure
( utxo <> utxoToSpend
, txbody & addVkInputs (toList $ UTxO.inputSet utxoToSpend)
Expand All @@ -303,8 +301,7 @@ genBlueprintTxWithUTxO =
spendSomeScriptInputs (utxo, txbody) = do
let alwaysSucceedingScript = PlutusScriptSerialised $ Plutus.alwaysSucceedingNAryFunction 3
datum <- unsafeHashableScriptData . fromPlutusData <$> arbitrary
redeemer <-
unsafeHashableScriptData . fromPlutusData <$> arbitrary -- . B . BS.pack <$> vector n
redeemer <- unsafeHashableScriptData . fromPlutusData <$> arbitrary
let genTxOut = do
value <- genValue
let scriptAddress = mkScriptAddress testNetworkId alwaysSucceedingScript
Expand Down Expand Up @@ -340,10 +337,6 @@ genBlueprintTxWithUTxO =
mtdt <- genMetadata
pure (utxo, txbody{txMetadata = mtdt})

removeRandomInputs (utxo, txbody) = do
someInput <- elements $ txIns txbody
pure (utxo, txbody{txIns = [someInput]})

addCollateralInput (utxo, txbody) = do
utxoToSpend <- genUTxOAdaOnlyOfSize 1
pure
Expand All @@ -369,6 +362,7 @@ prop_interestingBlueprintTx = do
True
& cover 1 (spendsFromScript (utxo, tx)) "blueprint spends script UTxO"
& cover 1 (spendsFromPubKey (utxo, tx)) "blueprint spends pub key UTxO"
& cover 1 (spendsFromPubKey (utxo, tx) && spendsFromScript (utxo, tx)) "blueprint spends from script AND pub key"
& cover 1 (hasReferenceInputs tx) "blueprint has reference input"
where
hasReferenceInputs tx =
Expand Down

0 comments on commit 226edac

Please sign in to comment.