Skip to content

Commit

Permalink
Improve genScriptData to generate larger range of numbers
Browse files Browse the repository at this point in the history
for `ScriptDataNumber` constructor including numbers outside
`maxBound @Word64`.
  • Loading branch information
sorki authored and newhoggy committed Mar 28, 2023
1 parent e23004f commit f561c6c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,21 @@ genScriptData =
, ScriptDataBytes <$> genByteString
]
-- The Gen.recursive combinator calls these with the size halved
[ ScriptDataConstructor <$> genInteger
[ ScriptDataConstructor <$> genConstructorInteger
<*> genScriptDataList
, ScriptDataList <$> genScriptDataList
, ScriptDataMap <$> genScriptDataMap
]
where
genInteger :: Gen Integer
genInteger = Gen.integral
(Range.linear
(-fromIntegral (maxBound :: Word64) :: Integer)
(2 * fromIntegral (maxBound :: Word64) :: Integer))


genConstructorInteger :: Gen Integer
genConstructorInteger = Gen.integral
(Range.linear
0 -- TODO: Alonzo should be -> (-fromIntegral (maxBound :: Word64) :: Integer)
-- Wrapping bug needs to be fixed in Plutus library
Expand Down

0 comments on commit f561c6c

Please sign in to comment.