1+ {-# LANGUAGE NamedFieldPuns #-}
12{-# LANGUAGE TypeApplications #-}
23
34module Test.Cardano.Ledger.Alonzo.Imp.TxInfoSpec (spec ) where
@@ -10,72 +11,68 @@ import Cardano.Ledger.Alonzo.Core (
1011 EraTxOut (.. ),
1112 )
1213import Cardano.Ledger.Alonzo.Plutus.Context (EraPlutusTxInfo (.. ), LedgerTxInfo (.. ))
13- import Cardano.Ledger.Alonzo.TxBody (AlonzoTxOut (.. ))
14- import Cardano.Ledger.BaseTypes (EpochSize (.. ), Inject (.. ), StrictMaybe (.. ))
14+ import Cardano.Ledger.BaseTypes
1515import Cardano.Ledger.Coin (Coin (.. ))
1616import Cardano.Ledger.Plutus (SLanguage (.. ))
17- import Cardano.Ledger.State (UTxO (.. ))
18- import Cardano.Slotting.EpochInfo (fixedEpochInfo )
19- import Cardano.Slotting.Time (SystemStart (.. ), mkSlotLength )
20- import Data.Either (isRight )
21- import qualified Data.Map.Strict as Map
2217import qualified Data.Sequence.Strict as SSeq
2318import qualified Data.Set as Set
24- import Data.Time.Clock.POSIX (posixSecondsToUTCTime )
2519import Lens.Micro ((&) , (.~) )
20+ import Lens.Micro.Mtl (use )
2621import Test.Cardano.Ledger.Alonzo.ImpTest
2722import Test.Cardano.Ledger.Imp.Common
2823
2924spec :: Spec
30- spec = withImpInit @ (LedgerSpec AlonzoEra ) $ describe " TxInfoSpec " $ do
25+ spec = withImpInit @ (LedgerSpec AlonzoEra ) $ describe " TxInfo " $ do
3126 describe " PlutusV1" $ do
3227 it " toPlutusTxInfo does not fail when Byron scripts are present in TxOuts" $ do
3328 pv <- getProtVer
29+ Globals {epochInfo, systemStart} <- use impGlobalsL
3430 (_, shelleyAddr) <- freshKeyAddr
3531 byronAddr <- AddrBootstrap <$> freshBootstapAddress
36- shelleyTxIn <- arbitrary
32+ shelleyTxIn <- sendCoinTo shelleyAddr mempty
33+ utxo <- getUTxO
3734 let
3835 byronTxOut = mkBasicTxOut byronAddr . inject $ Coin 1
3936 tx =
4037 mkBasicTx @ AlonzoEra mkBasicTxBody
4138 & bodyTxL
42- . inputsTxBodyL
43- .~ Set. singleton shelleyTxIn
39+ . inputsTxBodyL
40+ .~ Set. singleton shelleyTxIn
4441 & bodyTxL
45- . outputsTxBodyL
46- .~ SSeq. singleton byronTxOut
42+ . outputsTxBodyL
43+ .~ SSeq. singleton byronTxOut
4744 lti =
4845 LedgerTxInfo
4946 { ltiProtVer = pv
50- , ltiEpochInfo = fixedEpochInfo ( EpochSize 100 ) (mkSlotLength 1 )
51- , ltiSystemStart = SystemStart $ posixSecondsToUTCTime 0
52- , ltiUTxO = UTxO . Map. singleton shelleyTxIn $ AlonzoTxOut shelleyAddr (inject $ Coin 2 ) SNothing
47+ , ltiEpochInfo = epochInfo
48+ , ltiSystemStart = systemStart
49+ , ltiUTxO = utxo
5350 , ltiTx = tx
5451 }
55- toPlutusTxInfo SPlutusV1 lti `shouldSatisfy` isRight
52+ void $ expectRight $ toPlutusTxInfo SPlutusV1 lti
5653 it " toPlutusTxInfo does not fail when Byron scripts are present in TxIns" $ do
5754 pv <- getProtVer
55+ Globals {epochInfo, systemStart} <- use impGlobalsL
5856 (_, shelleyAddr) <- freshKeyAddr
5957 byronAddr <- AddrBootstrap <$> freshBootstapAddress
60- byronTxIn <- arbitrary
58+ byronTxIn <- sendCoinTo byronAddr mempty
59+ utxo <- getUTxO
6160 let
6261 shelleyTxOut = mkBasicTxOut shelleyAddr . inject $ Coin 1
6362 tx =
6463 mkBasicTx @ AlonzoEra mkBasicTxBody
6564 & bodyTxL
66- . inputsTxBodyL
67- .~ Set. singleton byronTxIn
65+ . inputsTxBodyL
66+ .~ Set. singleton byronTxIn
6867 & bodyTxL
69- . outputsTxBodyL
70- .~ SSeq. singleton shelleyTxOut
68+ . outputsTxBodyL
69+ .~ SSeq. singleton shelleyTxOut
7170 lti =
7271 LedgerTxInfo
7372 { ltiProtVer = pv
74- , ltiEpochInfo = fixedEpochInfo (EpochSize 100 ) (mkSlotLength 1 )
75- , ltiSystemStart = SystemStart $ posixSecondsToUTCTime 0
76- , ltiUTxO =
77- UTxO . Map. singleton byronTxIn $
78- AlonzoTxOut byronAddr (inject $ Coin 2 ) SNothing
73+ , ltiEpochInfo = epochInfo
74+ , ltiSystemStart = systemStart
75+ , ltiUTxO = utxo
7976 , ltiTx = tx
8077 }
81- toPlutusTxInfo SPlutusV1 lti `shouldSatisfy` isRight
78+ void $ expectRight $ toPlutusTxInfo SPlutusV1 lti
0 commit comments