Skip to content

Commit

Permalink
Adjust tx generator to workaround ledger serialisation issue
Browse files Browse the repository at this point in the history
The a_0 param can only handle rationals using 2^63, not 2^64.

This can be reverted once this ledger PR (or equivalent) is merged:

IntersectMBO/cardano-ledger#2330
  • Loading branch information
dcoutts committed Jun 12, 2021
1 parent 15dafb9 commit 5633bab
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cardano-api-gen/src/Gen/Cardano/Api/Typed.hs
Expand Up @@ -699,6 +699,18 @@ genRational =
ratioToRational :: Ratio Word64 -> Rational
ratioToRational = toRational

-- TODO: consolidate this back to just genRational once this is merged:
-- https://github.com/input-output-hk/cardano-ledger-specs/pull/2330
genRationalInt64 :: Gen Rational
genRationalInt64 =
(\d -> ratioToRational (1 % d)) <$> genDenominator
where
genDenominator :: Gen Int64
genDenominator = Gen.integral (Range.linear 1 maxBound)

ratioToRational :: Ratio Int64 -> Rational
ratioToRational = toRational

genEpochNo :: Gen EpochNo
genEpochNo = EpochNo <$> Gen.word64 (Range.linear 0 10)

Expand All @@ -725,7 +737,7 @@ genProtocolParameters =
<*> genLovelace
<*> genEpochNo
<*> genNat
<*> genRational
<*> genRationalInt64
<*> genRational
<*> genRational
<*> Gen.maybe genLovelace
Expand Down Expand Up @@ -754,7 +766,7 @@ genProtocolParametersUpdate =
<*> Gen.maybe genLovelace
<*> Gen.maybe genEpochNo
<*> Gen.maybe genNat
<*> Gen.maybe genRational
<*> Gen.maybe genRationalInt64
<*> Gen.maybe genRational
<*> Gen.maybe genRational
<*> Gen.maybe genLovelace
Expand Down

0 comments on commit 5633bab

Please sign in to comment.