File tree Expand file tree Collapse file tree 2 files changed +29
-5
lines changed
libs/cardano-ledger-core/testlib/Test/Cardano/Ledger Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -914,6 +914,15 @@ instance Arbitrary PV1.Data where
914914 ]
915915 | otherwise = oneof [PV1. I <$> arbitrary, PV1. B <$> arbitrary]
916916
917+ instance Arbitrary PV1. ExBudget where
918+ arbitrary = PV1. ExBudget <$> arbitrary <*> arbitrary
919+
920+ instance Arbitrary PV1. ExCPU where
921+ arbitrary = fromInteger . getNonNegative <$> arbitrary
922+
923+ instance Arbitrary PV1. ExMemory where
924+ arbitrary = fromInteger . getNonNegative <$> arbitrary
925+
917926genValidCostModel :: Language -> Gen CostModel
918927genValidCostModel lang = do
919928 newParamValues <- vectorOf (costModelInitParamCount lang) arbitrary
Original file line number Diff line number Diff line change @@ -9,13 +9,28 @@ import Test.Cardano.Ledger.Core.Arbitrary ()
99
1010spec :: Spec
1111spec = do
12- prop " Round-trip to ExBudget" exUnitsTranslationRoundTrip
12+ prop " Round-trip to ExBudget" exUnitsToExBudgetRoundTrip
13+ prop " Round-trip from ExBudget" exBudgetToExUnitsRoundTrip
1314
14- -- ExUnits should remain intact when translating to and from the plutus type
15- exUnitsTranslationRoundTrip :: Gen Property
16- exUnitsTranslationRoundTrip = do
15+ -- ExUnits should remain intact when translating to and from the Plutus ExBudget type
16+ exUnitsToExBudgetRoundTrip :: Gen Property
17+ exUnitsToExBudgetRoundTrip = do
1718 e <- arbitrary
18- let result = exBudgetToExUnits (transExUnits e)
19+ let result = exBudgetToExUnits $ transExUnits e
20+ pure
21+ $ counterexample
22+ ( " Before: "
23+ <> show e
24+ <> " \n After: "
25+ <> show result
26+ )
27+ $ result == Just e
28+
29+ -- Plutus ExBudget should remain intact when translating to and from the ExUnits type
30+ exBudgetToExUnitsRoundTrip :: Gen Property
31+ exBudgetToExUnitsRoundTrip = do
32+ e <- arbitrary
33+ let result = transExUnits <$> exBudgetToExUnits e
1934 pure
2035 $ counterexample
2136 ( " Before: "
You can’t perform that action at this time.
0 commit comments