@@ -25,6 +25,7 @@ import Cardano.Ledger.Allegra.TxAuxData (AllegraTxAuxData (..))
25
25
import Cardano.Ledger.Alonzo (AlonzoEra )
26
26
import Cardano.Ledger.Alonzo.Core
27
27
import Cardano.Ledger.Alonzo.PParams
28
+ import Cardano.Ledger.Alonzo.Plutus.Context (EraPlutusTxInfo , mkSupportedPlutusScript )
28
29
import Cardano.Ledger.Alonzo.Rules (vKeyLocked )
29
30
import Cardano.Ledger.Alonzo.Scripts as Alonzo (
30
31
AlonzoPlutusPurpose (.. ),
@@ -98,11 +99,11 @@ import Numeric.Natural (Natural)
98
99
import qualified PlutusLedgerApi.Common as P (Data (.. ))
99
100
import System.Random
100
101
import Test.Cardano.Ledger.AllegraEraGen (genValidityInterval )
101
- import Test.Cardano.Ledger.Alonzo.Arbitrary (alwaysFails , alwaysSucceeds , mkPlutusScript' )
102
+ import Test.Cardano.Ledger.Alonzo.Arbitrary ()
102
103
import Test.Cardano.Ledger.Binary.Random
103
104
import Test.Cardano.Ledger.Common (tracedDiscard )
104
105
import Test.Cardano.Ledger.MaryEraGen (addTokens , genMint , maryGenesisValue , policyIndex )
105
- import Test.Cardano.Ledger.Plutus (zeroTestingCostModels )
106
+ import Test.Cardano.Ledger.Plutus (alwaysFailsPlutus , alwaysSucceedsPlutus , zeroTestingCostModels )
106
107
import Test.Cardano.Ledger.Plutus.Examples
107
108
import Test.Cardano.Ledger.Shelley.Constants (Constants (.. ))
108
109
import Test.Cardano.Ledger.Shelley.Generator.Core (
@@ -128,63 +129,98 @@ import Test.QuickCheck hiding ((><))
128
129
vKeyLockedAdaOnly :: TxOut AlonzoEra -> Bool
129
130
vKeyLockedAdaOnly txOut = vKeyLocked txOut && isAdaOnly (txOut ^. valueTxOutL)
130
131
131
- phase2scripts3Arg :: forall era . AlonzoEraScript era => [TwoPhase3ArgInfo era ]
132
+ phase2scripts3Arg :: EraPlutusTxInfo PlutusV1 era => [TwoPhase3ArgInfo era ]
132
133
phase2scripts3Arg =
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
134
139
, mkTwoPhase3ArgInfo
135
- (mkPlutusScript' (redeemerSameAsDatum SPlutusV1 ))
140
+ (mkSupportedPlutusScript (redeemerSameAsDatum SPlutusV1 ))
136
141
(P. I 9 )
137
142
(P. I 9 , bigMem, bigStep)
138
143
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
141
144
, 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 ))
143
156
(P. I 3 )
144
157
(P. I 4 , bigMem, bigStep)
145
158
True
146
159
, mkTwoPhase3ArgInfo
147
- (mkPlutusScript' (datumIsWellformed SPlutusV1 ))
160
+ (mkSupportedPlutusScript (datumIsWellformed SPlutusV1 ))
148
161
(P. I 5 )
149
162
(P. I 6 , bigMem, bigStep)
150
163
True
151
164
, mkTwoPhase3ArgInfo
152
- (mkPlutusScript' (inputsOutputsAreNotEmptyWithDatum SPlutusV1 ))
165
+ (mkSupportedPlutusScript (inputsOutputsAreNotEmptyWithDatum SPlutusV1 ))
153
166
(P. I 7 )
154
167
(P. I 9 , bigMem, bigStep)
155
168
True
156
169
]
157
170
where
158
- mkTwoPhase3ArgInfo script = TwoPhase3ArgInfo script (hashScript @ era script)
171
+ mkTwoPhase3ArgInfo plutusScript =
172
+ let script = fromPlutusScript plutusScript
173
+ in TwoPhase3ArgInfo script (hashScript script)
159
174
160
- phase2scripts2Arg :: forall era . AlonzoEraScript era => [TwoPhase2ArgInfo era ]
175
+ phase2scripts2Arg :: EraPlutusTxInfo PlutusV1 era => [TwoPhase2ArgInfo era ]
161
176
phase2scripts2Arg =
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
165
181
, mkTwoPhase2ArgInfo
166
- (mkPlutusScript' (purposeIsWellformedNoDatum SPlutusV1 ))
182
+ (mkSupportedPlutusScript (evenRedeemerNoDatum SPlutusV1 ))
167
183
(P. I 14 , bigMem, bigStep)
168
184
True
169
185
, 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 ))
171
195
(P. I 15 , bigMem, bigStep)
172
196
True
173
197
]
174
198
where
175
- mkTwoPhase2ArgInfo script = TwoPhase2ArgInfo script (hashScript @ era script)
199
+ mkTwoPhase2ArgInfo plutusScript =
200
+ let script = fromPlutusScript plutusScript
201
+ in TwoPhase2ArgInfo script (hashScript script)
176
202
177
- phase2scripts3ArgSucceeds :: forall era . AlonzoEraScript era => Script era -> Bool
203
+ phase2scripts3ArgSucceeds ::
204
+ forall era .
205
+ EraPlutusTxInfo PlutusV1 era =>
206
+ Script era ->
207
+ Bool
178
208
phase2scripts3ArgSucceeds script =
179
209
maybe True getSucceeds3 $
180
210
List. find (\ info -> getScript3 info == script) phase2scripts3Arg
181
211
182
- phase2scripts2ArgSucceeds :: forall era . AlonzoEraScript era => Script era -> Bool
212
+ phase2scripts2ArgSucceeds ::
213
+ forall era .
214
+ EraPlutusTxInfo PlutusV1 era =>
215
+ Script era ->
216
+ Bool
183
217
phase2scripts2ArgSucceeds script =
184
218
maybe True getSucceeds2 $
185
219
List. find (\ info -> getScript2 info == script) phase2scripts2Arg
186
220
187
- genPlutus2Arg :: AlonzoEraScript era => Gen (Maybe (TwoPhase2ArgInfo era ))
221
+ genPlutus2Arg ::
222
+ EraPlutusTxInfo PlutusV1 era =>
223
+ Gen (Maybe (TwoPhase2ArgInfo era ))
188
224
genPlutus2Arg = frequency [(10 , Just <$> elements phase2scripts2Arg), (90 , pure Nothing )]
189
225
190
226
-- | Gen a Mint value in the Alonzo Era, with a 10% chance that it includes an AlonzoScript
0 commit comments