Skip to content

Commit

Permalink
Adapt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc authored and newhoggy committed Oct 4, 2023
1 parent 33616d4 commit 55f92db
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 84 deletions.
8 changes: 4 additions & 4 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,10 @@ test-suite cardano-cli-golden
build-tool-depends: cardano-cli:cardano-cli
, tasty-discover:tasty-discover

other-modules: Test.Golden.Byron.SigningKeys
other-modules: Test.Golden.Babbage.Governance.AnswerPoll
Test.Golden.Babbage.Governance.CreatePoll
Test.Golden.Babbage.Governance.VerifyPoll
Test.Golden.Byron.SigningKeys
Test.Golden.Byron.Tx
Test.Golden.Byron.TxBody
Test.Golden.Byron.UpdateProposal
Expand All @@ -379,9 +382,6 @@ test-suite cardano-cli-golden
Test.Golden.Shelley.Genesis.KeyGenGenesis
Test.Golden.Shelley.Genesis.KeyGenUtxo
Test.Golden.Shelley.Genesis.KeyHash
Test.Golden.Shelley.Governance.AnswerPoll
Test.Golden.Shelley.Governance.CreatePoll
Test.Golden.Shelley.Governance.VerifyPoll
Test.Golden.Shelley.Key.ConvertCardanoAddressKey
Test.Golden.Shelley.Metadata.StakePoolMetadata
Test.Golden.Shelley.MultiSig.Address
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}

module Test.Golden.Shelley.Governance.AnswerPoll where
module Test.Golden.Babbage.Governance.AnswerPoll where

import Control.Monad (void)

Expand All @@ -14,13 +14,13 @@ import qualified Hedgehog.Extras.Test.Golden as H

{- HLINT ignore "Use camelCase" -}

hprop_golden_shelleyGovernanceAnswerPollNeg1Invalid :: Property
hprop_golden_shelleyGovernanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json"
hprop_golden_babbageGovernanceAnswerPollNeg1Invalid :: Property
hprop_golden_babbageGovernanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json"
outFile <- H.noteTempFile tempDir "answer-file.json"

