Skip to content

Commit

Permalink
Merge pull request #671 from IntersectMBO/smelc/fix-metadata-url-64-c…
Browse files Browse the repository at this point in the history
…hars-limit

drep: registration-certificate, update-certificate: test anchors URLs of length > 64 and <= 128
  • Loading branch information
smelc authored Mar 22, 2024
2 parents 95528f9 + 51ce7e4 commit e37a31a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ test-suite cardano-cli-test
other-modules: Test.Cli.AddCostModels
Test.Cli.CreateTestnetData
Test.Cli.FilePermissions
Test.Cli.Governance.DRep
Test.Cli.Governance.Hash
Test.Cli.ITN
Test.Cli.JSON
Expand Down
60 changes: 60 additions & 0 deletions cardano-cli/test/cardano-cli-test/Test/Cli/Governance/DRep.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

{- HLINT ignore "Use camelCase" -}

module Test.Cli.Governance.DRep where

import Control.Monad

import Test.Cardano.CLI.Util (execCardanoCLI, propertyOnce)

import Hedgehog
import qualified Hedgehog.Extras.Test.Base as H

metadataUrls :: [String]
metadataUrls = [ "dummy-url"
, "length-84-here-we-goooooooooooooooooooooooooooooooooooooooooooooooooooooo-dummy-url"
, "exactly-128-chars-here-we-goooooooooooooooooooooooooooooooooooooooooooooooooooooo-dummy-url-ooooooooooooooooooooooooooooooooooo" ]

-- | This is a test of https://github.com/IntersectMBO/cardano-cli/issues/552
-- Execute me with:
-- @cabal test cardano-cli-test --test-options '-p "/governance drep registration certificate script hash/"'@
hprop_governance_drep_registration_certificate_script_hash :: Property
hprop_governance_drep_registration_certificate_script_hash =
propertyOnce $ forM_ metadataUrls $ \metadataUrl -> do
H.moduleWorkspace "tmp" $ \tempDir -> do
outFile <- H.noteTempFile tempDir "drep-reg-cert.txt"

H.noteShowM_ $ execCardanoCLI
[ "conway", "governance", "drep", "registration-certificate"
, "--drep-script-hash", "00000000000000000000000000000000000000000000000000000003"
, "--key-reg-deposit-amt", "0"
, "--drep-metadata-url", metadataUrl
, "--drep-metadata-hash", "52e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2"
, "--out-file", outFile
]

-- | This is a test of https://github.com/IntersectMBO/cardano-cli/issues/552
-- Execute me with:
-- @cabal test cardano-cli-test --test-options '-p "/governance drep update certificate vkey file/"'@
hprop_governance_drep_update_certificate_vkey_file :: Property
hprop_governance_drep_update_certificate_vkey_file =
propertyOnce $ forM_ metadataUrls $ \metadataUrl -> do
H.moduleWorkspace "tmp" $ \tempDir -> do
drepVKeyFile <- H.noteTempFile tempDir "drep.vkey"
drepSKeyFile <- H.noteTempFile tempDir "drep.skey"

H.noteShowM_ $ execCardanoCLI
[ "conway", "governance", "drep", "key-gen"
, "--verification-key-file", drepVKeyFile
, "--signing-key-file", drepSKeyFile
]

outFile <- H.noteTempFile tempDir "drep-upd-cert.txt"

H.noteShowM_ $ execCardanoCLI
[ "conway", "governance", "drep", "update-certificate"
, "--drep-verification-key-file", drepVKeyFile
, "--drep-metadata-url", metadataUrl
, "--drep-metadata-hash", "52e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2"
, "--out-file", outFile
]

0 comments on commit e37a31a

Please sign in to comment.