From c73e1130764105ac0451854233cd4c89af6d077e Mon Sep 17 00:00:00 2001 From: Konstantinos Lambrou-Latreille Date: Mon, 4 May 2026 14:55:01 -0400 Subject: [PATCH 1/2] Remove duplicate golden test from `cardano-ledger-alonzo-test` package --- eras/alonzo/test-suite/golden/tx.cbor | Bin 2276 -> 0 bytes .../test/Test/Cardano/Ledger/Alonzo/Golden.hs | 6 ------ eras/conway/impl/test/Main.hs | 2 ++ eras/mary/impl/test/Main.hs | 1 + eras/shelley/impl/test/Main.hs | 1 + 5 files changed, 4 insertions(+), 6 deletions(-) delete mode 100644 eras/alonzo/test-suite/golden/tx.cbor diff --git a/eras/alonzo/test-suite/golden/tx.cbor b/eras/alonzo/test-suite/golden/tx.cbor deleted file mode 100644 index a093b3778f14014ab447886138c4eea43ff432a1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2276 zcmZo!$I#dmq3}*L>f9U$O@)%vS^s zlHv5^h@iP&isl%(Em~lFdWPca{TFkebTqI|@Y>_Zn-yL+#c^%l%`{8H334rpvZF7W-@;ncIriA@3)vrxV z>&RjjefMa}yMvsa<*E670*e^K!x9ye^K%P|Qj3dIQxtMi^YRk)3i8sK9D&xE&WntP z8b`k8nj}&dM#wx^E@C)C=L-T4yILaHuay_C~c2BkK*hCPuCZ*$4Q{ zX~b_$a|?qc_YN0E28Q~89lVSR3{U_RU}$EPC#i@D4rNw#$`T03c)wRtm_-$rtVU3W%7qAgBsecM)#WBwA+Ew;#dW}qb!IRDT z%k!Q6{zSC9Zzmi+O>9jJ3!4}sWEi^LTYM)q>L2En=Q_FV_viMCGrQ*QFx0xqKB1Bk zsEQG+s%z?rw-L>3uR7YeLtgWwKCk_?b7sYyqt8w;w9f>oVqk1y0GWm_u$vg081W~~ zW+p;r;J1NwA%XaoNMUOtls#A^`4@0;F!2G?#t)fidHg}QVwN;cw#X|L{QGo+!D99; zhcm>@j(y-HWDaUJmUPI6qGP z8+2ROW>;*{sdUc$vQvblKbLecZsE_5iExmp7k})zVPfD5fv3#tjczW`kNZ_+d0WTH zR^_Se>SOEQ2~U@sq2;|WMN6q-?b4F7C2x6L=IXnaZQgX^s{Y}Xu1r8nth3bjoZGfU zH)-*T3tIWS#i>T3<+6{QmsuU~SlAtTOEbcOLFLvRRiE(O5A!VIzW4bo?)x}%`9zO% zVsi~vr)(9oxm(-wC&BpNn}-n!v)uBd4hu4NNQx!@X}X|$>TRHhT^BD?V@rgBzlYs~ z2!?H2f6smuJ?m+BZqDAQe_m40TX{vwC;BbUP>OJvZ7_Q)vlOq5{P)P4n>Gg?ao%Ne zY`wMf;Tv;iJw7&}JJB_ws;}Zu*qfqco7z+V=Bxa9lQg;IYp>wh`_pyqY-}8y+}<*3i!1y7mCe@zln+WxmFF>f0+Pp92!rI0ZoKdAZC3) zLWJHDz81cH-p=xWf4Dc?2HOY9Px$Nrx`zmBmbtlm_lFp&iLz}wRD7BJc-SnzZ6~vx z?s{nkaY228ub=^0fv>1xZuD>mmWN7841z3;H!A1PXZXL6(b4cfYfB3Q!;Px>^BMmy zWO6k6-y|vA0Yoi~j93Jjn6L;kGh+&Vy~)VDm|-bnT5(BHCa~UgO{y$OEoNq9X<}qz VUC8X1#MnshsA6h#a|H!JA^=v7(}e&4 diff --git a/eras/alonzo/test-suite/test/Test/Cardano/Ledger/Alonzo/Golden.hs b/eras/alonzo/test-suite/test/Test/Cardano/Ledger/Alonzo/Golden.hs index 2a72f2a5e93..d46ae229527 100644 --- a/eras/alonzo/test-suite/test/Test/Cardano/Ledger/Alonzo/Golden.hs +++ b/eras/alonzo/test-suite/test/Test/Cardano/Ledger/Alonzo/Golden.hs @@ -61,7 +61,6 @@ import Test.Cardano.Ledger.Mary.Golden ( import Test.Cardano.Ledger.Plutus (zeroTestingCostModels) import Test.Cardano.Ledger.Shelley.Examples.Cast (aliceAddr, bobAddr, carlAddr) import Test.Cardano.Protocol.TPraos.Examples ( - LedgerExamples (..), ProtocolLedgerExamples (..), ledgerExamplesAlonzo, ) @@ -187,11 +186,6 @@ goldenCborSerialization = "golden/block.cbor" (eraProtVerLow @AlonzoEra) (pleBlock ledgerExamplesAlonzo) - cborAnnGoldenSpec - getDataFileName - "golden/tx.cbor" - (eraProtVerLow @AlonzoEra) - (leTx $ pleLedgerExamples ledgerExamplesAlonzo) goldenJsonSerialization :: Spec goldenJsonSerialization = diff --git a/eras/conway/impl/test/Main.hs b/eras/conway/impl/test/Main.hs index c7d68255c2b..475327955b7 100644 --- a/eras/conway/impl/test/Main.hs +++ b/eras/conway/impl/test/Main.hs @@ -8,6 +8,8 @@ import Cardano.Ledger.Conway (ConwayEra) import Cardano.Ledger.Conway.Tx (tierRefScriptFee) import qualified Test.Cardano.Ledger.Alonzo.Imp as Alonzo import Test.Cardano.Ledger.Common +import qualified Test.Cardano.Ledger.Conway.Imp as Imp +import Test.Cardano.Ledger.Era import qualified Test.Cardano.Ledger.Conway.Binary.CddlSpec as Cddl import qualified Test.Cardano.Ledger.Conway.GenesisSpec as Genesis import qualified Test.Cardano.Ledger.Conway.GoldenSpec as GoldenSpec diff --git a/eras/mary/impl/test/Main.hs b/eras/mary/impl/test/Main.hs index 462f4e20fe5..5b5002a4fb8 100644 --- a/eras/mary/impl/test/Main.hs +++ b/eras/mary/impl/test/Main.hs @@ -10,6 +10,7 @@ import Test.Cardano.Ledger.Era import qualified Test.Cardano.Ledger.Mary.Binary.CddlSpec as CddlSpec import qualified Test.Cardano.Ledger.Mary.BinarySpec as BinarySpec import qualified Test.Cardano.Ledger.Mary.Imp as Imp +import Test.Cardano.Ledger.Era import Test.Cardano.Ledger.Mary.ImpTest () import qualified Test.Cardano.Ledger.Mary.ValueSpec as ValueSpec import qualified Test.Cardano.Ledger.Shelley.Imp as Imp (shelleyEraSpecificSpec) diff --git a/eras/shelley/impl/test/Main.hs b/eras/shelley/impl/test/Main.hs index 14feee936a4..819e58a15ab 100644 --- a/eras/shelley/impl/test/Main.hs +++ b/eras/shelley/impl/test/Main.hs @@ -9,6 +9,7 @@ import Test.Cardano.Ledger.Era import qualified Test.Cardano.Ledger.Shelley.Binary.CddlSpec as Cddl import qualified Test.Cardano.Ledger.Shelley.BinarySpec as Binary import qualified Test.Cardano.Ledger.Shelley.Imp as Imp +import Test.Cardano.Ledger.Era import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec) instance EraSpec ShelleyEra where From 88e4fda74ed03cdd2b8eac7d6bb0323f4ed8dfc6 Mon Sep 17 00:00:00 2001 From: Konstantinos Lambrou-Latreille Date: Mon, 4 May 2026 09:30:53 -0400 Subject: [PATCH 2/2] Add `Test.Cardano.Ledger.Core.Binary.Golden.goldenExampleEraTxCborSpec` in cardano-ledger-core:testlib and generate the golden example transactions for each era. `goldenExampleEraTxCborSpec` allows us to generate a `Spec` for generating a `golden/tx.cbor` golden file out of some `Tx` provided as a parameter. Then, for each era's test-suite, we call this function to generate the golden file using the example transaction we have defined for each era. We also extended `EraTest` so that we don't need to manually call `getDataFileName` in order to get the fullpath for each era's cabal project. We also create new `Binary.Golden` modules for Mary and Babbage (previously they reused Allegra's and Alonzo's respectively, which used the wrong era's example transactions). Additionally, fix `exampleDijkstraBasedTopTx` to not add PlutusV4 scripts to `scriptTxWitsL`: PlutusV4 is not included in Dijkstra's `transaction_witness_set` CDDL, so those scripts were silently dropped during serialization, causing a roundtrip failure. --- eras/allegra/impl/CHANGELOG.md | 2 +- .../allegra/impl/cardano-ledger-allegra.cabal | 5 ++- eras/allegra/impl/golden/tx.cbor | Bin 0 -> 1745 bytes .../Test/Cardano/Ledger/Allegra/Era.hs | 6 +++ .../Test/Cardano/Ledger/Allegra/Examples.hs | 17 ++++---- .../Test/Cardano/Ledger/Allegra/Imp.hs | 1 - eras/alonzo/impl/CHANGELOG.md | 2 +- eras/alonzo/impl/golden/tx.cbor | Bin 0 -> 2276 bytes eras/alonzo/impl/test/Main.hs | 4 +- .../Test/Cardano/Ledger/Alonzo/BinarySpec.hs | 2 - .../Test/Cardano/Ledger/Alonzo/GoldenSpec.hs | 6 +-- .../testlib/Test/Cardano/Ledger/Alonzo/Era.hs | 6 +++ .../Test/Cardano/Ledger/Alonzo/Examples.hs | 19 ++++----- eras/babbage/impl/CHANGELOG.md | 2 +- .../babbage/impl/cardano-ledger-babbage.cabal | 2 + eras/babbage/impl/golden/tx.cbor | Bin 0 -> 2982 bytes eras/babbage/impl/test/Main.hs | 4 +- .../Test/Cardano/Ledger/Babbage/GoldenSpec.hs | 2 +- .../Cardano/Ledger/Babbage/Binary/Golden.hs | 24 +++++++++++ .../Test/Cardano/Ledger/Babbage/Era.hs | 7 ++++ .../Test/Cardano/Ledger/Babbage/Examples.hs | 35 ++++++++++------ .../Test/Cardano/Ledger/Babbage/Imp.hs | 2 - eras/conway/impl/CHANGELOG.md | 2 +- eras/conway/impl/golden/tx.cbor | Bin 0 -> 5381 bytes eras/conway/impl/test/Main.hs | 2 - .../Test/Cardano/Ledger/Conway/GoldenSpec.hs | 3 +- .../testlib/Test/Cardano/Ledger/Conway/Era.hs | 6 +++ .../Test/Cardano/Ledger/Conway/Examples.hs | 16 ++++---- eras/dijkstra/impl/CHANGELOG.md | 3 +- .../impl/cardano-ledger-dijkstra.cabal | 1 + eras/dijkstra/impl/golden/tx.cbor | Bin 0 -> 11254 bytes eras/dijkstra/impl/test/Main.hs | 4 +- .../Test/Cardano/Ledger/Dijkstra/Era.hs | 6 +++ .../Test/Cardano/Ledger/Dijkstra/Examples.hs | 38 ++++++++++++++---- .../Test/Cardano/Ledger/Dijkstra/ImpTest.hs | 17 +------- eras/mary/impl/CHANGELOG.md | 2 +- eras/mary/impl/cardano-ledger-mary.cabal | 5 ++- eras/mary/impl/golden/tx.cbor | Bin 0 -> 1901 bytes eras/mary/impl/test/Main.hs | 1 - .../testlib/Test/Cardano/Ledger/Mary/Era.hs | 6 +++ .../Test/Cardano/Ledger/Mary/Examples.hs | 17 ++++---- .../testlib/Test/Cardano/Ledger/Mary/Imp.hs | 1 - eras/shelley/impl/CHANGELOG.md | 2 +- .../shelley/impl/cardano-ledger-shelley.cabal | 1 + eras/shelley/impl/golden/tx.cbor | Bin 0 -> 1517 bytes eras/shelley/impl/test/Main.hs | 1 - .../Ledger/Shelley/Binary/GoldenSpec.hs | 1 - .../Test/Cardano/Ledger/Shelley/Era.hs | 6 +++ .../Test/Cardano/Ledger/Shelley/Examples.hs | 19 ++++----- .../testlib/Test/Cardano/Ledger/Era.hs | 18 ++++++++- .../testlib/Test/Cardano/Ledger/Imp/Common.hs | 3 -- 51 files changed, 216 insertions(+), 113 deletions(-) create mode 100644 eras/allegra/impl/golden/tx.cbor create mode 100644 eras/alonzo/impl/golden/tx.cbor create mode 100644 eras/babbage/impl/golden/tx.cbor create mode 100644 eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Binary/Golden.hs create mode 100644 eras/conway/impl/golden/tx.cbor create mode 100644 eras/dijkstra/impl/golden/tx.cbor create mode 100644 eras/mary/impl/golden/tx.cbor create mode 100644 eras/shelley/impl/golden/tx.cbor diff --git a/eras/allegra/impl/CHANGELOG.md b/eras/allegra/impl/CHANGELOG.md index 8d200f0bd16..3fb0e0f1dfd 100644 --- a/eras/allegra/impl/CHANGELOG.md +++ b/eras/allegra/impl/CHANGELOG.md @@ -17,7 +17,7 @@ * Make `Test.Cardano.Ledger.Allegra.Imp.spec` accept `Proxy era` * In `Test.Cardano.Ledger.Allegra.Examples`: - Remove `mkAllegraBasedExampleTx`, `exampleAllegraBasedTxBody`, `exampleAllegraBasedShelleyTxBody` - - Add `exampleAllegraBasedTx` + - Add `exampleAllegraBasedTx`, `exampleAllegraTx` ## 1.9.0.0 diff --git a/eras/allegra/impl/cardano-ledger-allegra.cabal b/eras/allegra/impl/cardano-ledger-allegra.cabal index e2f75040424..57628a2a0bc 100644 --- a/eras/allegra/impl/cardano-ledger-allegra.cabal +++ b/eras/allegra/impl/cardano-ledger-allegra.cabal @@ -11,7 +11,10 @@ description: category: Network build-type: Simple -data-files: cddl/data/allegra.cddl +data-files: + cddl/data/allegra.cddl + golden/*.cbor + extra-source-files: CHANGELOG.md source-repository head diff --git a/eras/allegra/impl/golden/tx.cbor b/eras/allegra/impl/golden/tx.cbor new file mode 100644 index 0000000000000000000000000000000000000000..4f225b1483b79ce92db2cc653059084ae4414202 GIT binary patch literal 1745 zcmZo($f9U$O@)%vS^s>9wk-f!Y$3;n{G%%*fvMVD9`iYXG+-rQvKS*w2mxh z(RYugygSI*S)Q8TC$NYyJSAc8zuyIVx z%q%ROUCa?O_`DIJaP*PX#*^QebQ=$EiZd}gT`&8+ep=8vJ7IxCeMz!6s(lz)Z^$(< zaz)5Kz-LY)eruXr7$muOxG*v>)CcU~WmI5*0-yjxGovK;&cdS9oWx4K)QZI1f}B)6 zp!b@Xu!!X)=jRot<`tI~>lNhZ=Qvf@HnZTjnW=>}LS|!j*w;5~-p|(9tWGd}zpia_ z+8Ns;3$7L>*cLpEkV*YhFe{F6cGs@5Z_{gJ+6$g+&R?GI?Dr?4-F-XZ@M&UeVp!P3 z5Fx|R?cU-$sZswhuRPbuZNERaSDe{3cZZ?YP4)?uj6hY4U{zgHPrQw2W_#7q#vSsS zC-r&lubne1<{W)?ilKcbNEHKP69dRJe1YA>*u)qi^I*A%;S8a}--~y#yot@W|8sTK zjR3ZWXqIXYRmWx~LT2E%fpsB)_?AdvYg&lk4GUQ$`4@1pM<^J*v|e}g&%47e&i!4C zkERA#*|BAw`{(j@){h&XpWYL8=U`gQ&;-m%T^*0_mT-QY`ZwsduFbC4qEqRd`(>vH zNq;WsVBEr=9~0pqQ7``3bHl{I7XnY2*Bjkjpda_E%JR03ldZ~A+11C^zZ0G=H$%&N zVTzVg#oDDMXG`AlxXjgeE!({5#8v&nD_xm@mRM)0?>V<^iEh&36&JMfd5cqxM9XC# zIWMz1;IXhf@|I?V1B1$~JE}h6xgX|P#C`AcS={$==JJUi=fvh3tWMb~W^=c;=TCz1 zzc&vf6lS^QM;#Vq?2r^o{?l|p_te`!54$d2#-?Uwrev2r#sHG$(|%EOXk zy`QU|+gnC$ab@4XviVwo@~=oj+^G3x^oBJ`H+yE!)EzyJDKft*Gn^q3+fYm znF(YCzU;)**b<@O?_oC~f??a%-?Lvu&w3i3o3l6SpO@70R$h_viGGVSlp-8v8_eFy zEX8Xh|2^{NrpZ>>u_NFM=ruNjo`6_?jBu#Gl z+ADbW{&bx?+g%wW6c%@|&#QbT)un53cET<7vjI8!^3!~s*FWFRK3QUt&l=wdS-j=oR9TW*%*@Er#K^?Dkl8V*k>1e@05JUL`2YX_ literal 0 HcmV?d00001 diff --git a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Era.hs b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Era.hs index 1d3e3b72c1a..82571a60820 100644 --- a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Era.hs +++ b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Era.hs @@ -12,8 +12,10 @@ import Cardano.Ledger.Allegra.Core import Cardano.Ledger.Allegra.Scripts import Cardano.Ledger.MemoBytes (EqRaw) import Cardano.Ledger.Plutus (emptyCostModels) +import Paths_cardano_ledger_allegra (getDataFileName) import Test.Cardano.Ledger.Allegra.Arbitrary () import Test.Cardano.Ledger.Allegra.Binary.Annotator () +import Test.Cardano.Ledger.Allegra.Examples (exampleAllegraTx) import Test.Cardano.Ledger.Allegra.TreeDiff () import Test.Cardano.Ledger.Common import Test.Cardano.Ledger.Shelley.Era @@ -37,6 +39,10 @@ instance EraTest AllegraEra where accountsFromAccountsMap = shelleyAccountsFromAccountsMap + mkEraFullPath = getDataFileName + + exampleTx = exampleAllegraTx + instance ShelleyEraTest AllegraEra instance AllegraEraTest AllegraEra diff --git a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Examples.hs b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Examples.hs index 34cf9187da8..48de5e0baad 100644 --- a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Examples.hs +++ b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Examples.hs @@ -8,6 +8,7 @@ -- don't care, we are only interested in serialisation, not validation. module Test.Cardano.Ledger.Allegra.Examples ( ledgerExamples, + exampleAllegraTx, exampleAllegraBasedTx, ) where @@ -44,14 +45,14 @@ ledgerExamples = exampleCoin exampleAllegraTx NoGenesis - where - exampleAllegraTx :: Tx TopTx AllegraEra - exampleAllegraTx = - exampleAllegraBasedTx - & addShelleyBasedTopTxExampleFee - & addShelleyToBabbageExampleProposedPUpdates - & addShelleyToBabbageTxCerts - & addShelleyToConwayTxCerts + +exampleAllegraTx :: Tx TopTx AllegraEra +exampleAllegraTx = + exampleAllegraBasedTx + & addShelleyBasedTopTxExampleFee + & addShelleyToBabbageExampleProposedPUpdates + & addShelleyToBabbageTxCerts + & addShelleyToConwayTxCerts -- Complete transaction which is compatible with any era starting with Allegra. -- This transaction forms the basis on which future era transactions will be diff --git a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Imp.hs b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Imp.hs index 06bd93095c6..d7849eb6c4f 100644 --- a/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Imp.hs +++ b/eras/allegra/impl/testlib/Test/Cardano/Ledger/Allegra/Imp.hs @@ -2,7 +2,6 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -{-# OPTIONS_GHC -Wno-orphans #-} module Test.Cardano.Ledger.Allegra.Imp (spec) where diff --git a/eras/alonzo/impl/CHANGELOG.md b/eras/alonzo/impl/CHANGELOG.md index 084277c706d..cb6da3eb6cb 100644 --- a/eras/alonzo/impl/CHANGELOG.md +++ b/eras/alonzo/impl/CHANGELOG.md @@ -51,7 +51,7 @@ * `TranslationInstance` has a new field `tiPlutusPurpose` * In `Test.Cardano.Ledger.Alonzo.Examples`: - Remove `mkAlonzoBasedExampleTx`, `exampleAlonzoBasedShelleyTxBody`, `exampleAlonzoBasedTxBody`, `exampleRedeemer` - - Add `exampleAlonzoBasedTopTx`, `exampleAlonzoBasedTopTx`, `addAlonzoToConwayExampleReqSigners` + - Add `exampleAlonzoTx`, `exampleAlonzoBasedTopTx`, `exampleAlonzoBasedTopTx`, `addAlonzoToConwayExampleReqSigners` ## 1.15.0.0 diff --git a/eras/alonzo/impl/golden/tx.cbor b/eras/alonzo/impl/golden/tx.cbor new file mode 100644 index 0000000000000000000000000000000000000000..a093b3778f14014ab447886138c4eea43ff432a1 GIT binary patch literal 2276 zcmZo!$I#dmq3}*L>f9U$O@)%vS^s zlHv5^h@iP&isl%(Em~lFdWPca{TFkebTqI|@Y>_Zn-yL+#c^%l%`{8H334rpvZF7W-@;ncIriA@3)vrxV z>&RjjefMa}yMvsa<*E670*e^K!x9ye^K%P|Qj3dIQxtMi^YRk)3i8sK9D&xE&WntP z8b`k8nj}&dM#wx^E@C)C=L-T4yILaHuay_C~c2BkK*hCPuCZ*$4Q{ zX~b_$a|?qc_YN0E28Q~89lVSR3{U_RU}$EPC#i@D4rNw#$`T03c)wRtm_-$rtVU3W%7qAgBsecM)#WBwA+Ew;#dW}qb!IRDT z%k!Q6{zSC9Zzmi+O>9jJ3!4}sWEi^LTYM)q>L2En=Q_FV_viMCGrQ*QFx0xqKB1Bk zsEQG+s%z?rw-L>3uR7YeLtgWwKCk_?b7sYyqt8w;w9f>oVqk1y0GWm_u$vg081W~~ zW+p;r;J1NwA%XaoNMUOtls#A^`4@0;F!2G?#t)fidHg}QVwN;cw#X|L{QGo+!D99; zhcm>@j(y-HWDaUJmUPI6qGP z8+2ROW>;*{sdUc$vQvblKbLecZsE_5iExmp7k})zVPfD5fv3#tjczW`kNZ_+d0WTH zR^_Se>SOEQ2~U@sq2;|WMN6q-?b4F7C2x6L=IXnaZQgX^s{Y}Xu1r8nth3bjoZGfU zH)-*T3tIWS#i>T3<+6{QmsuU~SlAtTOEbcOLFLvRRiE(O5A!VIzW4bo?)x}%`9zO% zVsi~vr)(9oxm(-wC&BpNn}-n!v)uBd4hu4NNQx!@X}X|$>TRHhT^BD?V@rgBzlYs~ z2!?H2f6smuJ?m+BZqDAQe_m40TX{vwC;BbUP>OJvZ7_Q)vlOq5{P)P4n>Gg?ao%Ne zY`wMf;Tv;iJw7&}JJB_ws;}Zu*qfqco7z+V=Bxa9lQg;IYp>wh`_pyqY-}8y+}<*3i!1y7mCe@zln+WxmFF>f0+Pp92!rI0ZoKdAZC3) zLWJHDz81cH-p=xWf4Dc?2HOY9Px$Nrx`zmBmbtlm_lFp&iLz}wRD7BJc-SnzZ6~vx z?s{nkaY228ub=^0fv>1xZuD>mmWN7841z3;H!A1PXZXL6(b4cfYfB3Q!;Px>^BMmy zWO6k6-y|vA0Yoi~j93Jjn6L;kGh+&Vy~)VDm|-bnT5(BHCa~UgO{y$OEoNq9X<}qz VUC8X1#MnshsA6h#a|H!JA^=v7(}e&4 literal 0 HcmV?d00001 diff --git a/eras/alonzo/impl/test/Main.hs b/eras/alonzo/impl/test/Main.hs index f4aec8ba30d..fd379f8bf50 100644 --- a/eras/alonzo/impl/test/Main.hs +++ b/eras/alonzo/impl/test/Main.hs @@ -9,7 +9,7 @@ import qualified Test.Cardano.Ledger.Alonzo.Binary.CddlSpec as CddlSpec import qualified Test.Cardano.Ledger.Alonzo.Binary.CostModelsSpec as CostModelsSpec import qualified Test.Cardano.Ledger.Alonzo.Binary.TxWitsSpec as TxWitsSpec import qualified Test.Cardano.Ledger.Alonzo.BinarySpec as BinarySpec -import qualified Test.Cardano.Ledger.Alonzo.GoldenSpec as Golden +import qualified Test.Cardano.Ledger.Alonzo.GoldenSpec as GoldenSpec import qualified Test.Cardano.Ledger.Alonzo.GoldenTranslation as GoldenTranslation import qualified Test.Cardano.Ledger.Alonzo.Imp as Imp import qualified Test.Cardano.Ledger.Alonzo.Imp.TxInfoSpec as TxInfo @@ -35,7 +35,7 @@ main = roundTripJsonEraSpec @AlonzoEra roundTripJsonShelleyEraSpec @AlonzoEra GoldenTranslation.tests - Golden.spec + GoldenSpec.spec describe "CostModels" $ do CostModelsSpec.spec @AlonzoEra describe "TxWits" $ do diff --git a/eras/alonzo/impl/test/Test/Cardano/Ledger/Alonzo/BinarySpec.hs b/eras/alonzo/impl/test/Test/Cardano/Ledger/Alonzo/BinarySpec.hs index 184d7634716..0578acb37c5 100644 --- a/eras/alonzo/impl/test/Test/Cardano/Ledger/Alonzo/BinarySpec.hs +++ b/eras/alonzo/impl/test/Test/Cardano/Ledger/Alonzo/BinarySpec.hs @@ -10,7 +10,6 @@ import Cardano.Ledger.Core import Cardano.Ledger.MemoBytes (zipMemoRawType) import Cardano.Ledger.Plutus.Data (BinaryData, Data (..)) import Test.Cardano.Ledger.Alonzo.Arbitrary () -import qualified Test.Cardano.Ledger.Alonzo.Binary.Golden as Golden import Test.Cardano.Ledger.Alonzo.Binary.RoundTrip (roundTripAlonzoCommonSpec) import Test.Cardano.Ledger.Alonzo.Binary.Twiddle () import Test.Cardano.Ledger.Alonzo.TreeDiff () @@ -43,4 +42,3 @@ spec = do decoderEquivalenceEraSpec @AlonzoEra @(TxDats AlonzoEra) decoderEquivalenceEraSpec @AlonzoEra @(Redeemers AlonzoEra) Binary.txSizeSpec @AlonzoEra - Golden.spec @AlonzoEra diff --git a/eras/alonzo/impl/test/Test/Cardano/Ledger/Alonzo/GoldenSpec.hs b/eras/alonzo/impl/test/Test/Cardano/Ledger/Alonzo/GoldenSpec.hs index 317fc1e5077..c044ddffd3b 100644 --- a/eras/alonzo/impl/test/Test/Cardano/Ledger/Alonzo/GoldenSpec.hs +++ b/eras/alonzo/impl/test/Test/Cardano/Ledger/Alonzo/GoldenSpec.hs @@ -5,8 +5,7 @@ module Test.Cardano.Ledger.Alonzo.GoldenSpec (spec) where import Cardano.Ledger.Alonzo import Paths_cardano_ledger_alonzo (getDataFileName) -import qualified Test.Cardano.Ledger.Alonzo.Binary.Golden as Golden -import Test.Cardano.Ledger.Alonzo.Era () +import qualified Test.Cardano.Ledger.Alonzo.Binary.Golden as GoldenBinary import Test.Cardano.Ledger.Common import Test.Cardano.Ledger.Core.JSON (goldenJsonPParamsSpec, goldenJsonPParamsUpdateSpec) @@ -18,4 +17,5 @@ spec = goldenJsonPParamsSpec @AlonzoEra beforeAll (getDataFileName "golden/pparams-update.json") $ goldenJsonPParamsUpdateSpec @AlonzoEra - describe "CBOR" $ Golden.spec @AlonzoEra + describe "CBOR" $ do + GoldenBinary.spec @AlonzoEra diff --git a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Era.hs b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Era.hs index adcbc53874f..72f22b434c9 100644 --- a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Era.hs +++ b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Era.hs @@ -16,8 +16,10 @@ import Cardano.Ledger.Alonzo.Plutus.Context import Cardano.Ledger.Alonzo.UTxO import Cardano.Ledger.Plutus (Language (..)) import Data.TreeDiff +import Paths_cardano_ledger_alonzo (getDataFileName) import Test.Cardano.Ledger.Alonzo.Arbitrary () import Test.Cardano.Ledger.Alonzo.Binary.Annotator () +import Test.Cardano.Ledger.Alonzo.Examples (exampleAlonzoTx) import Test.Cardano.Ledger.Alonzo.TreeDiff () import Test.Cardano.Ledger.Common (Arbitrary) import Test.Cardano.Ledger.Mary.Era @@ -45,6 +47,10 @@ instance EraTest AlonzoEra where accountsFromAccountsMap = shelleyAccountsFromAccountsMap + mkEraFullPath = getDataFileName + + exampleTx = exampleAlonzoTx + instance ShelleyEraTest AlonzoEra instance AllegraEraTest AlonzoEra diff --git a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Examples.hs b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Examples.hs index 83f770046ad..27967cbd746 100644 --- a/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Examples.hs +++ b/eras/alonzo/impl/testlib/Test/Cardano/Ledger/Alonzo/Examples.hs @@ -11,6 +11,7 @@ module Test.Cardano.Ledger.Alonzo.Examples ( ledgerExamples, mkAlonzoBasedLedgerExamples, + exampleAlonzoTx, exampleAlonzoBasedTx, exampleAlonzoBasedTopTx, addAlonzoToConwayExampleReqSigners, @@ -86,15 +87,6 @@ ledgerExamples = exampleAlonzoTx exampleAlonzoGenesis where - exampleAlonzoTx :: Tx TopTx AlonzoEra - exampleAlonzoTx = - exampleAlonzoBasedTopTx - & addShelleyBasedTopTxExampleFee - & addShelleyToBabbageExampleProposedPUpdates - & addShelleyToBabbageTxCerts - & addShelleyToConwayTxCerts - & addAlonzoToConwayExampleReqSigners - exampleAlonzoGenesis = AlonzoGenesis { agCoinsPerUTxOWord = CoinPerWord $ Coin 1 @@ -108,6 +100,15 @@ ledgerExamples = , agExtraConfig = Nothing } +exampleAlonzoTx :: Tx TopTx AlonzoEra +exampleAlonzoTx = + exampleAlonzoBasedTopTx + & addShelleyBasedTopTxExampleFee + & addShelleyToBabbageExampleProposedPUpdates + & addShelleyToBabbageTxCerts + & addShelleyToConwayTxCerts + & addAlonzoToConwayExampleReqSigners + mkAlonzoBasedLedgerExamples :: forall era. AlonzoEraPParams era => diff --git a/eras/babbage/impl/CHANGELOG.md b/eras/babbage/impl/CHANGELOG.md index 548a3b6129f..7ce866d78d9 100644 --- a/eras/babbage/impl/CHANGELOG.md +++ b/eras/babbage/impl/CHANGELOG.md @@ -34,7 +34,7 @@ * Add `Test.Cardano.Ledger.Babbage.Imp.PoolSpec` module with `babbageEraSpecificSpec` * In `Test.Cardano.Ledger.Babbage.Examples`: - Remove `mkBabbageBasedExampleTx`, `exampleBabbageBasedTxBody` - - Add `exampleBabbageBasedTx`, `exampleBabbageBasedTopTx` + - Add `exampleBabbageBasedTx`, `exampleBabbageBasedTopTx`, `exampleBabbageTx` ## 1.13.0.0 diff --git a/eras/babbage/impl/cardano-ledger-babbage.cabal b/eras/babbage/impl/cardano-ledger-babbage.cabal index bd76cf02278..fa720e8b829 100644 --- a/eras/babbage/impl/cardano-ledger-babbage.cabal +++ b/eras/babbage/impl/cardano-ledger-babbage.cabal @@ -154,6 +154,7 @@ library testlib Test.Cardano.Ledger.Babbage.Arbitrary Test.Cardano.Ledger.Babbage.Binary.Annotator Test.Cardano.Ledger.Babbage.Binary.Cddl + Test.Cardano.Ledger.Babbage.Binary.Golden Test.Cardano.Ledger.Babbage.Binary.Twiddle Test.Cardano.Ledger.Babbage.Era Test.Cardano.Ledger.Babbage.Examples @@ -205,6 +206,7 @@ library testlib cardano-slotting, cardano-strict-containers, containers, + data-default, generic-random, microlens, microlens-ghc, diff --git a/eras/babbage/impl/golden/tx.cbor b/eras/babbage/impl/golden/tx.cbor new file mode 100644 index 0000000000000000000000000000000000000000..64675b9a3a434e32afdb38b7edc694e55bf8db06 GIT binary patch literal 2982 zcmZqK$k5mnq3}*L>f9U$O@)%vS^sH6PnQVfi33xG~`z-Is#0|Qi@Yyv)YP(|)dHzXo#nmz81k?BH+BT=1u|2ZjYGHzH!BaHL2&a=J3>3JB zk!0U9H8I|h@V-$we?G(ig^Z4d|Cxc@CPoi;Mg|5YB?duiIA@ugyLW$xp_(Y$wnN32 z*^h_K^4oSY+v%>CW)K%z_+WPq6WlqAsSr9OL>DkHBGxo9G&3_bH!(!W@J@MHQmprL z)pL8xs4cGS`&Tw!3s62NHC3L+=t&b}6G#cZga?wx7Zy!SU?cFk4`f8@pMqI&jI+CT zm3^CDBhy~+WOM%Vd}qHu5$*2V1t=>QTH@adN-+RQCT3<9md-9_pr7#+BoPWnA4zRI z`He}p@$jZN6SLFxvft~c1+B9a7C6+GBzvRUhmrM$ToWT#gzN)+<}~8Brn!Ydl6!{> zFh$k}?BHcoV1NRk07EmQB=^q3qSTzkO1;#I#N2|MR6Sq;)5L^DEH61fuQ)ZYxU^WW zAU{9Hsk*kA1;5QqEvykT_~HY9Y!D8gCblMqg`h}f=yq@Moz$p*m{*?bn8hzN=Be6MzE@`sVCk>G_$?xXyXof&6E1P_Sept6?2Y0JH^mG6QqiPv55g> z8os~=CR9fJ>9m=NkQw-GU|mQcz9mxFng|urERy^SxHy>jfNA50%(FcHpj$CZ8Yf%i zl?wiSy1`&E`YOb*~%U>=6n^FRj-d{qydyi*tV$BnTi0e+Y|*K7&i%4egrq;0bTDq=&yR_4kf;}b?73lL;0uAL%)#1amz$yGy)Z>fsbcNYlCvdmd0gh|yOwR1@}mw5GImIcCI4xVngo3|^-Gm5+ZCiiOeic3IX?SkV-l%_GQqNm?Man1oEzVGiaF}f{dn>aPuZ{fo z$eWus2Oe?WWpZr2we#T{b7nn0HlaJwHKMAo;!xO|qGX%eQ~&0x{CSf!x#erG;Mx1r zb?$6;WsFc*+`&Gt@|9GVuEp62x75!Dwh$Pbzy&d| zpk-lbV&#Mumv{?hU|t|pA|Kx@#ikMZ#e6}``hbK8y(N4teEYne<^TS0Z@4{l3V!BB zcpb@xV6rqK)$FV-Ees4ds^-sU{J)UN(dd7Zq;LliwJ + Spec +spec = do + AlonzoGolden.spec @era diff --git a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Era.hs b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Era.hs index 00aa3ad63e8..bfb7be3c852 100644 --- a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Era.hs +++ b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Era.hs @@ -12,9 +12,11 @@ import Cardano.Ledger.Alonzo.Plutus.Context (EraPlutusTxInfo) import Cardano.Ledger.Babbage import Cardano.Ledger.Babbage.Core import Cardano.Ledger.Plutus (Language (..)) +import Paths_cardano_ledger_babbage (getDataFileName) import Test.Cardano.Ledger.Alonzo.Era import Test.Cardano.Ledger.Babbage.Arbitrary () import Test.Cardano.Ledger.Babbage.Binary.Annotator () +import Test.Cardano.Ledger.Babbage.Examples (exampleBabbageTx) import Test.Cardano.Ledger.Babbage.TreeDiff () import Test.Cardano.Ledger.Plutus (zeroTestingCostModels) @@ -28,10 +30,15 @@ class instance EraTest BabbageEra where zeroCostModels = zeroTestingCostModels [PlutusV1 .. PlutusV2] + mkTestAccountState = mkShelleyTestAccountState accountsFromAccountsMap = shelleyAccountsFromAccountsMap + mkEraFullPath = getDataFileName + + exampleTx = exampleBabbageTx + instance ShelleyEraTest BabbageEra instance AllegraEraTest BabbageEra diff --git a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Examples.hs b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Examples.hs index 723f2afc100..17d0ec289ce 100644 --- a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Examples.hs +++ b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Examples.hs @@ -10,6 +10,7 @@ module Test.Cardano.Ledger.Babbage.Examples ( ledgerExamples, exampleBabbageNewEpochState, + exampleBabbageTx, exampleBabbageBasedTx, exampleBabbageBasedTopTx, ) where @@ -26,8 +27,14 @@ import Cardano.Ledger.Plutus.Data ( dataToBinaryData, ) import Cardano.Ledger.Plutus.Language (Language (..), plutusBinary) -import Cardano.Ledger.Shelley.LedgerState (NewEpochState (..)) +import Cardano.Ledger.Shelley.LedgerState ( + EraCertState (..), + NewEpochState (..), + StashedAVVMAddresses, + ) import qualified Cardano.Ledger.Shelley.Rules as Shelley +import Cardano.Ledger.State (EraStake) +import Data.Default (Default) import qualified Data.List.NonEmpty as NE import qualified Data.Map.Strict as Map import qualified Data.MapExtras as Map @@ -42,7 +49,6 @@ import Test.Cardano.Ledger.Alonzo.Examples ( exampleDatum, mkAlonzoBasedLedgerExamples, ) -import Test.Cardano.Ledger.Babbage.Era import Test.Cardano.Ledger.Core.KeyPair (mkAddr) import Test.Cardano.Ledger.Mary.Examples (exampleMultiAssetValue) import Test.Cardano.Ledger.Plutus (alwaysSucceedsPlutus) @@ -73,19 +79,24 @@ ledgerExamples = exampleBabbageNewEpochState exampleBabbageTx NoGenesis - where - exampleBabbageTx :: Tx TopTx BabbageEra - exampleBabbageTx = - exampleBabbageBasedTopTx - & addShelleyBasedTopTxExampleFee - & addShelleyToBabbageExampleProposedPUpdates - & addShelleyToBabbageTxCerts - & addShelleyToConwayTxCerts - & addAlonzoToConwayExampleReqSigners + +exampleBabbageTx :: Tx TopTx BabbageEra +exampleBabbageTx = + exampleBabbageBasedTopTx + & addShelleyBasedTopTxExampleFee + & addShelleyToBabbageExampleProposedPUpdates + & addShelleyToBabbageTxCerts + & addShelleyToConwayTxCerts + & addAlonzoToConwayExampleReqSigners exampleBabbageNewEpochState :: - ( BabbageEraTest era + ( BabbageEraPParams era , Value era ~ MaryValue + , EraTxOut era + , EraGov era + , EraStake era + , EraCertState era + , Default (StashedAVVMAddresses era) ) => NewEpochState era exampleBabbageNewEpochState = diff --git a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp.hs b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp.hs index 112d0573201..1fff409e2ba 100644 --- a/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp.hs +++ b/eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp.hs @@ -2,11 +2,9 @@ {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} -{-# OPTIONS_GHC -Wno-orphans #-} module Test.Cardano.Ledger.Babbage.Imp (spec, babbageEraSpecificSpec) where diff --git a/eras/conway/impl/CHANGELOG.md b/eras/conway/impl/CHANGELOG.md index d9ead9735f3..31a0c9bac96 100644 --- a/eras/conway/impl/CHANGELOG.md +++ b/eras/conway/impl/CHANGELOG.md @@ -50,7 +50,7 @@ * Make `Test.Cardano.Ledger.Conway.Imp.spec` accept `Proxy era` * In `Test.Cardano.Ledger.Conway.Examples`: - Remove `mkConwayBasedExampleTx`, `exampleConwayBasedTxBody` - - Add `exampleConwayBasedTx`, `exampleConwayBasedTopTx` + - Add `exampleConwayBasedTx`, `exampleConwayBasedTopTx`, `exampleConwayTx` ## 1.22.0.0 diff --git a/eras/conway/impl/golden/tx.cbor b/eras/conway/impl/golden/tx.cbor new file mode 100644 index 0000000000000000000000000000000000000000..b02c57ecf6c7b379f69efa7a1ff50c1d62314aa0 GIT binary patch literal 5381 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 ( mkBasicTxWits - & scriptTxWitsL <>~ Map.fromElems hashScript [alwaysSucceeds @'PlutusV4 3] + -- NOTE: PlutusV4 scripts are NOT part of Dijkstra's transaction_witness_set + -- CDDL (only V1/V2/V3 are). Including them here would cause a roundtrip + -- failure as they get silently dropped during serialization. See + -- TODO in 'Cardano.Ledger.Dijkstra.HuddleSpec'. + -- & scriptTxWitsL <>~ Map.fromElems hashScript [alwaysSucceeds @'PlutusV4 3] & rdmrsTxWitsL <>~ redeemers ) & modifyTxAuxData diff --git a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/ImpTest.hs b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/ImpTest.hs index 480c24bd0b1..4be08a30bce 100644 --- a/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/ImpTest.hs +++ b/eras/dijkstra/impl/testlib/Test/Cardano/Ledger/Dijkstra/ImpTest.hs @@ -13,7 +13,6 @@ module Test.Cardano.Ledger.Dijkstra.ImpTest ( module Test.Cardano.Ledger.Conway.ImpTest, - exampleDijkstraGenesis, DijkstraEraImp, impDijkstraSatisfyNativeScript, ) where @@ -30,8 +29,6 @@ import Cardano.Ledger.Conway.TxCert import Cardano.Ledger.Credential import Cardano.Ledger.Dijkstra (ApplyTxError, DijkstraEra) import Cardano.Ledger.Dijkstra.Core -import Cardano.Ledger.Dijkstra.Genesis (DijkstraGenesis (..)) -import Cardano.Ledger.Dijkstra.PParams (UpgradeDijkstraPParams (..)) import Cardano.Ledger.Dijkstra.Rules ( DijkstraLedgerPredFailure (..), DijkstraMempoolPredFailure, @@ -54,11 +51,11 @@ import Cardano.Ledger.Shelley.Scripts ( import Cardano.Ledger.State import Data.List.NonEmpty (NonEmpty) import qualified Data.Map.Strict as Map -import Data.Maybe (fromJust) import qualified Data.Set as Set import Lens.Micro import Test.Cardano.Ledger.Conway.ImpTest import Test.Cardano.Ledger.Dijkstra.Era +import Test.Cardano.Ledger.Dijkstra.Examples (exampleDijkstraGenesis) import Test.Cardano.Ledger.Imp.Common instance ShelleyEraImp DijkstraEra where @@ -124,18 +121,6 @@ instance InjectRuleFailure "DELEG" Shelley.ShelleyDelegPredFailure DijkstraEra w injectFailure (Shelley.StakeKeyNonZeroAccountBalanceDELEG c) = Conway.StakeKeyHasNonZeroAccountBalanceDELEG c injectFailure _ = error "Cannot inject ShelleyDelegPredFailure into DijkstraEra" -exampleDijkstraGenesis :: DijkstraGenesis -exampleDijkstraGenesis = - DijkstraGenesis - { dgUpgradePParams = - UpgradeDijkstraPParams - { udppMaxRefScriptSizePerBlock = 1024 * 1024 -- 1MiB - , udppMaxRefScriptSizePerTx = 200 * 1024 -- 200KiB - , udppRefScriptCostStride = knownNonZeroBounded @25_600 -- 25 KiB - , udppRefScriptCostMultiplier = fromJust $ boundRational 1.2 - } - } - impDijkstraSatisfyNativeScript :: ( DijkstraEraImp era , NativeScript era ~ DijkstraNativeScript era diff --git a/eras/mary/impl/CHANGELOG.md b/eras/mary/impl/CHANGELOG.md index 2c901b3af34..55fce69bc69 100644 --- a/eras/mary/impl/CHANGELOG.md +++ b/eras/mary/impl/CHANGELOG.md @@ -14,7 +14,7 @@ * Make `Test.Cardano.Ledger.Mary.Imp.spec` accept `Proxy era` * In `Test.Cardano.Ledger.Mary.Examples`: - Remove `exampleMaryBasedShelleyTxBody`, `exampleMaryBasedTxBody` - - Add `exampleMaryBasedTx` + - Add `exampleMaryBasedTx`, `exampleMaryTx` ## 1.10.0.0 diff --git a/eras/mary/impl/cardano-ledger-mary.cabal b/eras/mary/impl/cardano-ledger-mary.cabal index 6819a754380..e4dd8ab3457 100644 --- a/eras/mary/impl/cardano-ledger-mary.cabal +++ b/eras/mary/impl/cardano-ledger-mary.cabal @@ -12,7 +12,10 @@ description: category: Network build-type: Simple -data-files: cddl/data/mary.cddl +data-files: + cddl/data/mary.cddl + golden/*.cbor + extra-source-files: CHANGELOG.md source-repository head diff --git a/eras/mary/impl/golden/tx.cbor b/eras/mary/impl/golden/tx.cbor new file mode 100644 index 0000000000000000000000000000000000000000..defbb5049cbcd97d30e8eb748c3a5ce28e06cb7b GIT binary patch literal 1901 zcmZo(#n9Lkq3}*L>f9U$O@)%vS^sDSTdZR z91%44OVJ!7w?zw#PtQ>9wk-f!Y$3;n{G%%*fvMVD9`iYXG+-rQvKS*w2mxh z(RYugygSI*S)Q8TC$NYyJSAc8zsBz?b zu1O+gVT8Fi>Tkii#b5ei2iNo_p&jY+rh@TNEuv(xpm-|MFZt+NvrIMkOUd!yQik@bdL z6C+oI>;rt}G~&0WxrITJdxr}n14Dhl4qiqD1}FduFf=nta_=lGO3g{E)Jv^M%q_@C z)dPlQ6B8D(yyX16;?%t2(qg@W{QMlJ>e^-&{5CVSutvyi%ntkdhRyrg8k^M#rtjCa zZB9F5dt|}Y!UWrbrx7x#e+p*BG0yJVRrYOqjZAyNlg;_d^PT`;YwC%&5zTC`I@-8H zUh||rul==iX2qPN&rUJ4&jhJrU~FOlnT9X0n;4rI@u!7mCPHT5w}Evbf%uk4VQV6k z9$6&$7jUshC>Xu8UU&4*yTdNd{auWYrUqEqv1Ok7=kj*ej~kz#-V=7`VB#cX6l&65 z%+LhP=3O0+@0M_WoccHDwyw>t*rHSEocm>`2uXh~>0sQ#pC1$9AW<*=*mJ|gz!w5f znb#ZLT%aHKtIG1Wj+3p*Q`yzW*1r>;E;mEVdtr)}QpMV(C1*?C^0>^^cP-nz>BLq2 z!z*2xfRjYP|3A2~0xI^eOeJMxxhgad=htvjkd;kh5? zS;T$s^I6>Yapv-g9_Pg78mvy)DrR%Hw&zcR@xM0@BNS%2Oa9YzLHE?# zKo7evUdEvL&)Zr4?+^Ee+hF@ZNerJIK=%+~%`!K4 z@BR=&HBq*0hl($=9}k=5x9w!M(_JskATFp+@Z~*_75H)=Q)5eng1?8|gb0RhTYt}f z6+P=|cy7+#sDEBk&s%v#$|w3Q&QOYQm~Ak7E3*`@jr{k>o0~QV9&z4fa%{b|^WhtF zW<5SOp*ztvqN=arP}rNIWSiPk|K_Xwd6P7`q2J7q(*v2F92iCEWZE% literal 0 HcmV?d00001 diff --git a/eras/mary/impl/test/Main.hs b/eras/mary/impl/test/Main.hs index 5b5002a4fb8..462f4e20fe5 100644 --- a/eras/mary/impl/test/Main.hs +++ b/eras/mary/impl/test/Main.hs @@ -10,7 +10,6 @@ import Test.Cardano.Ledger.Era import qualified Test.Cardano.Ledger.Mary.Binary.CddlSpec as CddlSpec import qualified Test.Cardano.Ledger.Mary.BinarySpec as BinarySpec import qualified Test.Cardano.Ledger.Mary.Imp as Imp -import Test.Cardano.Ledger.Era import Test.Cardano.Ledger.Mary.ImpTest () import qualified Test.Cardano.Ledger.Mary.ValueSpec as ValueSpec import qualified Test.Cardano.Ledger.Shelley.Imp as Imp (shelleyEraSpecificSpec) diff --git a/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Era.hs b/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Era.hs index ec5a88f0082..bac19bddffb 100644 --- a/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Era.hs +++ b/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Era.hs @@ -9,9 +9,11 @@ module Test.Cardano.Ledger.Mary.Era ( import Cardano.Ledger.Mary import Cardano.Ledger.Mary.Core import Cardano.Ledger.Plutus (emptyCostModels) +import Paths_cardano_ledger_mary (getDataFileName) import Test.Cardano.Ledger.Allegra.Era import Test.Cardano.Ledger.Mary.Arbitrary () import Test.Cardano.Ledger.Mary.Binary.Annotator () +import Test.Cardano.Ledger.Mary.Examples (exampleMaryTx) import Test.Cardano.Ledger.Mary.TreeDiff () class @@ -27,6 +29,10 @@ instance EraTest MaryEra where accountsFromAccountsMap = shelleyAccountsFromAccountsMap + mkEraFullPath = getDataFileName + + exampleTx = exampleMaryTx + instance ShelleyEraTest MaryEra instance AllegraEraTest MaryEra diff --git a/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Examples.hs b/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Examples.hs index 682272567cc..1bf7b78e836 100644 --- a/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Examples.hs +++ b/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Examples.hs @@ -10,6 +10,7 @@ -- don't care, we are only interested in serialisation, not validation. module Test.Cardano.Ledger.Mary.Examples ( ledgerExamples, + exampleMaryTx, exampleMaryBasedTx, exampleMultiAsset, exampleMultiAssetValue, @@ -52,14 +53,14 @@ ledgerExamples = (exampleMultiAssetValue 1) exampleMaryTx NoGenesis - where - exampleMaryTx :: Tx TopTx MaryEra - exampleMaryTx = - exampleMaryBasedTx - & addShelleyBasedTopTxExampleFee - & addShelleyToBabbageExampleProposedPUpdates - & addShelleyToBabbageTxCerts - & addShelleyToConwayTxCerts + +exampleMaryTx :: Tx TopTx MaryEra +exampleMaryTx = + exampleMaryBasedTx + & addShelleyBasedTopTxExampleFee + & addShelleyToBabbageExampleProposedPUpdates + & addShelleyToBabbageTxCerts + & addShelleyToConwayTxCerts -- Complete transaction which is compatible with any era starting with Mary. -- This transaction forms the basis on which future era transactions will be diff --git a/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp.hs b/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp.hs index 325db485bf4..9048e4b9f09 100644 --- a/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp.hs +++ b/eras/mary/impl/testlib/Test/Cardano/Ledger/Mary/Imp.hs @@ -2,7 +2,6 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -{-# OPTIONS_GHC -Wno-orphans #-} module Test.Cardano.Ledger.Mary.Imp (spec) where diff --git a/eras/shelley/impl/CHANGELOG.md b/eras/shelley/impl/CHANGELOG.md index 1042fbd0fd9..faf0028dc2e 100644 --- a/eras/shelley/impl/CHANGELOG.md +++ b/eras/shelley/impl/CHANGELOG.md @@ -70,7 +70,7 @@ * Export `exampleShelleyScript` and `exampleBootstrapWitness` from `Test.Cardano.Ledger.Shelley.Examples` * In `Test.Cardano.Ledger.Shelley.Examples`: - Remove `mkShelleyBasedExampleTx`, `exampleShelleyBasedShelleyTxBody`, `exampleShelleyBasedTxBody`, `exampleCerts` - - Add `exampleShelleyBasedTx`, `addShelleyBasedTopTxExampleFee`, `addShelleyToBabbageExampleProposedPUpdates`, `addShelleyToBabbageTxCerts`, `addShelleyToConwayTxCerts` + - Add `exampleShelleyTx`, `exampleShelleyBasedTx`, `addShelleyBasedTopTxExampleFee`, `addShelleyToBabbageExampleProposedPUpdates`, `addShelleyToBabbageTxCerts`, `addShelleyToConwayTxCerts` ## 1.18.0.0 diff --git a/eras/shelley/impl/cardano-ledger-shelley.cabal b/eras/shelley/impl/cardano-ledger-shelley.cabal index 05e1488048c..d0fe2b48c70 100644 --- a/eras/shelley/impl/cardano-ledger-shelley.cabal +++ b/eras/shelley/impl/cardano-ledger-shelley.cabal @@ -8,6 +8,7 @@ synopsis: Shelley Ledger Executable Model build-type: Simple data-files: cddl/data/shelley.cddl + golden/*.cbor golden/*.json extra-source-files: CHANGELOG.md diff --git a/eras/shelley/impl/golden/tx.cbor b/eras/shelley/impl/golden/tx.cbor new file mode 100644 index 0000000000000000000000000000000000000000..350579fbe2fca393111de21101a9e8f15b50d68f GIT binary patch literal 1517 zcmZo(!O++gq3}*L>f9U$O@)%vS^s>9wk-f!Y$3;n{G%%*fvMVD9`iYXG+-rQvKS*w2mxh z(RYugygSI*S)Q8TC$NYyJSAc8zuyIVx z%v>y;UCa?O_`DIJaP*PX#*^QebQ=$EiZd}gT`&8+ep=8vJ7IxCeMz!6s(lz)Z^$(< zaz)5Kz-LY)eruXr7$muOxG*v>)CcU~WmI5*0-yjxGovK;&cdS9oWx4K)QZI1f}B)6 zp!b@Xu!!X)=jRot<`tI~>lNhZ=Qvf@HnZTjnW=>}LS|!j*w;5~-p|(9tWGd}zpia_ z+8Ns;3$7L>*cLpEkV*YhFe{F6cGs@5Z_{gJ+6$g+&R?GI?Dr?4-F-XZ@M&UeVp!P3 z5Fx|R?cU-$sZswhuRPbuZNERaSDe{3cZZ?YP4)?uj6hY4U{zgHPrQw2W_#7q#vSsS zC-r&lubne1<{W)?ilKcbNEHKP69dRJe1YA>*u)qi^I*A%;S8a}--~y#yot@W|8sTK zjR3ZWXqIXYRmWx~LT2E%fpsB)_?AdvYg&lk4GUQ$`4@1pM<^J*v|e}g&%47e&i!4C zkERA#*|BAw`{(j@){h&XpWYL8U(C=1%t&1wkMEXnew_L@=(euSuGpee>74szrwB=Z zF6m(0!k-@#;czD8<=v&-XU-;X3!L(2ugOm{`(55Ig%xhy5IJl9_|np4uQ%H{ww8sz zEMfNR&n!+hSood4g4_7OXZ@$AGhF_!Vgg!Xou$6#+_ojUNsCup(8}j6PBjuOmwn{C z%<6#0!tTghnh_5Cxwm$f?Vk`HbHDnJX%2Uz5aZPCTx$Fo=Oh+$KEChb@Fte|o^e)- z>6b-wUNC)H{O#klNligH2RJ2d?3mhOU$8JXHZwCdgF}DH!;)gXpR1nRTSjehW#7ND z`C5STL8+-m!IbAy#D!i_Q?{HeAf6z$l@*4 fmNKRlmlS0JOE}l0%97M#W=57KMkdyU%#KL_p9G0Z literal 0 HcmV?d00001 diff --git a/eras/shelley/impl/test/Main.hs b/eras/shelley/impl/test/Main.hs index 819e58a15ab..14feee936a4 100644 --- a/eras/shelley/impl/test/Main.hs +++ b/eras/shelley/impl/test/Main.hs @@ -9,7 +9,6 @@ import Test.Cardano.Ledger.Era import qualified Test.Cardano.Ledger.Shelley.Binary.CddlSpec as Cddl import qualified Test.Cardano.Ledger.Shelley.BinarySpec as Binary import qualified Test.Cardano.Ledger.Shelley.Imp as Imp -import Test.Cardano.Ledger.Era import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec) instance EraSpec ShelleyEra where diff --git a/eras/shelley/impl/test/Test/Cardano/Ledger/Shelley/Binary/GoldenSpec.hs b/eras/shelley/impl/test/Test/Cardano/Ledger/Shelley/Binary/GoldenSpec.hs index 87e7fff220a..d0c17b29211 100644 --- a/eras/shelley/impl/test/Test/Cardano/Ledger/Shelley/Binary/GoldenSpec.hs +++ b/eras/shelley/impl/test/Test/Cardano/Ledger/Shelley/Binary/GoldenSpec.hs @@ -12,7 +12,6 @@ import Test.Cardano.Ledger.Shelley.Binary.Golden ( goldenNewEpochStateExpectation, shelleyDecodeDuplicateDelegCertSucceeds, ) -import Test.Cardano.Ledger.Shelley.Era () spec :: Spec spec = diff --git a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Era.hs b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Era.hs index a20d3f15cfb..40fab3cbeed 100644 --- a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Era.hs +++ b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Era.hs @@ -30,10 +30,12 @@ import Data.Default import qualified Data.Map.Strict as Map import Data.Typeable import Lens.Micro +import Paths_cardano_ledger_shelley (getDataFileName) import Test.Cardano.Ledger.Common import Test.Cardano.Ledger.Era import Test.Cardano.Ledger.Shelley.Arbitrary () import Test.Cardano.Ledger.Shelley.Binary.Annotator () +import Test.Cardano.Ledger.Shelley.Examples (exampleShelleyTx) import Test.Cardano.Ledger.Shelley.TreeDiff () class @@ -64,6 +66,10 @@ instance EraTest ShelleyEra where accountsFromAccountsMap = shelleyAccountsFromAccountsMap + mkEraFullPath = getDataFileName + + exampleTx = exampleShelleyTx + instance ShelleyEraTest ShelleyEra mkShelleyTestAccountState :: diff --git a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Examples.hs b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Examples.hs index 62ae9116dad..a8d4e75b076 100644 --- a/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Examples.hs +++ b/eras/shelley/impl/testlib/Test/Cardano/Ledger/Shelley/Examples.hs @@ -16,6 +16,7 @@ module Test.Cardano.Ledger.Shelley.Examples ( ledgerExamples, -- functions used in building examples for other eras mkShelleyBasedLedgerExamples, + exampleShelleyTx, exampleShelleyBasedTx, addShelleyBasedTopTxExampleFee, addShelleyToBabbageExampleProposedPUpdates, @@ -134,15 +135,15 @@ ledgerExamples = exampleCoin exampleShelleyTx emptyFromByronTranslationContext - where - exampleShelleyTx :: Tx TopTx ShelleyEra - exampleShelleyTx = - exampleShelleyBasedTx - & bodyTxL . ttlTxBodyL .~ SlotNo 10 - & addShelleyBasedTopTxExampleFee - & addShelleyToBabbageExampleProposedPUpdates - & addShelleyToBabbageTxCerts - & addShelleyToConwayTxCerts + +exampleShelleyTx :: Tx TopTx ShelleyEra +exampleShelleyTx = + exampleShelleyBasedTx + & bodyTxL . ttlTxBodyL .~ SlotNo 10 + & addShelleyBasedTopTxExampleFee + & addShelleyToBabbageExampleProposedPUpdates + & addShelleyToBabbageTxCerts + & addShelleyToConwayTxCerts mkShelleyBasedLedgerExamples :: forall era. diff --git a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Era.hs b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Era.hs index 3ec83d57612..ede0c436fcf 100644 --- a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Era.hs +++ b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Era.hs @@ -25,6 +25,7 @@ import Data.Aeson (FromJSON, ToJSON) import Data.Functor.Identity import qualified Data.Map.Strict as Map import Data.Typeable +import Test.Cardano.Ledger.Binary.Golden (cborAnnGoldenSpec) import Test.Cardano.Ledger.Common import Test.Cardano.Ledger.Core.Arbitrary () import Test.Cardano.Ledger.TreeDiff () @@ -108,6 +109,15 @@ class accountsFromAccountsMap :: Map.Map (Credential Staking) (AccountState era) -> Accounts era + -- | Get the full path for the era directory. + -- An use case for this is for saving golden files in a golden test directory + -- for each era. + mkEraFullPath :: FilePath -> IO FilePath + + -- | Example transaction that needs to be provided for each era. Doesn't need + -- to be valid, but all possible fields must be set to some example value. + exampleTx :: Tx TopTx era + class EraTest era => EraSpec era where -- | All of Imp spec that is applicable to this era eraImpSpec :: Proxy era -> Spec @@ -124,7 +134,13 @@ ledgerEraTestMain extraEraSpec = ledgerTestMain $ describe (eraName @era) $ do describe "Imp" $ eraImpSpec (Proxy @era) - extraEraSpec + describe "Golden" $ + cborAnnGoldenSpec + (mkEraFullPath @era) + "golden/tx.cbor" + (eraProtVerLow @era) + (exampleTx @era) + describe "Era-specific spec" extraEraSpec -- | This is a helper function that uses `mkTestAccountState` to register an account. registerTestAccount :: diff --git a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Imp/Common.hs b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Imp/Common.hs index f89a4163139..eeacbb69390 100644 --- a/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Imp/Common.hs +++ b/libs/cardano-ledger-core/testlib/Test/Cardano/Ledger/Imp/Common.hs @@ -1,11 +1,8 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE FunctionalDependencies #-} -{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ScopedTypeVariables #-} -{-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wno-orphans #-}