Skip to content

Commit 3856b94

Browse files
authored
Merge pull request #5799 from IntersectMBO/koslambrou/golden-example-tx-each-era
Add example transaction golden test for each era
2 parents 8cf291e + 88e4fda commit 3856b94

49 files changed

Lines changed: 216 additions & 115 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Make `Test.Cardano.Ledger.Allegra.Imp.spec` accept `Proxy era`
1818
* In `Test.Cardano.Ledger.Allegra.Examples`:
1919
- Remove `mkAllegraBasedExampleTx`, `exampleAllegraBasedTxBody`, `exampleAllegraBasedShelleyTxBody`
20-
- Add `exampleAllegraBasedTx`
20+
- Add `exampleAllegraBasedTx`, `exampleAllegraTx`
2121

2222
## 1.9.0.0
2323

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ description:
1111

1212
category: Network
1313
build-type: Simple
14-
data-files: cddl/data/allegra.cddl
14+
data-files:
15+
cddl/data/allegra.cddl
16+
golden/*.cbor
17+
1518
extra-source-files: CHANGELOG.md
1619

1720
source-repository head

eras/allegra/impl/golden/tx.cbor

1.7 KB
Binary file not shown.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ import Cardano.Ledger.Allegra.Core
1212
import Cardano.Ledger.Allegra.Scripts
1313
import Cardano.Ledger.MemoBytes (EqRaw)
1414
import Cardano.Ledger.Plutus (emptyCostModels)
15+
import Paths_cardano_ledger_allegra (getDataFileName)
1516
import Test.Cardano.Ledger.Allegra.Arbitrary ()
1617
import Test.Cardano.Ledger.Allegra.Binary.Annotator ()
18+
import Test.Cardano.Ledger.Allegra.Examples (exampleAllegraTx)
1719
import Test.Cardano.Ledger.Allegra.TreeDiff ()
1820
import Test.Cardano.Ledger.Common
1921
import Test.Cardano.Ledger.Shelley.Era
@@ -37,6 +39,10 @@ instance EraTest AllegraEra where
3739

3840
accountsFromAccountsMap = shelleyAccountsFromAccountsMap
3941

42+
mkEraFullPath = getDataFileName
43+
44+
exampleTx = exampleAllegraTx
45+
4046
instance ShelleyEraTest AllegraEra
4147

4248
instance AllegraEraTest AllegraEra

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
-- don't care, we are only interested in serialisation, not validation.
99
module Test.Cardano.Ledger.Allegra.Examples (
1010
ledgerExamples,
11+
exampleAllegraTx,
1112
exampleAllegraBasedTx,
1213
) where
1314

@@ -44,14 +45,14 @@ ledgerExamples =
4445
exampleCoin
4546
exampleAllegraTx
4647
NoGenesis
47-
where
48-
exampleAllegraTx :: Tx TopTx AllegraEra
49-
exampleAllegraTx =
50-
exampleAllegraBasedTx
51-
& addShelleyBasedTopTxExampleFee
52-
& addShelleyToBabbageExampleProposedPUpdates
53-
& addShelleyToBabbageTxCerts
54-
& addShelleyToConwayTxCerts
48+
49+
exampleAllegraTx :: Tx TopTx AllegraEra
50+
exampleAllegraTx =
51+
exampleAllegraBasedTx
52+
& addShelleyBasedTopTxExampleFee
53+
& addShelleyToBabbageExampleProposedPUpdates
54+
& addShelleyToBabbageTxCerts
55+
& addShelleyToConwayTxCerts
5556

5657
-- Complete transaction which is compatible with any era starting with Allegra.
5758
-- This transaction forms the basis on which future era transactions will be

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
{-# LANGUAGE FlexibleContexts #-}
33
{-# LANGUAGE TypeFamilies #-}
44
{-# LANGUAGE TypeOperators #-}
5-
{-# OPTIONS_GHC -Wno-orphans #-}
65

76
module Test.Cardano.Ledger.Allegra.Imp (spec) where
87

eras/alonzo/impl/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
* `TranslationInstance` has a new field `tiPlutusPurpose`
5252
* In `Test.Cardano.Ledger.Alonzo.Examples`:
5353
- Remove `mkAlonzoBasedExampleTx`, `exampleAlonzoBasedShelleyTxBody`, `exampleAlonzoBasedTxBody`, `exampleRedeemer`
54-
- Add `exampleAlonzoBasedTopTx`, `exampleAlonzoBasedTopTx`, `addAlonzoToConwayExampleReqSigners`
54+
- Add `exampleAlonzoTx`, `exampleAlonzoBasedTopTx`, `exampleAlonzoBasedTopTx`, `addAlonzoToConwayExampleReqSigners`
5555

5656
## 1.15.0.0
5757

eras/alonzo/impl/test/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import qualified Test.Cardano.Ledger.Alonzo.Binary.CddlSpec as CddlSpec
99
import qualified Test.Cardano.Ledger.Alonzo.Binary.CostModelsSpec as CostModelsSpec
1010
import qualified Test.Cardano.Ledger.Alonzo.Binary.TxWitsSpec as TxWitsSpec
1111
import qualified Test.Cardano.Ledger.Alonzo.BinarySpec as BinarySpec
12-
import qualified Test.Cardano.Ledger.Alonzo.GoldenSpec as Golden
12+
import qualified Test.Cardano.Ledger.Alonzo.GoldenSpec as GoldenSpec
1313
import qualified Test.Cardano.Ledger.Alonzo.GoldenTranslation as GoldenTranslation
1414
import qualified Test.Cardano.Ledger.Alonzo.Imp as Imp
1515
import qualified Test.Cardano.Ledger.Alonzo.Imp.TxInfoSpec as TxInfo
@@ -35,7 +35,7 @@ main =
3535
roundTripJsonEraSpec @AlonzoEra
3636
roundTripJsonShelleyEraSpec @AlonzoEra
3737
GoldenTranslation.tests
38-
Golden.spec
38+
GoldenSpec.spec
3939
describe "CostModels" $ do
4040
CostModelsSpec.spec @AlonzoEra
4141
describe "TxWits" $ do

eras/alonzo/impl/test/Test/Cardano/Ledger/Alonzo/BinarySpec.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import Cardano.Ledger.Core
1010
import Cardano.Ledger.MemoBytes (zipMemoRawType)
1111
import Cardano.Ledger.Plutus.Data (BinaryData, Data (..))
1212
import Test.Cardano.Ledger.Alonzo.Arbitrary ()
13-
import qualified Test.Cardano.Ledger.Alonzo.Binary.Golden as Golden
1413
import Test.Cardano.Ledger.Alonzo.Binary.RoundTrip (roundTripAlonzoCommonSpec)
1514
import Test.Cardano.Ledger.Alonzo.Binary.Twiddle ()
1615
import Test.Cardano.Ledger.Alonzo.TreeDiff ()
@@ -43,4 +42,3 @@ spec = do
4342
decoderEquivalenceEraSpec @AlonzoEra @(TxDats AlonzoEra)
4443
decoderEquivalenceEraSpec @AlonzoEra @(Redeemers AlonzoEra)
4544
Binary.txSizeSpec @AlonzoEra
46-
Golden.spec @AlonzoEra

0 commit comments

Comments
 (0)