Skip to content

Commit 8f142fa

Browse files
committed
Add EraSpec and ledgerEraTestMain
This commit introduces a general hierarchy for common era testing
1 parent 183cfee commit 8f142fa

51 files changed

Lines changed: 220 additions & 210 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+
* Make `Test.Cardano.Ledger.Allegra.Imp.spec` accept `Proxy era`
1718
* In `Test.Cardano.Ledger.Allegra.Examples`:
1819
- Remove `mkAllegraBasedExampleTx`, `exampleAllegraBasedTxBody`, `exampleAllegraBasedShelleyTxBody`
1920
- Add `exampleAllegraBasedTx`

eras/allegra/impl/test/Main.hs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE TypeApplications #-}
2+
{-# OPTIONS_GHC -Wno-orphans #-}
23

34
module Main where
45

@@ -8,18 +9,18 @@ import qualified Test.Cardano.Ledger.Allegra.Binary.Golden as Golden
89
import qualified Test.Cardano.Ledger.Allegra.BinarySpec as BinarySpec
910
import qualified Test.Cardano.Ledger.Allegra.Imp as Imp
1011
import Test.Cardano.Ledger.Allegra.ImpTest ()
11-
import Test.Cardano.Ledger.Common
1212
import Test.Cardano.Ledger.Core.JSON (roundTripJsonEraSpec)
13+
import Test.Cardano.Ledger.Era
1314
import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec)
1415

