Skip to content

Commit c3dafcb

Browse files
committed
Remove Fields types from Generic tests
1 parent 1cfa24b commit c3dafcb

File tree

37 files changed

+2866
-4371
lines changed

37 files changed

+2866
-4371
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ module Test.Cardano.Ledger.Allegra.Era (
99
import Cardano.Ledger.Allegra
1010
import Cardano.Ledger.Allegra.Core
1111
import Cardano.Ledger.Allegra.Scripts
12+
import Cardano.Ledger.Plutus (emptyCostModels)
1213
import Test.Cardano.Ledger.Allegra.Arbitrary ()
1314
import Test.Cardano.Ledger.Allegra.TreeDiff ()
14-
import Test.Cardano.Ledger.Era
1515
import Test.Cardano.Ledger.Shelley.Era
1616

1717
class
@@ -22,7 +22,8 @@ class
2222
) =>
2323
AllegraEraTest era
2424

25-
instance EraTest AllegraEra
25+
instance EraTest AllegraEra where
26+
zeroCostModels = emptyCostModels
2627

2728
instance ShelleyEraTest AllegraEra
2829

eras/alonzo/impl/CHANGELOG.md

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

33
## 1.14.0.0
44

5+
* Add `Generic` instance to `TransactionScriptFailure`
56
* Fix `AlonzoPlutusPurpose` CBOR(Group) instances. #5135
67
* Reset shuffled serialization indexes for `AlonzoPlutusPurpose AsItem`.
78
* Deprecated `toAlonzoTransitionConfigPairs`

eras/alonzo/impl/src/Cardano/Ledger/Alonzo/Plutus/Evaluate.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ data TransactionScriptFailure era
268268
NoCostModelInLedgerState !Language
269269
| -- | Error that can happen during plutus context translation
270270
ContextError !(ContextError era)
271+
deriving (Generic)
271272

