Skip to content

Commit ebed62d

Browse files
authored
Merge pull request #5851 from IntersectMBO/lehins/add-predicate-failure-tests
Organize predicate failure CBOR roundtrip tests
2 parents af1179d + 42219c0 commit ebed62d

43 files changed

Lines changed: 310 additions & 291 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eras/allegra/impl/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
### `testlib`
1616

17+
* Export `shelleyToBabbageSpec`
1718
* Make `Test.Cardano.Ledger.Allegra.Imp.spec` accept `Proxy era`
1819
* In `Test.Cardano.Ledger.Allegra.Examples`:
1920
- Remove `mkAllegraBasedExampleTx`, `exampleAllegraBasedTxBody`, `exampleAllegraBasedShelleyTxBody`

eras/allegra/impl/test/Main.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ import qualified Test.Cardano.Ledger.Allegra.Imp as Imp
1111
import Test.Cardano.Ledger.Allegra.ImpTest ()
1212
import Test.Cardano.Ledger.Core.JSON (roundTripJsonEraSpec)
1313
import Test.Cardano.Ledger.Era
14-
import qualified Test.Cardano.Ledger.Shelley.Imp as Imp (shelleyEraSpecificSpec)
1514
import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec)
1615

1716
instance EraSpec AllegraEra where
1817
eraImpSpec era = do
19-
Imp.shelleyEraSpecificSpec era
18+
Imp.shelleyToBabbageSpec era
2019
Imp.spec era
2120

2221
main :: IO ()

eras/allegra/impl/test/Test/Cardano/Ledger/Allegra/BinarySpec.hs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import Test.Cardano.Ledger.Allegra.Era ()
1212
import Test.Cardano.Ledger.Allegra.TreeDiff ()
1313
import Test.Cardano.Ledger.Common
1414
import Test.Cardano.Ledger.Core.Binary as Binary (decoderEquivalenceCoreEraTypesSpec, txSizeSpec)
15-
import Test.Cardano.Ledger.Core.Binary.RoundTrip (RuleListEra (..))
1615
import Test.Cardano.Ledger.Shelley.Binary.RoundTrip (roundTripShelleyCommonSpec)
1716

1817
spec :: Spec
@@ -22,17 +21,3 @@ spec = do
2221
describe "DecCBOR instances equivalence" $ do
2322
Binary.decoderEquivalenceCoreEraTypesSpec @AllegraEra
2423
Binary.txSizeSpec @AllegraEra
25-
26-
instance RuleListEra AllegraEra where
27-
type
28-
EraRules AllegraEra =
29-
'[ "DELEG"
30-
, "DELEGS"
31-
, "DELPL"
32-
, "LEDGER"
33-
, "LEDGERS"
34-
, "POOL"
35-
, "PPUP"
36-
, "UTXO"
37-
, "UTXOW"
38-
]

eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Era.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
{-# LANGUAGE DataKinds #-}
12
{-# LANGUAGE FlexibleContexts #-}
3+
{-# LANGUAGE TypeFamilies #-}
24
{-# LANGUAGE UndecidableSuperClasses #-}
35
{-# OPTIONS_GHC -Wno-orphans #-}
46

@@ -37,6 +39,20 @@ class
3739
AllegraEraTest era
3840

3941
instance EraTest AllegraEra where
42+
type
43+
EraRulesWithFailures AllegraEra =
44+
'[ "BBODY"
45+
, "DELEG"
46+
, "DELEGS"
47+
, "DELPL"
48+
, "LEDGER"
49+
, "LEDGERS"
50+
, "POOL"
51+
, "PPUP"
52+
, "UTXO"
53+
, "UTXOW"
54+
]
55+
4056
zeroCostModels = emptyCostModels
4157

4258
mkTestAccountState = mkShelleyTestAccountState

eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Imp.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{-# LANGUAGE TypeFamilies #-}
44
{-# LANGUAGE TypeOperators #-}
55

6-
module Test.Cardano.Ledger.Allegra.Imp (spec) where
6+
module Test.Cardano.Ledger.Allegra.Imp (spec, Shelley.shelleyToBabbageSpec) where
77

88
import Cardano.Ledger.Core
99
import qualified Cardano.Ledger.Shelley.Rules as Shelley

eras/alonzo/impl/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
### `testlib`
5151

52+
* Add `Arbitrary` instance for `AlonzoBbodyPredFailure`
5253
* Add to `Test.Cardano.Ledger.Alonzo.Examples`:
5354
- `exampleAlonzoPParams`
5455
- `exampleAlonzoPParamsUpdate`

eras/alonzo/impl/test/Main.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@ import Test.Cardano.Ledger.Alonzo.ImpTest ()
1717
import Test.Cardano.Ledger.Common
1818
import Test.Cardano.Ledger.Core.JSON (roundTripJsonEraSpec)
1919
import Test.Cardano.Ledger.Era
20-
import qualified Test.Cardano.Ledger.Shelley.Imp as Shelley
2120
import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec)
2221

2322
instance EraSpec AlonzoEra where
2423
eraImpSpec era = do
25-
Shelley.shelleyEraSpecificSpec era
26-
Imp.alonzoEraSpecificSpec era
24+
Imp.shelleyToBabbageSpec era
25+
Imp.alonzoToConwaySpec era
2726
Imp.spec era
2827

2928
main :: IO ()

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Arbitrary.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import Cardano.Ledger.Alonzo.Plutus.Context (
5151
import Cardano.Ledger.Alonzo.Plutus.Evaluate (CollectError)
5252
import Cardano.Ledger.Alonzo.Plutus.TxInfo (AlonzoContextError)
5353
import Cardano.Ledger.Alonzo.Rules (
54+
AlonzoBbodyPredFailure,
5455
AlonzoUtxoPredFailure (..),
5556
AlonzoUtxosPredFailure (..),
5657
AlonzoUtxowPredFailure (..),
@@ -358,6 +359,14 @@ instance
358359
where
359360
arbitrary = genericArbitraryU
360361

362+
instance
363+
( Era era
364+
, Arbitrary (Shelley.PredicateFailure (EraRule "LEDGERS" era))
365+
) =>
366+
Arbitrary (AlonzoBbodyPredFailure era)
367+
where
368+
arbitrary = genericArbitraryU
369+
361370
deriving instance Arbitrary ix => Arbitrary (AsIx ix it)
362371

363372
deriving instance Arbitrary it => Arbitrary (AsItem ix it)

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Binary/RoundTrip.hs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module Test.Cardano.Ledger.Alonzo.Binary.RoundTrip (
1313
roundTripAlonzoEraTypesSpec,
1414
) where
1515

16-
import Cardano.Ledger.Alonzo (AlonzoEra)
1716
import Cardano.Ledger.Alonzo.Scripts (
1817
AlonzoEraScript (..),
1918
AsIx (..),
@@ -26,20 +25,14 @@ import Test.Cardano.Ledger.Alonzo.Era (AlonzoEraTest)
2625
import Test.Cardano.Ledger.Common
2726
import Test.Cardano.Ledger.Core.Arbitrary (genValidCostModels)
2827
import Test.Cardano.Ledger.Core.Binary.RoundTrip (
29-
RuleListEra (..),
3028
roundTripAnnEraTypeSpec,
3129
roundTripEraExpectation,
3230
roundTripEraTypeExpectation,
3331
roundTripEraTypeSpec,
3432
)
3533
import Test.Cardano.Ledger.Shelley.Binary.RoundTrip (roundTripShelleyCommonSpec)
3634

37-
roundTripAlonzoCommonSpec ::
38-
forall era.
39-
( AlonzoEraTest era
40-
, RuleListEra era
41-
) =>
42-
Spec
35+
roundTripAlonzoCommonSpec :: forall era. AlonzoEraTest era => Spec
4336
roundTripAlonzoCommonSpec = do
4437
roundTripAlonzoEraTypesSpec @era
4538
roundTripShelleyCommonSpec @era
@@ -69,18 +62,3 @@ roundTripAlonzoEraTypesSpec = do
6962
prop "Redeemers" $
7063
forAll genNonEmptyRedeemers $
7164
roundTripEraTypeExpectation @era @Redeemers
72-
73-
instance RuleListEra AlonzoEra where
74-
type
75-
EraRules AlonzoEra =
76-
'[ "DELEG"
77-
, "DELEGS"
78-
, "DELPL"
79-
, "LEDGER"
80-
, "LEDGERS"
81-
, "POOL"
82-
, "PPUP"
83-
, "UTXO"
84-
, "UTXOW"
85-
, "UTXOS"
86-
]

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Era.hs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ class
4545
AlonzoEraTest era
4646

4747
instance EraTest AlonzoEra where
48+
type
49+
EraRulesWithFailures AlonzoEra =
50+
'[ "BBODY"
51+
, "DELEG"
52+
, "DELEGS"
53+
, "DELPL"
54+
, "LEDGER"
55+
, "LEDGERS"
56+
, "POOL"
57+
, "PPUP"
58+
, "UTXO"
59+
, "UTXOS"
60+
, "UTXOW"
61+
]
62+
4863
zeroCostModels = zeroTestingCostModels [PlutusV1]
4964

5065
mkTestAccountState = mkShelleyTestAccountState

0 commit comments

Comments
 (0)