@@ -28,10 +28,12 @@ import Gen.Models
28
28
import Debug.Trace
29
29
30
30
checkVestingWithPeriod = testGroup " checkVestingWithPeriod"
31
- [ HH. testProperty " correct_vesting" correctVesting
32
- , HH. testProperty " incorrect_signature_qty_vesting" incorrectSignatureQtyVesting
33
- , HH. testProperty " incorrect_time_vesting" incorrectTimeVesting
34
- , HH. testProperty " incorrect_value_vesting" incorrectValueVesting
31
+ [
32
+ -- HH.testProperty "correct_vesting" correctVesting
33
+ -- , HH.testProperty "incorrect_signature_qty_vesting" incorrectSignatureQtyVesting
34
+ -- , HH.testProperty "incorrect_time_vesting" incorrectTimeVesting
35
+ -- , HH.testProperty "incorrect_value_vesting" incorrectValueVesting
36
+ , HH. testProperty " incorrect_datum_in_output" incorrectDatumVesting
35
37
]
36
38
37
39
correctVesting :: Property
@@ -290,4 +292,59 @@ incorrectValueVesting = property $ do
290
292
in (newVestingBoxInput, prevResult && isRight resultEither)
291
293
) (initialVestingWPTxIn, True ) periodsList
292
294
295
+ result === False
296
+
297
+ incorrectDatumVesting :: Property
298
+ incorrectDatumVesting = property $ do
299
+ let
300
+ range = linear 24 4096
301
+ firstPkh <- forAll genPkh
302
+ secondPkh <- forAll genPkh
303
+ vestingOutTxRef <- forAll genTxOutRef
304
+ vestingAC <- forAll genAssetClass
305
+ vestingStartInt <- (forAll $ int range)
306
+
307
+ vestingPeriodDurationInt <- forAll $ int range
308
+
309
+ totalVestedInt <- forAll $ int range
310
+ let
311
+ vestedRange = linear 24 totalVestedInt
312
+
313
+ maxPeriodIdInt <- forAll $ int vestedRange
314
+ let
315
+
316
+ vestingStart = toInteger vestingStartInt
317
+
318
+ vestingPeriodDuration = toInteger vestingPeriodDurationInt
319
+
320
+ totalVested = toInteger totalVestedInt
321
+ maxPeriodId = toInteger maxPeriodIdInt
322
+
323
+ periodVested = totalVested `div` maxPeriodId
324
+
325
+ vestingWPCfg = genVestingWithPeriodConfig vestingStart vestingPeriodDuration totalVested periodVested [firstPkh, secondPkh] vestingAC
326
+ vestingWPCfgData = toData vestingWPCfg
327
+ vestingWPDatum = OutputDatum $ mkDatum vestingWPCfg
328
+ initialVestingWPTxIn = genVestingWPTxIn vestingOutTxRef vestingWPDatum vestingAC totalVested
329
+ periodsList = [1 .. maxPeriodId]
330
+
331
+ deadline = vestingStart + vestingPeriodDuration * periodId
332
+
333
+ vestingRedeemToData = toData $ PPVestingWP. VestingWithPeriodRedeemer 0 periodId
334
+
335
+ newVestingBox = genVestingWPTxOut NoOutputDatum vestingAC (totalVested - periodId * periodVested)
336
+
337
+ newVestingBoxInput = mkTxIn vestingOutTxRef newVestingBox
338
+
339
+ userTxOut = genUserTxOut vestingAC periodVested firstPkh
340
+
341
+ txInfo = mkVestingTxInfo [vestingBox] [newVestingBox, userTxOut] (deadline + 5 ) (deadline + 10 ) [secondPkh]
342
+
343
+ purpose = mkPurpose vestingOutTxRef
344
+
345
+ cxtData = toData $ mkContext txInfo purpose
346
+
347
+ resultEither = eraseRight $ evalWithArgs (wrapValidator PVestingWP. vestingWithPeriodValidatorT) [vestingWPCfgData, vestingRedeemToData, cxtData]
348
+
349
+
293
350
result === False
0 commit comments