Skip to content

Commit 12e4531

Browse files
authored
Merge pull request #5223 from IntersectMBO/td/run-imptests-across-versions
Run Imp tests for every version of an era
2 parents c4cf9f3 + 57aa9fc commit 12e4531

File tree

9 files changed

+26
-24
lines changed
  • eras
    • allegra/impl/testlib/Test/Cardano/Ledger/Allegra
    • alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo
    • babbage/impl/testlib/Test/Cardano/Ledger/Babbage
    • conway/impl/testlib/Test/Cardano/Ledger/Conway
    • mary/impl/testlib/Test/Cardano/Ledger/Mary
    • shelley/impl

9 files changed

+26
-24
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ spec ::
2323
Spec
2424
spec = do
2525
ShelleyImp.spec @era
26-
describe "AllegraImpSpec" . withImpInit @(LedgerSpec era) $ do
26+
describe "AllegraImpSpec" . withEachEraVersion @era $
2727
UtxowSpec.spec

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Cardano.Ledger.Shelley.Rules (
2121
import qualified Test.Cardano.Ledger.Alonzo.Imp.UtxoSpec as Utxo
2222
import qualified Test.Cardano.Ledger.Alonzo.Imp.UtxosSpec as Utxos
2323
import qualified Test.Cardano.Ledger.Alonzo.Imp.UtxowSpec as Utxow
24-
import Test.Cardano.Ledger.Alonzo.ImpTest (AlonzoEraImp, LedgerSpec)
24+
import Test.Cardano.Ledger.Alonzo.ImpTest
2525
import Test.Cardano.Ledger.Imp.Common
2626
import qualified Test.Cardano.Ledger.Mary.Imp as MaryImp
2727

@@ -38,7 +38,7 @@ spec ::
3838
Spec
3939
spec = do
4040
MaryImp.spec @era
41-
describe "AlonzoImpSpec" . withImpInit @(LedgerSpec era) $ do
41+
describe "AlonzoImpSpec" . withEachEraVersion @era $ do
4242
Utxo.spec
4343
Utxos.spec
4444
Utxow.spec

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
{-# LANGUAGE FlexibleContexts #-}
44
{-# LANGUAGE OverloadedStrings #-}
55
{-# LANGUAGE ScopedTypeVariables #-}
6-
{-# LANGUAGE TypeApplications #-}
76
{-# LANGUAGE TypeFamilies #-}
8-
{-# LANGUAGE TypeOperators #-}
97

108
module Test.Cardano.Ledger.Alonzo.Imp.UtxowSpec (spec) where
119

eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import Cardano.Ledger.Shelley.Rules (
2323
ShelleyUtxowPredFailure,
2424
)
2525
import qualified Test.Cardano.Ledger.Alonzo.Imp as AlonzoImp
26-
import Test.Cardano.Ledger.Alonzo.ImpTest (AlonzoEraImp, LedgerSpec)
26+
import Test.Cardano.Ledger.Alonzo.ImpTest
2727
import qualified Test.Cardano.Ledger.Babbage.Imp.UtxoSpec as Utxo
2828
import qualified Test.Cardano.Ledger.Babbage.Imp.UtxosSpec as Utxos
2929
import qualified Test.Cardano.Ledger.Babbage.Imp.UtxowSpec as Utxow
@@ -46,7 +46,7 @@ spec ::
4646
Spec
4747
spec = do
4848
AlonzoImp.spec @era
49-
withImpInit @(LedgerSpec era) $
49+
withEachEraVersion @era $
5050
describe "BabbageImpSpec" $ do
5151
Utxo.spec
5252
Utxow.spec

eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp.hs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,8 @@ import qualified Test.Cardano.Ledger.Conway.Imp.RatifySpec as Ratify
5757
import qualified Test.Cardano.Ledger.Conway.Imp.UtxoSpec as Utxo
5858
import qualified Test.Cardano.Ledger.Conway.Imp.UtxosSpec as Utxos
5959
import qualified Test.Cardano.Ledger.Conway.Imp.UtxowSpec as Utxow
60-
import Test.Cardano.Ledger.Conway.ImpTest (
61-
ConwayEraImp,
62-
LedgerSpec,
63-
modifyImpInitProtVer,
64-
)
60+
import Test.Cardano.Ledger.Conway.ImpTest
6561
import Test.Cardano.Ledger.Imp.Common
66-
import Test.Cardano.Ledger.Shelley.ImpTest (ImpInit)
6762

6863
spec ::
6964
forall era.
@@ -101,11 +96,7 @@ spec ::
10196
Spec
10297
spec = do
10398
BabbageImp.spec @era
104-
withImpInit @(LedgerSpec era) $
105-
forM_ (eraProtVersions @era) $ \protVer ->
106-
describe ("ConwayImpSpec - " <> show protVer) $
107-
modifyImpInitProtVer protVer $
108-
conwaySpec @era
99+
withEachEraVersion @era $ conwaySpec @era
109100

110101
conwaySpec ::
111102
forall era.

eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import Cardano.Ledger.Shelley.Rules (ShelleyUtxoPredFailure, ShelleyUtxowPredFai
1212
import qualified Test.Cardano.Ledger.Allegra.Imp as AllegraImp
1313
import Test.Cardano.Ledger.Imp.Common
1414
import qualified Test.Cardano.Ledger.Mary.Imp.UtxoSpec as Utxo
15-
import Test.Cardano.Ledger.Mary.ImpTest (MaryEraImp)
16-
import Test.Cardano.Ledger.Shelley.ImpTest (LedgerSpec)
15+
import Test.Cardano.Ledger.Mary.ImpTest
1716

1817
spec ::
1918
forall era.
@@ -24,5 +23,6 @@ spec ::
2423
Spec
2524
spec = do
2625
AllegraImp.spec @era
27-
describe "MaryImpSpec" $ withImpInit @(LedgerSpec era) $ do
28-
Utxo.spec
26+
describe "MaryImpSpec" $
27+
withEachEraVersion @era $
28+
Utxo.spec

eras/shelley/impl/CHANGELOG.md

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

6969
### `testlib`
7070

71+
* Added `withEachEraVersion`
7172
* Added `Examples` module with: `LedgerExamples`, `ledgerExamples`, `mkLedgerExamples`, `exampleCerts`,`exampleWithdrawals`, `exampleAuxDataMap`, `exampleNonMyopicRewards`, `exampleCoin`, `examplePayKey`, `exampleStakeKey`, `exampleNewEpochState`, `examplePoolDistr`, `examplePoolParams`, `exampleTxIns`, `exampleProposedPPUpdates`, `exampleByronAddress`, `testShelleyGenesis`, `keyToCredential`, `mkDSIGNKeyPair`, `mkKeyHash`, `mkScriptHash`, `mkWitnessesPreAlonzo`, `seedFromByte`, `seedFromWords`
7273
* Add `nativeAlwaysFails`, `nativeAlwaysSucceeds`
7374
* Deprecated `getRewardAccountAmount`, `lookupReward` and `getReward`

eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Imp.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import qualified Test.Cardano.Ledger.Shelley.Imp.EpochSpec as Epoch
1313
import qualified Test.Cardano.Ledger.Shelley.Imp.LedgerSpec as Ledger
1414
import qualified Test.Cardano.Ledger.Shelley.Imp.UtxoSpec as Utxo
1515
import qualified Test.Cardano.Ledger.Shelley.Imp.UtxowSpec as Utxow
16-
import Test.Cardano.Ledger.Shelley.ImpTest (LedgerSpec, ShelleyEraImp)
16+
import Test.Cardano.Ledger.Shelley.ImpTest
1717
import qualified Test.Cardano.Ledger.Shelley.UnitTests.InstantStakeTest as Instant
1818

1919
spec ::
@@ -24,7 +24,7 @@ spec ::
2424
) =>
2525
Spec
2626
spec = do
27-
describe "ShelleyImpSpec" $ withImpInit @(LedgerSpec era) $ do
27+
describe "ShelleyImpSpec" $ withEachEraVersion @era $ do
2828
Ledger.spec
2929
Epoch.spec
3030
Utxow.spec

eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/ImpTest.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ module Test.Cardano.Ledger.Shelley.ImpTest (
115115
whenMajorVersionAtMost,
116116
unlessMajorVersion,
117117
getsPParams,
118+
withEachEraVersion,
118119

119120
-- * Logging
120121
Doc,
@@ -569,6 +570,17 @@ defaultInitImpTestState nes = do
569570
, impEvents = mempty
570571
}
571572

573+
withEachEraVersion ::
574+
forall era.
575+
ShelleyEraImp era =>
576+
SpecWith (ImpInit (LedgerSpec era)) ->
577+
Spec
578+
withEachEraVersion specWith =
579+
withImpInit @(LedgerSpec era) $ do
580+
forM_ (eraProtVersions @era) $ \protVer ->
581+
describe (show protVer) $
582+
modifyImpInitProtVer protVer specWith
583+
572584
modifyImpInitProtVer ::
573585
forall era.
574586
ShelleyEraImp era =>

0 commit comments

Comments
 (0)