Skip to content

Commit 0d5318e

Browse files
committed
Reapply review suggestions
1 parent b68ef5c commit 0d5318e

File tree

6 files changed

+15
-19
lines changed

6 files changed

+15
-19
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ fixupDatums tx = impAnn "fixupDatums" $ do
287287
getData txOut =
288288
let sh = txOutScriptHash txOut
289289
in case txOut ^. datumTxOutF of
290-
DatumHash _dh -> case Map.lookup sh (scriptTestContexts @era) of
291-
Just x -> pure . Just $ spendDatum x
292-
Nothing -> do
290+
DatumHash dh -> case Map.lookup sh (scriptTestContexts @era) of
291+
Just x | hashData @era (spendDatum x) == dh -> pure . Just $ spendDatum x
292+
_ -> do
293293
logText $
294294
"Script not found in `scriptTestContexts`:\n"
295295
<> T.pack (show sh)

eras/babbage/impl/src/Cardano/Ledger/Babbage/Rules/Utxo.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ disjointRefInputs ::
232232
Test (BabbageUtxoPredFailure era)
233233
disjointRefInputs pp inputs refInputs =
234234
when
235-
(pvMajor (pp ^. ppProtocolVersionL) == natVersion @10)
235+
( pvMajor (pp ^. ppProtocolVersionL) > eraProtVerHigh @BabbageEra
236+
&& pvMajor (pp ^. ppProtocolVersionL) < natVersion @11
237+
)
236238
(failureOnNonEmpty common BabbageNonDisjointRefInputs)
237239
where
238240
common = inputs `Set.intersection` refInputs

eras/babbage/impl/testlib/Test/Cardano/Ledger/Babbage/Imp/UtxoSpec.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ import Cardano.Ledger.Babbage.Core (
1313
EraTx (..),
1414
EraTxBody (..),
1515
EraTxOut (..),
16-
KeyRole (..),
1716
)
1817
import Cardano.Ledger.BaseTypes (Inject (..))
1918
import Cardano.Ledger.Coin (Coin (..))
20-
import Cardano.Ledger.Credential (Credential (..), StakeReference (..))
19+
import Cardano.Ledger.Credential (StakeReference (..))
2120
import Cardano.Ledger.Plutus (
2221
Data (..),
2322
Datum (..),
@@ -49,11 +48,11 @@ spec = describe "UTXO" $ do
4948
txOut =
5049
mkBasicTxOut
5150
( mkAddr
52-
(ScriptHashObj @'Payment $ hashPlutusScript (inputsOverlapsWithRefInputs SPlutusV2))
51+
(hashPlutusScript (inputsOverlapsWithRefInputs SPlutusV2))
5352
StakeRefNull
5453
)
5554
(inject $ Coin 1_000_000)
56-
& datumTxOutL .~ (Datum . dataToBinaryData . Data . PV1.I $ 0)
55+
& datumTxOutL .~ Datum (dataToBinaryData . Data $ PV1.I 0)
5756
tx <-
5857
submitTx $
5958
mkBasicTx mkBasicTxBody

eras/conway/impl/src/Cardano/Ledger/Conway/TxInfo.hs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ import Control.DeepSeq (NFData)
118118
import Control.Monad (unless, when, zipWithM)
119119
import Data.Aeson (ToJSON (..), (.=))
120120
import Data.Foldable as F (Foldable (..))
121+
import Data.List.NonEmpty (NonEmpty (..))
121122
import qualified Data.Map.Strict as Map
122123
import qualified Data.OSet.Strict as OSet
123124
import qualified Data.Set as Set
@@ -166,7 +167,7 @@ data ConwayContextError era
166167
| VotingProceduresFieldNotSupported !(VotingProcedures era)
167168
| ProposalProceduresFieldNotSupported !(OSet.OSet (ProposalProcedure era))
168169
| TreasuryDonationFieldNotSupported !Coin
169-
| ReferenceInputsNotDisjointFromInputs !(Set.Set TxIn)
170+
| ReferenceInputsNotDisjointFromInputs !(NonEmpty TxIn)
170171
deriving (Generic)
171172

172173
deriving instance
@@ -472,8 +473,9 @@ instance EraPlutusTxInfo 'PlutusV3 ConwayEra where
472473
refInputsInfo <- mapM (transTxInInfoV3 ltiUTxO) (Set.toList refInputs)
473474
let
474475
commonInputs = txInputs `Set.intersection` refInputs
475-
unless (pvMajor ltiProtVer < natVersion @11 || Set.null commonInputs) . Left $
476-
ReferenceInputsNotDisjointFromInputs commonInputs
476+
unless (pvMajor ltiProtVer < natVersion @11) $ case toList commonInputs of
477+
(x : xs) -> Left $ ReferenceInputsNotDisjointFromInputs $ x :| xs
478+
_ -> Right ()
477479
outputs <-
478480
zipWithM
479481
(Babbage.transTxOutV2 . TxOutFromOutput)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ spec ::
9090
, ToExpr (Event (EraRule "ENACT" era))
9191
, Eq (Event (EraRule "ENACT" era))
9292
, Typeable (Event (EraRule "ENACT" era))
93-
, ContextError era ~ ConwayContextError era
9493
) =>
9594
Spec
9695
spec = do
@@ -126,7 +125,6 @@ conwaySpec ::
126125
, ToExpr (Event (EraRule "ENACT" era))
127126
, Eq (Event (EraRule "ENACT" era))
128127
, Typeable (Event (EraRule "ENACT" era))
129-
, ContextError era ~ ConwayContextError era
130128
) =>
131129
SpecWith (ImpInit (LedgerSpec era))
132130
conwaySpec = do

eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxoSpec.hs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ spec ::
5858
( ConwayEraImp era
5959
, InjectRuleFailure "LEDGER" BabbageUtxoPredFailure era
6060
, InjectRuleFailure "LEDGER" AlonzoUtxosPredFailure era
61-
, ContextError era ~ ConwayContextError era
6261
) =>
6362
SpecWith (ImpInit (LedgerSpec era))
6463
spec =
@@ -110,11 +109,7 @@ spec =
110109
(tx txIn)
111110
[ injectFailure $
112111
CollectErrors
113-
[ BadTranslation
114-
( ReferenceInputsNotDisjointFromInputs
115-
(Set.singleton txIn)
116-
)
117-
]
112+
[inject (ReferenceInputsNotDisjointFromInputs (Set.singleton txIn))]
118113
]
119114
where
120115
checkMinFee :: HasCallStack => NativeScript era -> [Script era] -> ImpTestM era ()

0 commit comments

Comments
 (0)