272273
deriving instance
273274
( Era era

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
{-# LANGUAGE FlexibleContexts #-}
2+
{-# LANGUAGE RankNTypes #-}
3+
{-# LANGUAGE ScopedTypeVariables #-}
4+
{-# LANGUAGE TypeApplications #-}
25
{-# LANGUAGE TypeFamilies #-}
36
{-# LANGUAGE TypeOperators #-}
47
{-# LANGUAGE UndecidableSuperClasses #-}
@@ -12,12 +15,13 @@ module Test.Cardano.Ledger.Alonzo.Era (
1215
import Cardano.Ledger.Alonzo
1316
import Cardano.Ledger.Alonzo.Core
1417
import Cardano.Ledger.Alonzo.Plutus.Context
15-
import Cardano.Ledger.Alonzo.Scripts ()
1618
import Cardano.Ledger.Alonzo.UTxO
19+
import Cardano.Ledger.Plutus (Language (..))
1720
import Data.TreeDiff
1821
import Test.Cardano.Ledger.Alonzo.Arbitrary ()
1922
import Test.Cardano.Ledger.Alonzo.TreeDiff ()
2023
import Test.Cardano.Ledger.Mary.Era
24+
import Test.Cardano.Ledger.Plutus (zeroTestingCostModels)
2125

2226
class
2327
( MaryEraTest era
@@ -32,7 +36,8 @@ class
3236
) =>
3337
AlonzoEraTest era
3438

35-
instance EraTest AlonzoEra
39+
instance EraTest AlonzoEra where
40+
zeroCostModels = zeroTestingCostModels [PlutusV1]
3641

3742
instance ShelleyEraTest AlonzoEra
3843

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import Cardano.Ledger.Compactible
3131
import Cardano.Ledger.Plutus.Evaluate (PlutusWithContext (..))
3232
import Cardano.Ledger.Shelley.Rules
3333
import qualified Data.TreeDiff.OMap as OMap
34+
import PlutusLedgerApi.Common (EvaluationError (..), ExBudget, ExCPU, ExMemory, SatInt)
3435
import Test.Cardano.Ledger.Mary.TreeDiff
3536

3637
-- Scripts
@@ -179,3 +180,22 @@ instance
179180
instance
180181
ToExpr (PredicateFailure (EraRule "LEDGERS" era)) =>
181182
ToExpr (AlonzoBbodyPredFailure era)
183+
184+
instance ToExpr EvaluationError where
185+
toExpr = toExpr . show
186+
187+
instance ToExpr SatInt
188+
189+
instance ToExpr ExCPU
190+
191+
instance ToExpr ExMemory
192+
193+
instance ToExpr ExBudget
194+
195+
instance
196+
( ToExpr (PlutusPurpose AsIx era)
197+
, ToExpr (PlutusPurpose AsItem era)
198+
, ToExpr (PlutusScript era)
199+
, ToExpr (ContextError era)
200+
) =>
201+
ToExpr (TransactionScriptFailure era)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ module Test.Cardano.Ledger.Babbage.Era (
88

99
import Cardano.Ledger.Babbage
1010
import Cardano.Ledger.Babbage.Core
11+
import Cardano.Ledger.Plutus (Language (..))
1112
import Test.Cardano.Ledger.Alonzo.Era
1213
import Test.Cardano.Ledger.Babbage.Arbitrary ()
1314
import Test.Cardano.Ledger.Babbage.TreeDiff ()
15+
import Test.Cardano.Ledger.Plutus (zeroTestingCostModels)
1416

1517
class
1618
( AlonzoEraTest era
@@ -19,7 +21,8 @@ class
1921
) =>
2022
BabbageEraTest era
2123

22-
instance EraTest BabbageEra
24+
instance EraTest BabbageEra where
25+
zeroCostModels = zeroTestingCostModels [PlutusV1 .. PlutusV2]
2326

2427
instance ShelleyEraTest BabbageEra
2528

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import Cardano.Ledger.Conway
1010
import Cardano.Ledger.Conway.Core
1111
import Cardano.Ledger.Conway.Governance
1212
import Cardano.Ledger.Conway.State
13+
import Cardano.Ledger.Plutus (Language (..))
1314
import Test.Cardano.Ledger.Babbage.Era
1415
import Test.Cardano.Ledger.Conway.Arbitrary ()
1516
import Test.Cardano.Ledger.Conway.TreeDiff ()
17+
import Test.Cardano.Ledger.Plutus (zeroTestingCostModels)
1618

1719
class
1820
( BabbageEraTest era
@@ -22,7 +24,8 @@ class
2224
) =>
2325
ConwayEraTest era
2426

25-
instance EraTest ConwayEra
27+
instance EraTest ConwayEra where
28+
zeroCostModels = zeroTestingCostModels [PlutusV1 .. PlutusV3]
2629

2730
instance ShelleyEraTest ConwayEra
2831

eras/dijkstra/testlib/Test/Cardano/Ledger/Dijkstra/Era.hs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
{-# OPTIONS_GHC -Wno-orphans #-}
22

3-
module Test.Cardano.Ledger.Dijkstra.Era () where
3+
module Test.Cardano.Ledger.Dijkstra.Era (
4+
module Test.Cardano.Ledger.Conway.Era,
5+
) where
46

57
import Cardano.Ledger.Dijkstra (DijkstraEra)
6-
import Test.Cardano.Ledger.Conway.Era (
7-
AllegraEraTest,
8-
AlonzoEraTest,
9-
BabbageEraTest,
10-
ConwayEraTest,
11-
EraTest,
12-
MaryEraTest,
13-
ShelleyEraTest,
14-
)
8+
import Cardano.Ledger.Plutus (Language (..))
9+
import Test.Cardano.Ledger.Conway.Era
1510
import Test.Cardano.Ledger.Dijkstra.Arbitrary ()
1611
import Test.Cardano.Ledger.Dijkstra.TreeDiff ()
12+
import Test.Cardano.Ledger.Plutus (zeroTestingCostModels)
1713

18-
instance EraTest DijkstraEra
14+
instance EraTest DijkstraEra where
15+
-- TODO add PlutusV4?
16+
zeroCostModels = zeroTestingCostModels [PlutusV1 .. PlutusV3]
1917

2018
instance ShelleyEraTest DijkstraEra
2119

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Test.Cardano.Ledger.Mary.Era (
88

99
import Cardano.Ledger.Mary
1010
import Cardano.Ledger.Mary.Core
11+
import Cardano.Ledger.Plutus (emptyCostModels)
1112
import Test.Cardano.Ledger.Allegra.Era
1213
import Test.Cardano.Ledger.Mary.Arbitrary ()
1314
import Test.Cardano.Ledger.Mary.TreeDiff ()
@@ -18,7 +19,8 @@ class
1819
) =>
1920
MaryEraTest era
2021

21-
instance EraTest MaryEra
22+
instance EraTest MaryEra where
23+
zeroCostModels = emptyCostModels
2224

2325
instance ShelleyEraTest MaryEra
2426

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
{-# LANGUAGE FlexibleContexts #-}
2+
{-# LANGUAGE TypeApplications #-}
23
{-# LANGUAGE UndecidableSuperClasses #-}
34
{-# OPTIONS_GHC -Wno-orphans #-}
45

56
module Test.Cardano.Ledger.Shelley.Era (
6-
EraTest,
7+
EraTest (..),
78
ShelleyEraTest,
89
) where
910

11+
import Cardano.Ledger.Plutus (emptyCostModels)
1012
import Cardano.Ledger.Shelley
1113
import Cardano.Ledger.Shelley.LedgerState
1214
import Cardano.Ledger.Shelley.Scripts
@@ -33,6 +35,7 @@ class
3335
) =>
3436
ShelleyEraTest era
3537

36-
instance EraTest ShelleyEra
38+
instance EraTest ShelleyEra where
39+
zeroCostModels = emptyCostModels
3740

3841
instance ShelleyEraTest ShelleyEra

0 commit comments

Comments
 (0)