Skip to content

Commit 4a9e8a4

Browse files
committed
Added txInfoSpec tests to Dijkstra
1 parent d3ec8ec commit 4a9e8a4

File tree

4 files changed

+21
-14
lines changed

4 files changed

+21
-14
lines changed

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{-# LANGUAGE TypeApplications #-}
99
{-# LANGUAGE TypeOperators #-}
1010

11-
module Test.Cardano.Ledger.Babbage.TxInfoSpec (txInfoSpecV2, spec) where
11+
module Test.Cardano.Ledger.Babbage.TxInfoSpec (txInfoSpec, spec) where
1212

1313
import Cardano.Ledger.Address (Addr (..))
1414
import Cardano.Ledger.Alonzo.Plutus.Context (
@@ -35,7 +35,7 @@ import Cardano.Ledger.Credential (StakeReference (..))
3535
import Cardano.Ledger.Hashes (unsafeMakeSafeHash)
3636
import Cardano.Ledger.Mary.Value (MaryValue)
3737
import Cardano.Ledger.Plutus.Data (Data (..), Datum (..), dataToBinaryData)
38-
import Cardano.Ledger.Plutus.Language (Language (..), SLanguage (..))
38+
import Cardano.Ledger.Plutus.Language (Language (..), SLanguage (..), plutusLanguage)
3939
import Cardano.Ledger.State (UTxO (..))
4040
import Cardano.Ledger.TxIn (TxId (..), TxIn (..), mkTxInPartial)
4141
import Cardano.Slotting.EpochInfo (EpochInfo, fixedEpochInfo)
@@ -314,7 +314,7 @@ txInfoSpecV1 =
314314
(txBare shelleyInput inlineDatumOutput)
315315
(inject $ InlineDatumsNotSupported @era (TxOutFromOutput minBound))
316316

317-
txInfoSpecV2 ::
317+
txInfoSpec ::
318318
forall era l.
319319
( EraTx era
320320
, EraPlutusTxInfo l era
@@ -327,7 +327,7 @@ txInfoSpecV2 ::
327327
) =>
328328
SLanguage l ->
329329
Spec
330-
txInfoSpecV2 lang =
330+
txInfoSpec lang =
331331
describe (show lang) $ do
332332
it "translation error on byron txout" $
333333
expectTranslationError @era
@@ -344,11 +344,13 @@ txInfoSpecV2 lang =
344344
lang
345345
(txBare unknownInput shelleyOutput)
346346
(inject $ AlonzoContextError $ TranslationLogicMissingInput @era unknownInput)
347-
it "use reference input starting in Babbage" $
348-
successfulTranslation @era
349-
lang
350-
(txRefInput shelleyInput)
351-
hasReferenceInput
347+
-- This test will fail in PlutusV3 because of ReferenceInputsNotDisjointFromInputs
348+
when (plutusLanguage lang == PlutusV2) $
349+
it "use reference input starting in Babbage" $
350+
successfulTranslation @era
351+
lang
352+
(txRefInput shelleyInput)
353+
hasReferenceInput
352354
it "use inline datum in input" $
353355
successfulTranslation @era
354356
lang
@@ -389,7 +391,7 @@ spec ::
389391
spec =
390392
describe "txInfo translation" $ do
391393
txInfoSpecV1 @era
392-
txInfoSpecV2 @era SPlutusV2
394+
txInfoSpec @era SPlutusV2
393395

394396
genesisId :: TxId
395397
genesisId = TxId (unsafeMakeSafeHash (mkDummyHash (0 :: Int)))

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,5 @@ spec =
121121
describe "TxInfo" $ do
122122
TxInfo.spec @era
123123
BabbageTxInfo.spec @era
124-
describe "PlutusV3" $ BabbageTxInfo.txInfoSpecV2 @era SPlutusV3
124+
describe "PlutusV3" $
125+
BabbageTxInfo.txInfoSpec @era SPlutusV3

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ test-suite tests
194194

195195
build-depends:
196196
base,
197-
cardano-ledger-core:testlib,
198-
cardano-ledger-dijkstra:{cardano-ledger-dijkstra, testlib},
199197
cardano-ledger-babbage:testlib,
198+
cardano-ledger-core:{cardano-ledger-core, testlib},
199+
cardano-ledger-dijkstra:{cardano-ledger-dijkstra, testlib},
200200
cardano-ledger-shelley:testlib,

eras/dijkstra/impl/test/Main.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ module Main where
44

55
import Cardano.Ledger.Dijkstra (DijkstraEra)
66
import Cardano.Ledger.Dijkstra.Rules ()
7+
import Cardano.Ledger.Plutus (SLanguage (..))
8+
import Test.Cardano.Ledger.Babbage.TxInfoSpec (txInfoSpec)
9+
import qualified Test.Cardano.Ledger.Babbage.TxInfoSpec as BabbageTxInfo
710
import Test.Cardano.Ledger.Common
811
import Test.Cardano.Ledger.Dijkstra.Binary.Annotator ()
912
import Test.Cardano.Ledger.Dijkstra.Binary.RoundTrip ()
1013
import qualified Test.Cardano.Ledger.Dijkstra.GoldenSpec as GoldenSpec
1114
import qualified Test.Cardano.Ledger.Dijkstra.Imp as Imp
1215
import Test.Cardano.Ledger.Dijkstra.ImpTest ()
1316
import Test.Cardano.Ledger.Shelley.JSON (roundTripJsonShelleyEraSpec)
14-
import qualified Test.Cardano.Ledger.Babbage.TxInfoSpec as BabbageTxInfo
1517

1618
main :: IO ()
1719
main =
@@ -23,3 +25,5 @@ main =
2325
Imp.spec @DijkstraEra
2426
describe "TxInfo" $ do
2527
BabbageTxInfo.spec @DijkstraEra
28+
txInfoSpec @DijkstraEra SPlutusV3
29+
txInfoSpec @DijkstraEra SPlutusV4

0 commit comments

Comments
 (0)