@@ -9,6 +9,8 @@ import Cardano.Api (MonadIO)
9
9
import Control.Monad (void )
10
10
import Control.Monad.Catch (MonadCatch )
11
11
import Control.Monad.Trans.Control (MonadBaseControl )
12
+ import Data.List (isInfixOf )
13
+ import System.Exit (ExitCode (ExitSuccess ))
12
14
13
15
import Test.Cardano.CLI.Hash (exampleAnchorDataHash , exampleAnchorDataHash2 ,
14
16
exampleAnchorDataIpfsHash , exampleAnchorDataIpfsHash2 ,
@@ -497,6 +499,108 @@ hprop_golden_conway_governance_action_create_protocol_parameters_update_partial_
497
499
" test/cardano-cli-golden/files/golden/governance/action/conway-create-protocol-parameters-update-partial-costmodels.action"
498
500
H. diffFileVsGoldenFile actionFile goldenActionFile
499
501
502
+ -- | Execute me with:
503
+ -- @cabal test cardano-cli-golden --test-options '-p "/golden conway governance action create protocol parameters too small costmodel size/"'@
504
+ hprop_golden_conway_governance_action_create_protocol_parameters_too_small_costmodel_size
505
+ :: Property
506
+ hprop_golden_conway_governance_action_create_protocol_parameters_too_small_costmodel_size =
507
+ propertyOnce . H. moduleWorkspace " tmp" $ \ tempDir -> do
508
+ -- This file has 165 entries, whereas PV1 requires 166
509
+ runOnCostModelFile
510
+ tempDir
511
+ " test/cardano-cli-golden/files/input/governance/costmodels-v1-too-small.json"
512
+ -- This file has 184 entries, whereas PV2 requires 185
513
+ runOnCostModelFile
514
+ tempDir
515
+ " test/cardano-cli-golden/files/input/governance/costmodels-v2-too-small.json"
516
+ -- This file has 184 entries, whereas PV3 requires 297
517
+ runOnCostModelFile
518
+ tempDir
519
+ " test/cardano-cli-golden/files/input/governance/costmodels-v3-too-small.json"
520
+ where
521
+ runOnCostModelFile tempDir costModelsFile = do
522
+ stakeAddressVKeyFile <- H. note " test/cardano-cli-golden/files/input/governance/stake-address.vkey"
523
+
524
+ actionFile <- noteTempFile tempDir " action"
525
+
526
+ (exitCode, _stdout, stderr) <-
527
+ H. noteShowM $
528
+ H. execDetailCardanoCLI
529
+ [ " conway"
530
+ , " governance"
531
+ , " action"
532
+ , " create-protocol-parameters-update"
533
+ , " --anchor-url"
534
+ , " example.com"
535
+ , " --anchor-data-hash"
536
+ , " c7ddb5b493faa4d3d2d679847740bdce0c5d358d56f9b1470ca67f5652a02745"
537
+ , " --mainnet"
538
+ , " --deposit-return-stake-verification-key-file"
539
+ , stakeAddressVKeyFile
540
+ , " --governance-action-deposit"
541
+ , " 12345"
542
+ , " --cost-model-file"
543
+ , costModelsFile
544
+ , " --out-file"
545
+ , actionFile
546
+ ]
547
+
548
+ H. assert (exitCode /= ExitSuccess )
549
+ H. assertWith stderr $ \ msg -> " The decoded cost model has the wrong size" `isInfixOf` msg
550
+
551
+ -- | Execute me with:
552
+ -- @cabal test cardano-cli-golden --test-options '-p "/golden conway governance action create protocol parameters too large costmodel size/"'@
553
+ hprop_golden_conway_governance_action_create_protocol_parameters_too_large_costmodel_size
554
+ :: Property
555
+ hprop_golden_conway_governance_action_create_protocol_parameters_too_large_costmodel_size =
556
+ propertyOnce . H. moduleWorkspace " tmp" $ \ tempDir -> do
557
+ -- From https://input-output-rnd.slack.com/archives/CCRB7BU8Y/p1727096158830419?thread_ts=1727089226.813099&cid=CCRB7BU8Y
558
+ --
559
+ -- Having too large models is fine:
560
+ --
561
+ -- Ziyang Liu
562
+ -- There should not be any check on the upper bound. The number of parameters for V1, V2 and V3 can increase at any time as we add new builtins or other features to the languages.
563
+ -- Theoretically they can also possibly decrease but that's very unlikely, certainly not below the current numbers.
564
+
565
+ -- This file has 167 entries, whereas PV1 requires 166
566
+ runOnCostModelFile
567
+ tempDir
568
+ " test/cardano-cli-golden/files/input/governance/costmodels-v1-too-large.json"
569
+ -- This file has 186 entries, whereas PV2 requires 185
570
+ runOnCostModelFile
571
+ tempDir
572
+ " test/cardano-cli-golden/files/input/governance/costmodels-v2-too-large.json"
573
+ -- This file has 298 entries, whereas PV3 requires 297
574
+ runOnCostModelFile
575
+ tempDir
576
+ " test/cardano-cli-golden/files/input/governance/costmodels-v3-too-large.json"
577
+ where
578
+ runOnCostModelFile tempDir costModelsFile = do
579
+ stakeAddressVKeyFile <- H. note " test/cardano-cli-golden/files/input/governance/stake-address.vkey"
580
+
581
+ actionFile <- noteTempFile tempDir " action"
582
+
583
+ H. noteShowM_ $
584
+ H. execCardanoCLI
585
+ [ " conway"
586
+ , " governance"
587
+ , " action"
588
+ , " create-protocol-parameters-update"
589
+ , " --anchor-url"
590
+ , " example.com"
591
+ , " --anchor-data-hash"
592
+ , " c7ddb5b493faa4d3d2d679847740bdce0c5d358d56f9b1470ca67f5652a02745"
593
+ , " --mainnet"
594
+ , " --deposit-return-stake-verification-key-file"
595
+ , stakeAddressVKeyFile
596
+ , " --governance-action-deposit"
597
+ , " 12345"
598
+ , " --cost-model-file"
599
+ , costModelsFile
600
+ , " --out-file"
601
+ , actionFile
602
+ ]
603
+
500
604
hprop_golden_conway_governance_action_create_hardfork_wrong_hash_fails :: Property
501
605
hprop_golden_conway_governance_action_create_hardfork_wrong_hash_fails =
502
606
propertyOnce . expectFailure . H. moduleWorkspace " tmp" $ \ tempDir -> do
0 commit comments