Skip to content

Commit

Permalink
Generator for TxInsCollateral
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Jun 14, 2021
1 parent 4783593 commit 0d7c1dd
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cardano-api-gen/src/Gen/Cardano/Api/Typed.hs
Expand Up @@ -473,6 +473,7 @@ genTxMintValue era =
genTxBodyContent :: CardanoEra era -> Gen (TxBodyContent BuildTx era)
genTxBodyContent era = do
trxIns <- Gen.list (Range.constant 1 10) genTxIn
txInCollateral' <- genTxInsCollateral era
trxOuts <- Gen.list (Range.constant 1 10) (genTxOut era)
fee <- genTxFee era
validityRange <- genTxValidityRange era
Expand All @@ -486,7 +487,7 @@ genTxBodyContent era = do

pure $ TxBodyContent
{ txIns = map (, BuildTxWith (KeyWitness KeyWitnessForSpending)) trxIns
, txInsCollateral = TxInsCollateralNone --TODO: Alonzo era: Generate collateral inputs.
, txInsCollateral = txInCollateral'
, txOuts = trxOuts
, txFee = fee
, txValidityRange = validityRange
Expand All @@ -501,6 +502,18 @@ genTxBodyContent era = do
, txMintValue = mintValue
}

genTxInsCollateral :: CardanoEra era -> Gen (TxInsCollateral era)
genTxInsCollateral era =
case era of
ByronEra -> pure TxInsCollateralNone
ShelleyEra -> pure TxInsCollateralNone
AllegraEra -> pure TxInsCollateralNone
MaryEra -> pure TxInsCollateralNone
AlonzoEra -> Gen.choice
[ pure TxInsCollateralNone
, TxInsCollateral CollateralInAlonzoEra <$> Gen.list (Range.linear 0 10) genTxIn
]

genTxFee :: CardanoEra era -> Gen (TxFee era)
genTxFee era =
case txFeesExplicitInEra era of
Expand Down

0 comments on commit 0d7c1dd

Please sign in to comment.