Skip to content

Commit 0aae94b

Browse files
committed
Generate blueprints spending from key AND script
This was not covered before and seems like we have failing transactions now.
1 parent 5fdb315 commit 0aae94b

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

hydra-node/test/Hydra/Chain/Direct/TxSpec.hs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ import Test.Cardano.Ledger.Shelley.Arbitrary (genMetadata')
9494
import Test.Hydra.Fixture (genForParty)
9595
import Test.Hydra.Prelude
9696
import Test.QuickCheck (
97-
Positive (..),
9897
Property,
9998
checkCoverage,
10099
choose,
@@ -290,11 +289,10 @@ genBlueprintTxWithUTxO =
290289
>>= addSomeReferenceInputs
291290
>>= addValidityRange
292291
>>= addRandomMetadata
293-
>>= removeRandomInputs
294292
>>= addCollateralInput
295293
where
296294
spendingPubKeyOutput (utxo, txbody) = do
297-
utxoToSpend <- (genUTxOAdaOnlyOfSize . getPositive) . Positive =<< choose (0, 50)
295+
utxoToSpend <- genUTxOAdaOnlyOfSize =<< choose (0, 3)
298296
pure
299297
( utxo <> utxoToSpend
300298
, txbody & addVkInputs (toList $ UTxO.inputSet utxoToSpend)
@@ -303,8 +301,7 @@ genBlueprintTxWithUTxO =
303301
spendSomeScriptInputs (utxo, txbody) = do
304302
let alwaysSucceedingScript = PlutusScriptSerialised $ Plutus.alwaysSucceedingNAryFunction 3
305303
datum <- unsafeHashableScriptData . fromPlutusData <$> arbitrary
306-
redeemer <-
307-
unsafeHashableScriptData . fromPlutusData <$> arbitrary -- . B . BS.pack <$> vector n
304+
redeemer <- unsafeHashableScriptData . fromPlutusData <$> arbitrary
308305
let genTxOut = do
309306
value <- genValue
310307
let scriptAddress = mkScriptAddress testNetworkId alwaysSucceedingScript
@@ -340,10 +337,6 @@ genBlueprintTxWithUTxO =
340337
mtdt <- genMetadata
341338
pure (utxo, txbody{txMetadata = mtdt})
342339

343-
removeRandomInputs (utxo, txbody) = do
344-
someInput <- elements $ txIns txbody
345-
pure (utxo, txbody{txIns = [someInput]})
346-
347340
addCollateralInput (utxo, txbody) = do
348341
utxoToSpend <- genUTxOAdaOnlyOfSize 1
349342
pure
@@ -369,6 +362,7 @@ prop_interestingBlueprintTx = do
369362
True
370363
& cover 1 (spendsFromScript (utxo, tx)) "blueprint spends script UTxO"
371364
& cover 1 (spendsFromPubKey (utxo, tx)) "blueprint spends pub key UTxO"
365+
& cover 1 (spendsFromPubKey (utxo, tx) && spendsFromScript (utxo, tx)) "blueprint spends from script AND pub key"
372366
& cover 1 (hasReferenceInputs tx) "blueprint has reference input"
373367
where
374368
hasReferenceInputs tx =

0 commit comments

Comments
 (0)