16+
instance EraSpec AllegraEra where
17+
eraImpSpec = Imp.spec
18+
1519
main :: IO ()
1620
main =
17-
ledgerTestMain $
18-
describe "Allegra" $ do
19-
BinarySpec.spec
20-
CddlSpec.spec
21-
describe "Imp" $ do
22-
Imp.spec @AllegraEra
23-
roundTripJsonEraSpec @AllegraEra
24-
roundTripJsonShelleyEraSpec @AllegraEra
25-
Golden.spec @AllegraEra
21+
ledgerEraTestMain @AllegraEra $ do
22+
BinarySpec.spec
23+
CddlSpec.spec
24+
roundTripJsonEraSpec @AllegraEra
25+
roundTripJsonShelleyEraSpec @AllegraEra
26+
Golden.spec @AllegraEra

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
{-# LANGUAGE AllowAmbiguousTypes #-}
21
{-# LANGUAGE DataKinds #-}
32
{-# LANGUAGE FlexibleContexts #-}
4-
{-# LANGUAGE ScopedTypeVariables #-}
5-
{-# LANGUAGE TypeApplications #-}
63
{-# LANGUAGE TypeFamilies #-}
74
{-# LANGUAGE TypeOperators #-}
85
{-# OPTIONS_GHC -Wno-orphans #-}
@@ -17,14 +14,14 @@ import Test.Cardano.Ledger.Imp.Common
1714
import qualified Test.Cardano.Ledger.Shelley.Imp as ShelleyImp
1815

1916
spec ::
20-
forall era.
2117
( ShelleyEraImp era
2218
, EraSpecificSpec era
2319
, Event (EraRule "RUPD" era) ~ RupdEvent
2420
) =>
21+
proxy era ->
2522
Spec
26-
spec = do
27-
ShelleyImp.spec @era
23+
spec era = do
24+
ShelleyImp.spec era
2825

2926
instance EraSpecificSpec AllegraEra where
3027
eraSpecificSpec = ShelleyImp.shelleyEraSpecificSpec

eras/alonzo/impl/CHANGELOG.md

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

4545
### `testlib`
4646

47+
* Make `Test.Cardano.Ledger.Alonzo.Imp.spec` accept `Proxy era`
4748
* Add `genDatumPresent`
4849
* Added `Proxy era` argument to `exUnitsRule`
4950
* `TranslationInstance` has a new field `tiPlutusPurpose`

eras/alonzo/impl/cardano-ledger-alonzo.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ library
9898
cardano-ledger-allegra ^>=1.10,
9999
cardano-ledger-binary ^>=1.9,
100100
cardano-ledger-core:{cardano-ledger-core, internal} ^>=1.21,
101-
cardano-ledger-mary ^>=1.10.1,
101+
cardano-ledger-mary ^>=1.11,
102102
cardano-ledger-shelley ^>=1.19,
103103
cardano-slotting,
104104
cardano-strict-containers,

eras/alonzo/impl/test/Main.hs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE TypeApplications #-}
2+
{-# OPTIONS_GHC -Wno-orphans #-}
23

34
module Main where
45

@@ -11,27 +12,28 @@ import qualified Test.Cardano.Ledger.Alonzo.BinarySpec as BinarySpec
1112
import qualified Test.Cardano.Ledger.Alonzo.GoldenSpec as Golden
1213
import qualified Test.Cardano.Ledger.Alonzo.GoldenTranslation as GoldenTranslation
1314
import qualified Test.Cardano.Ledger.Alonzo.Imp as Imp
14-
import qualified Test.Cardano.Ledger.Alonzo.Imp.TxInfoSpec as TxInfoImp
15+
import qualified Test.Cardano.Ledger.Alonzo.Imp.TxInfoSpec as TxInfo
1516
import Test.Cardano.Ledger.Alonzo.ImpTest ()
1617
import Test.Cardano.Ledger.Common
1718
import Test.Cardano.Ledger.Core.JSON (roundTripJsonEraSpec)
19+
import Test.Cardano.Ledger.Era
1820
import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec)
1921

22+
instance EraSpec AlonzoEra where
23+
eraImpSpec = Imp.spec
24+
2025
main :: IO ()
2126
main =
22-
ledgerTestMain $
23-
describe "Alonzo" $ do
24-
BinarySpec.spec
25-
Canonical.spec
26-
CddlSpec.spec
27-
roundTripJsonEraSpec @AlonzoEra
28-
roundTripJsonShelleyEraSpec @AlonzoEra
29-
GoldenTranslation.tests
30-
Golden.spec
31-
describe "Imp" $ do
32-
Imp.spec @AlonzoEra
33-
describe "CostModels" $ do
34-
CostModelsSpec.spec @AlonzoEra
35-
describe "TxWits" $ do
36-
TxWitsSpec.spec @AlonzoEra
37-
TxInfoImp.spec
27+
ledgerEraTestMain @AlonzoEra $ do
28+
BinarySpec.spec
29+
Canonical.spec
30+
CddlSpec.spec
31+
roundTripJsonEraSpec @AlonzoEra
32+
roundTripJsonShelleyEraSpec @AlonzoEra
33+
GoldenTranslation.tests
34+
Golden.spec
35+
describe "CostModels" $ do
36+
CostModelsSpec.spec @AlonzoEra
37+
describe "TxWits" $ do
38+
TxWitsSpec.spec @AlonzoEra
39+
TxInfo.spec

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
{-# LANGUAGE AllowAmbiguousTypes #-}
21
{-# LANGUAGE DataKinds #-}
32
{-# LANGUAGE FlexibleContexts #-}
4-
{-# LANGUAGE RankNTypes #-}
5-
{-# LANGUAGE ScopedTypeVariables #-}
6-
{-# LANGUAGE TypeApplications #-}
73
{-# LANGUAGE TypeOperators #-}
84
{-# OPTIONS_GHC -Wno-orphans #-}
95

@@ -23,28 +19,26 @@ import qualified Test.Cardano.Ledger.Mary.Imp as MaryImp
2319
import qualified Test.Cardano.Ledger.Shelley.Imp as ShelleyImp
2420

2521
spec ::
26-
forall era.
2722
( AlonzoEraImp era
2823
, EraSpecificSpec era
2924
, Event (EraRule "RUPD" era) ~ RupdEvent
3025
) =>
26+
proxy era ->
3127
Spec
32-
spec = do
33-
MaryImp.spec @era
34-
describe "AlonzoImpSpec" . withEachEraVersion @era $ do
28+
spec era = do
29+
MaryImp.spec era
30+
describe "AlonzoImpSpec" . withImpInitEachEraVersion era $ do
3531
Bbody.spec
3632
Utxo.spec
3733
Utxos.spec
3834
Utxow.spec
3935

4036
alonzoEraSpecificSpec ::
41-
forall era.
4237
(AlonzoEraImp era, ShelleyEraTxCert era) =>
4338
SpecWith (ImpInit (LedgerSpec era))
4439
alonzoEraSpecificSpec = do
45-
describe "Alonzo era specific Imp spec" $
46-
describe "Certificates without deposits" $ do
47-
Utxow.alonzoEraSpecificSpec
40+
describe "From AlonzoEra" $ do
41+
Utxow.alonzoEraSpecificSpec
4842

4943
instance EraSpecificSpec AlonzoEra where
5044
eraSpecificSpec =

eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Imp/UtxowSpec.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ alonzoEraSpecificSpec ::
2323
forall era. (AlonzoEraImp era, ShelleyEraTxCert era) => SpecWith (ImpInit (LedgerSpec era))
2424
alonzoEraSpecificSpec = do
2525
describe "UTXOW" $ do
26-
Valid.alonzoEraSpecificSpec
27-
Invalid.alonzoEraSpecificSpec
26+
describe "Certificates without deposits" $ do
27+
Valid.alonzoEraSpecificSpec
28+
Invalid.alonzoEraSpecificSpec

eras/babbage/impl/CHANGELOG.md

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

3030
### `testlib`
3131

32+
* Make `Test.Cardano.Ledger.Babbage.Imp.spec` accept `Proxy era`
3233
* Add `Test.Cardano.Ledger.Babbage.Imp.PoolSpec` module with `babbageEraSpecificSpec`
3334
* In `Test.Cardano.Ledger.Babbage.Examples`:
3435
- Remove `mkBabbageBasedExampleTx`, `exampleBabbageBasedTxBody`

eras/babbage/impl/cardano-ledger-babbage.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ library
9494
cardano-ledger-alonzo ^>=1.16,
9595
cardano-ledger-binary >=1.6,
9696
cardano-ledger-core:{cardano-ledger-core, internal} >=1.20,
97-
cardano-ledger-mary ^>=1.10.1,
97+
cardano-ledger-mary ^>=1.11,
9898
cardano-ledger-shelley ^>=1.19,
9999
cardano-strict-containers,
100100
containers,

0 commit comments

Comments
 (0)