Skip to content

Commit 8bfce0d

Browse files
Soupstrawlehins
andcommitted
Update eras/conway/impl/testlib/Test/Cardano/Ledger/Conway/Imp/UtxoSpec.hs
Co-authored-by: Alexey Kuleshevich <[email protected]>
1 parent 1ce6ad7 commit 8bfce0d

File tree

2 files changed

+30
-37
lines changed

2 files changed

+30
-37
lines changed

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

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ import Cardano.Ledger.TxIn (TxIn (..))
4141
import Cardano.Ledger.Val
4242
import qualified Data.ByteString.Short as SBS (length)
4343
import Data.Functor ((<&>))
44-
import qualified Data.List.NonEmpty as NE
4544
import qualified Data.Map.Strict as Map
4645
import qualified Data.Sequence.Strict as SSeq
4746
import qualified Data.Set as Set
@@ -82,35 +81,31 @@ spec =
8281
describe "disjoint inputs and reference inputs" $ do
8382
let
8483
scriptHash lang = hashPlutusScript $ inputsOverlapsWithRefInputs lang
85-
tx :: TxIn -> Tx era
86-
tx txIn =
84+
mkTestTx :: TxIn -> Tx era
85+
mkTestTx txIn =
8786
mkBasicTx mkBasicTxBody
8887
& bodyTxL . inputsTxBodyL .~ Set.singleton txIn
8988
& bodyTxL . referenceInputsTxBodyL .~ Set.singleton txIn
9089

91-
it "Can run scripts that expect inputs and refInputs to overlap (PV 9)" . whenMajorVersion @9 $ do
90+
it "Cannot run scripts that expect inputs and refInputs to overlap (PV 9)" $ whenMajorVersion @9 $ do
9291
txIn <- produceScript $ scriptHash SPlutusV3
93-
submitTx_ @era $ tx txIn
94-
it "Same script cannot appear in regular and reference inputs in PlutusV3 (PV 10)"
95-
. whenMajorVersion @10
96-
$ do
97-
txIn <- produceScript $ scriptHash SPlutusV3
98-
submitFailingTx @era
99-
(tx txIn)
100-
[ injectFailure $
101-
BabbageNonDisjointRefInputs
102-
(txIn NE.:| [])
103-
]
104-
it "Same script cannot appear in regular and reference inputs in PlutusV3 (PV 11)"
105-
. whenMajorVersionAtLeast @11
106-
$ do
107-
txIn <- produceScript $ scriptHash SPlutusV3
108-
submitFailingTx @era
109-
(tx txIn)
110-
[ injectFailure $
111-
CollectErrors
112-
[BadTranslation . inject $ ReferenceInputsNotDisjointFromInputs @era (txIn NE.:| [])]
113-
]
92+
submitFailingTx @era
93+
(mkTestTx txIn)
94+
[ injectFailure $ BabbageNonDisjointRefInputs [txIn]
95+
]
96+
it "Same script cannot appear in regular and reference inputs in PlutusV3 (PV 10)" $ whenMajorVersion @10 $ do
97+
txIn <- produceScript $ scriptHash SPlutusV3
98+
submitFailingTx @era
99+
(mkTestTx txIn)
100+
[ injectFailure $ BabbageNonDisjointRefInputs [txIn]
101+
]
102+
it "Same script cannot appear in regular and reference inputs in PlutusV3 (PV 11)" $ whenMajorVersionAtLeast @11 $ do
103+
txIn <- produceScript $ scriptHash SPlutusV3
104+
submitFailingTx @era
105+
(mkTestTx txIn)
106+
[ injectFailure $
107+
CollectErrors [BadTranslation . inject $ ReferenceInputsNotDisjointFromInputs @era [txIn]]
108+
]
114109
where
115110
checkMinFee :: HasCallStack => NativeScript era -> [Script era] -> ImpTestM era ()
116111
checkMinFee scriptToSpend refScripts = do

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import Cardano.Ledger.Shelley.LedgerState
3232
import Cardano.Ledger.Shelley.Rules (ShelleyUtxowPredFailure (..))
3333
import Cardano.Ledger.TxIn (TxId (..), mkTxInPartial)
3434
import Data.Default (def)
35-
import Data.Either (isLeft, isRight)
3635
import Data.List.NonEmpty (NonEmpty (..))
3736
import qualified Data.Map.Strict as Map
3837
import qualified Data.OSet.Strict as OSet
@@ -121,17 +120,16 @@ datumAndReferenceInputsSpec = do
121120
, mkTxInPartial producingTx 1
122121
]
123122
& bodyTxL . referenceInputsTxBodyL .~ Set.singleton (mkTxInPartial producingTx 0)
124-
pv <- getProtVer
125-
res <- trySubmitTx consumingTx
126-
if pv == ProtVer (natVersion @10) 0
127-
then case res of
128-
Left (err, _) ->
129-
err
130-
`shouldBeExpr` ( pure . injectFailure . BabbageNonDisjointRefInputs $
131-
mkTxInPartial producingTx 0 :| []
132-
)
133-
x -> x `shouldSatisfyExpr` isLeft
134-
else res `shouldSatisfyExpr` isRight
123+
let badTxIns = mkTxInPartial producingTx 0 :| []
124+
125+
whenMajorVersionAtMost @10 $
126+
submitFailingTx
127+
consumingTx
128+
(pure . injectFailure $ BabbageNonDisjointRefInputs badTxIns)
129+
130+
-- consumingTx uses PlutusV1 script, so it should be a success
131+
whenMajorVersionAtLeast @11 $
132+
submitTx_ consumingTx
135133
it "fails when using inline datums for PlutusV1" $ do
136134
let shSpending = hashPlutusScript (redeemerSameAsDatum SPlutusV1)
137135
refTxOut <- mkRefTxOut shSpending

0 commit comments

Comments
 (0)