result <- tryExecCardanoCLI
[ "legacy", "governance", "answer-poll"
[ "babbage", "governance", "answer-poll"
, "--poll-file", pollFile
, "--answer", "-1"
, "--out-file", outFile
Expand All @@ -30,43 +30,43 @@ hprop_golden_shelleyGovernanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWor

either (const H.success) (const H.failure) result

hprop_golden_shelleyGovernanceAnswerPoll0 :: Property
hprop_golden_shelleyGovernanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json"
expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.0.json"
hprop_golden_babbageGovernanceAnswerPoll0 :: Property
hprop_golden_babbageGovernanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json"
expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.0.json"
outFile <- H.noteTempFile tempDir "answer-file.json"

void $ execCardanoCLI
[ "legacy", "governance", "answer-poll"
[ "babbage", "governance", "answer-poll"
, "--poll-file", pollFile
, "--answer", "0"
, "--out-file", outFile
]

H.diffFileVsGoldenFile outFile expectedAnswerFile

hprop_golden_shelleyGovernanceAnswerPollPos1 :: Property
hprop_golden_shelleyGovernanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json"
expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.answer.1.json"
hprop_golden_babbageGovernanceAnswerPollPos1 :: Property
hprop_golden_babbageGovernanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json"
expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.answer.1.json"
outFile <- H.noteTempFile tempDir "answer-file.json"

void $ execCardanoCLI
[ "legacy", "governance", "answer-poll"
[ "babbage", "governance", "answer-poll"
, "--poll-file", pollFile
, "--answer", "1"
, "--out-file", outFile
]

H.diffFileVsGoldenFile outFile expectedAnswerFile

hprop_golden_shelleyGovernanceAnswerPollPos2Invalid :: Property
hprop_golden_shelleyGovernanceAnswerPollPos2Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json"
hprop_golden_babbageGovernanceAnswerPollPos2Invalid :: Property
hprop_golden_babbageGovernanceAnswerPollPos2Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json"
outFile <- H.noteTempFile tempDir "answer-file.json"

result <- tryExecCardanoCLI
[ "legacy", "governance", "answer-poll"
[ "babbage", "governance", "answer-poll"
, "--poll-file", pollFile
, "--answer", "2"
, "--out-file", outFile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-}

module Test.Golden.Shelley.Governance.CreatePoll where
module Test.Golden.Babbage.Governance.CreatePoll where

import Control.Monad (void)

Expand All @@ -13,41 +13,41 @@ import qualified Hedgehog.Extras.Test.File as H

{- HLINT ignore "Use camelCase" -}

hprop_golden_shelleyGovernanceCreatePoll :: Property
hprop_golden_shelleyGovernanceCreatePoll =
hprop_golden_babbageGovernanceCreatePoll :: Property
hprop_golden_babbageGovernanceCreatePoll =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
pollFile <- noteTempFile tempDir "poll.json"

stdout <- execCardanoCLI
[ "legacy", "governance", "create-poll"
[ "babbage", "governance", "create-poll"
, "--question", "Pineapples on pizza?"
, "--answer", "yes"
, "--answer", "no"
, "--out-file", pollFile
]

void $ H.readFile pollFile
noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/create/basic.json"
noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/create/basic.json"
>>= H.readFile
>>= (H.===) stdout
H.assertFileOccurences 1 "GovernancePoll" pollFile
H.assertEndsWithSingleNewline pollFile

hprop_golden_shelleyGovernanceCreateLongPoll :: Property
hprop_golden_shelleyGovernanceCreateLongPoll =
hprop_golden_babbageGovernanceCreateLongPoll :: Property
hprop_golden_babbageGovernanceCreateLongPoll =
propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do
pollFile <- noteTempFile tempDir "poll.json"

stdout <- execCardanoCLI
[ "legacy", "governance", "create-poll"
[ "babbage", "governance", "create-poll"
, "--question", "What is the most adequate topping to put on a pizza (please consider all possibilities and take time to answer)?"
, "--answer", "pineapples"
, "--answer", "only traditional topics should go on a pizza, this isn't room for jokes"
, "--out-file", pollFile
]

void $ H.readFile pollFile
noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/create/long-text.json"
noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/create/long-text.json"
>>= H.readFile
>>= (H.===) stdout
H.assertFileOccurences 1 "GovernancePoll" pollFile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}

module Test.Golden.Shelley.Governance.VerifyPoll where
module Test.Golden.Babbage.Governance.VerifyPoll where

import Cardano.Api

Expand All @@ -19,15 +19,15 @@ import qualified Hedgehog.Internal.Property as H

{- HLINT ignore "Use camelCase" -}

hprop_golden_shelleyGovernanceVerifyPoll :: Property
hprop_golden_shelleyGovernanceVerifyPoll = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/valid"
hprop_golden_babbageGovernanceVerifyPoll :: Property
hprop_golden_babbageGovernanceVerifyPoll = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/valid"
vkFile <- VerificationKeyFilePath . File <$>
noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/cold.vk"
noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/cold.vk"

stdout <- BSC.pack <$> execCardanoCLI
[ "legacy", "governance", "verify-poll"
[ "babbage", "governance", "verify-poll"
, "--poll-file", pollFile
, "--tx-file", txFile
]
Expand All @@ -39,52 +39,52 @@ hprop_golden_shelleyGovernanceVerifyPoll = propertyOnce $ do
let expected = prettyPrintJSON $ serialiseToRawBytesHexText <$> [verificationKeyHash vk]
H.assert $ expected `BSC.isInfixOf` stdout

hprop_golden_shelleyGovernanceVerifyPollMismatch :: Property
hprop_golden_shelleyGovernanceVerifyPollMismatch = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/mismatch"
hprop_golden_babbageGovernanceVerifyPollMismatch :: Property
hprop_golden_babbageGovernanceVerifyPollMismatch = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/mismatch"

result <- tryExecCardanoCLI
[ "legacy", "governance", "verify-poll"
[ "babbage", "governance", "verify-poll"
, "--poll-file", pollFile
, "--tx-file", txFile
]

either (const H.success) (H.failWith Nothing) result

hprop_golden_shelleyGovernanceVerifyPollNoAnswer :: Property
hprop_golden_shelleyGovernanceVerifyPollNoAnswer = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/none"
hprop_golden_babbageGovernanceVerifyPollNoAnswer :: Property
hprop_golden_babbageGovernanceVerifyPollNoAnswer = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/none"

result <- tryExecCardanoCLI
[ "legacy", "governance", "verify-poll"
[ "babbage", "governance", "verify-poll"
, "--poll-file", pollFile
, "--tx-file", txFile
]

either (const H.success) (H.failWith Nothing) result

hprop_golden_shelleyGovernanceVerifyPollMalformedAnswer :: Property
hprop_golden_shelleyGovernanceVerifyPollMalformedAnswer = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/malformed"
hprop_golden_babbageGovernanceVerifyPollMalformedAnswer :: Property
hprop_golden_babbageGovernanceVerifyPollMalformedAnswer = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/malformed"

result <- tryExecCardanoCLI
[ "legacy", "governance", "verify-poll"
[ "babbage", "governance", "verify-poll"
, "--poll-file", pollFile
, "--tx-file", txFile
]

either (const H.success) (H.failWith Nothing) result

hprop_golden_shelleyGovernanceVerifyPollInvalidAnswer :: Property
hprop_golden_shelleyGovernanceVerifyPollInvalidAnswer = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/shelley/governance/verify/invalid"
hprop_golden_babbageGovernanceVerifyPollInvalidAnswer :: Property
hprop_golden_babbageGovernanceVerifyPollInvalidAnswer = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/babbage/governance/verify/invalid"

result <- tryExecCardanoCLI
[ "legacy", "governance", "verify-poll"
[ "babbage", "governance", "verify-poll"
, "--poll-file", pollFile
, "--tx-file", txFile
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Usage: cardano-cli governance answer-poll --poll-file FILE
[--answer INT]
[--out-file FILE]
Usage: cardano-cli babbage governance answer-poll --poll-file FILE
[--answer INT]
[--out-file FILE]

Answer an SPO poll

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Usage: cardano-cli governance create-poll --question STRING
(--answer STRING)
[--nonce UINT]
--out-file FILE
Usage: cardano-cli babbage governance create-poll --question STRING
(--answer STRING)
[--nonce UINT]
--out-file FILE

Create an SPO poll

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Usage: cardano-cli governance verify-poll --poll-file FILE
--tx-file FILE
[--out-file FILE]
Usage: cardano-cli babbage governance verify-poll --poll-file FILE
--tx-file FILE
[--out-file FILE]

Verify an answer to a given SPO poll

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ Usage: cardano-cli governance
( create-mir-certificate
| create-genesis-key-delegation-certificate
| create-update-proposal
| create-poll
| answer-poll
| verify-poll
)

Governance commands
Expand All @@ -18,6 +15,3 @@ Available commands:
create-genesis-key-delegation-certificate
Create a genesis key delegation certificate
create-update-proposal Create an update proposal
create-poll Create an SPO poll
answer-poll Answer an SPO poll
verify-poll Verify an answer to a given SPO poll
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: cardano-cli legacy governance answer-poll --poll-file FILE
Usage: cardano-cli latest governance answer-poll --poll-file FILE
[--answer INT]
[--out-file FILE]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: cardano-cli legacy governance create-poll --question STRING
Usage: cardano-cli latest governance create-poll --question STRING
(--answer STRING)
[--nonce UINT]
--out-file FILE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Usage: cardano-cli legacy governance verify-poll --poll-file FILE
Usage: cardano-cli latest governance verify-poll --poll-file FILE
--tx-file FILE
[--out-file FILE]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ Usage: cardano-cli legacy governance
( create-mir-certificate
| create-genesis-key-delegation-certificate
| create-update-proposal
| create-poll
| answer-poll
| verify-poll
)

Governance commands
Expand All @@ -18,6 +15,3 @@ Available commands:
create-genesis-key-delegation-certificate
Create a genesis key delegation certificate
create-update-proposal Create an update proposal
create-poll Create an SPO poll
answer-poll Answer an SPO poll
verify-poll Verify an answer to a given SPO poll

0 comments on commit 55f92db

Please sign in to comment.