@@ -25,6 +25,7 @@ import Cardano.Ledger.Allegra.TxAuxData (AllegraTxAuxData (..))
2525import Cardano.Ledger.Alonzo (AlonzoEra )
2626import Cardano.Ledger.Alonzo.Core
2727import Cardano.Ledger.Alonzo.PParams
28+ import Cardano.Ledger.Alonzo.Plutus.Context (EraPlutusTxInfo , mkSupportedPlutusScript )
2829import Cardano.Ledger.Alonzo.Rules (vKeyLocked )
2930import Cardano.Ledger.Alonzo.Scripts as Alonzo (
3031 AlonzoPlutusPurpose (.. ),
@@ -98,11 +99,11 @@ import Numeric.Natural (Natural)
9899import qualified PlutusLedgerApi.Common as P (Data (.. ))
99100import System.Random
100101import Test.Cardano.Ledger.AllegraEraGen (genValidityInterval )
101- import Test.Cardano.Ledger.Alonzo.Arbitrary (alwaysFails , alwaysSucceeds , mkPlutusScript' )
102+ import Test.Cardano.Ledger.Alonzo.Arbitrary ()
102103import Test.Cardano.Ledger.Binary.Random
103104import Test.Cardano.Ledger.Common (tracedDiscard )
104105import Test.Cardano.Ledger.MaryEraGen (addTokens , genMint , maryGenesisValue , policyIndex )
105- import Test.Cardano.Ledger.Plutus (zeroTestingCostModels )
106+ import Test.Cardano.Ledger.Plutus (alwaysFailsPlutus , alwaysSucceedsPlutus , zeroTestingCostModels )
106107import Test.Cardano.Ledger.Plutus.Examples
107108import Test.Cardano.Ledger.Shelley.Constants (Constants (.. ))
108109import Test.Cardano.Ledger.Shelley.Generator.Core (
@@ -128,63 +129,98 @@ import Test.QuickCheck hiding ((><))
128129vKeyLockedAdaOnly :: TxOut AlonzoEra -> Bool
129130vKeyLockedAdaOnly txOut = vKeyLocked txOut && isAdaOnly (txOut ^. valueTxOutL)
130131
131- phase2scripts3Arg :: forall era . AlonzoEraScript era => [TwoPhase3ArgInfo era ]
132+ phase2scripts3Arg :: EraPlutusTxInfo PlutusV1 era => [TwoPhase3ArgInfo era ]
132133phase2scripts3Arg =
133- [ mkTwoPhase3ArgInfo (alwaysSucceeds @ 'PlutusV1 3 ) (P. I 1 ) (P. I 1 , bigMem, bigStep) True
134+ [ mkTwoPhase3ArgInfo
135+ (mkSupportedPlutusScript (alwaysSucceedsPlutus @ 'PlutusV1 3 ))
136+ (P. I 1 )
137+ (P. I 1 , bigMem, bigStep)
138+ True
134139 , mkTwoPhase3ArgInfo
135- (mkPlutusScript' (redeemerSameAsDatum SPlutusV1 ))
140+ (mkSupportedPlutusScript (redeemerSameAsDatum SPlutusV1 ))
136141 (P. I 9 )
137142 (P. I 9 , bigMem, bigStep)
138143 True
139- , mkTwoPhase3ArgInfo (mkPlutusScript' (evenDatum SPlutusV1 )) (P. I 8 ) (P. I 8 , bigMem, bigStep) True
140- , mkTwoPhase3ArgInfo (alwaysFails @ 'PlutusV1 3 ) (P. I 1 ) (P. I 1 , bigMem, bigStep) False
141144 , mkTwoPhase3ArgInfo
142- (mkPlutusScript' (purposeIsWellformedWithDatum SPlutusV1 ))
145+ (mkSupportedPlutusScript (evenDatum SPlutusV1 ))
146+ (P. I 8 )
147+ (P. I 8 , bigMem, bigStep)
148+ True
149+ , mkTwoPhase3ArgInfo
150+ (mkSupportedPlutusScript (alwaysFailsPlutus @ 'PlutusV1 3 ))
151+ (P. I 1 )
152+ (P. I 1 , bigMem, bigStep)
153+ False
154+ , mkTwoPhase3ArgInfo
155+ (mkSupportedPlutusScript (purposeIsWellformedWithDatum SPlutusV1 ))
143156 (P. I 3 )
144157 (P. I 4 , bigMem, bigStep)
145158 True
146159 , mkTwoPhase3ArgInfo
147- (mkPlutusScript' (datumIsWellformed SPlutusV1 ))
160+ (mkSupportedPlutusScript (datumIsWellformed SPlutusV1 ))
148161 (P. I 5 )
149162 (P. I 6 , bigMem, bigStep)
150163 True
151164 , mkTwoPhase3ArgInfo
152- (mkPlutusScript' (inputsOutputsAreNotEmptyWithDatum SPlutusV1 ))
165+ (mkSupportedPlutusScript (inputsOutputsAreNotEmptyWithDatum SPlutusV1 ))
153166 (P. I 7 )
154167 (P. I 9 , bigMem, bigStep)
155168 True
156169 ]
157170 where
158- mkTwoPhase3ArgInfo script = TwoPhase3ArgInfo script (hashScript @ era script)
171+ mkTwoPhase3ArgInfo plutusScript =
172+ let script = fromPlutusScript plutusScript
173+ in TwoPhase3ArgInfo script (hashScript script)
159174
160- phase2scripts2Arg :: forall era . AlonzoEraScript era => [TwoPhase2ArgInfo era ]
175+ phase2scripts2Arg :: EraPlutusTxInfo PlutusV1 era => [TwoPhase2ArgInfo era ]
161176phase2scripts2Arg =
162- [ mkTwoPhase2ArgInfo (alwaysSucceeds @ 'PlutusV1 2 ) (P. I 1 , bigMem, bigStep) True
163- , mkTwoPhase2ArgInfo (mkPlutusScript' (evenRedeemerNoDatum SPlutusV1 )) (P. I 14 , bigMem, bigStep) True
164- , mkTwoPhase2ArgInfo (alwaysFails @ 'PlutusV1 2 ) (P. I 1 , bigMem, bigStep) False
177+ [ mkTwoPhase2ArgInfo
178+ (mkSupportedPlutusScript (alwaysSucceedsPlutus @ 'PlutusV1 2 ))
179+ (P. I 1 , bigMem, bigStep)
180+ True
165181 , mkTwoPhase2ArgInfo
166- (mkPlutusScript' (purposeIsWellformedNoDatum SPlutusV1 ))
182+ (mkSupportedPlutusScript (evenRedeemerNoDatum SPlutusV1 ))
167183 (P. I 14 , bigMem, bigStep)
168184 True
169185 , mkTwoPhase2ArgInfo
170- (mkPlutusScript' (inputsOutputsAreNotEmptyNoDatum SPlutusV1 ))
186+ (mkSupportedPlutusScript (alwaysFailsPlutus @ 'PlutusV1 2 ))
187+ (P. I 1 , bigMem, bigStep)
188+ False
189+ , mkTwoPhase2ArgInfo
190+ (mkSupportedPlutusScript (purposeIsWellformedNoDatum SPlutusV1 ))
191+ (P. I 14 , bigMem, bigStep)
192+ True
193+ , mkTwoPhase2ArgInfo
194+ (mkSupportedPlutusScript (inputsOutputsAreNotEmptyNoDatum SPlutusV1 ))
171195 (P. I 15 , bigMem, bigStep)
172196 True
173197 ]
174198 where
175- mkTwoPhase2ArgInfo script = TwoPhase2ArgInfo script (hashScript @ era script)
199+ mkTwoPhase2ArgInfo plutusScript =
200+ let script = fromPlutusScript plutusScript
201+ in TwoPhase2ArgInfo script (hashScript script)
176202
177- phase2scripts3ArgSucceeds :: forall era . AlonzoEraScript era => Script era -> Bool
203+ phase2scripts3ArgSucceeds ::
204+ forall era .
205+ EraPlutusTxInfo PlutusV1 era =>
206+ Script era ->
207+ Bool
178208phase2scripts3ArgSucceeds script =
179209 maybe True getSucceeds3 $
180210 List. find (\ info -> getScript3 info == script) phase2scripts3Arg
181211
182- phase2scripts2ArgSucceeds :: forall era . AlonzoEraScript era => Script era -> Bool
212+ phase2scripts2ArgSucceeds ::
213+ forall era .
214+ EraPlutusTxInfo PlutusV1 era =>
215+ Script era ->
216+ Bool
183217phase2scripts2ArgSucceeds script =
184218 maybe True getSucceeds2 $
185219 List. find (\ info -> getScript2 info == script) phase2scripts2Arg
186220
187- genPlutus2Arg :: AlonzoEraScript era => Gen (Maybe (TwoPhase2ArgInfo era ))
221+ genPlutus2Arg ::
222+ EraPlutusTxInfo PlutusV1 era =>
223+ Gen (Maybe (TwoPhase2ArgInfo era ))
188224genPlutus2Arg = frequency [(10 , Just <$> elements phase2scripts2Arg), (90 , pure Nothing )]
189225
190226-- | Gen a Mint value in the Alonzo Era, with a 10% chance that it includes an AlonzoScript
0 commit comments