forked from IntersectMBO/cardano-node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework integration tests for governance commands
- [x] Cover new error cases for 'verify' - [x] Create full-blown test transactions for 'verify' - [x] Slightly re-organised and re-structure data folder - [x] Remove now-unnecessary old files ``` ❯ tree cardano-cli/test/data/golden/shelley/governance . ├── answer │ └── basic.json ├── cold.sk ├── cold.vk ├── create │ ├── basic.json │ └── long-text.json ├── polls │ ├── basic.json │ └── long-text.json └── verify ├── invalid ├── malformed ├── mismatch ├── none └── valid ```
- Loading branch information
Showing
20 changed files
with
131 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 62 additions & 29 deletions
91
cardano-cli/test/Test/Golden/Shelley/Governance/VerifyPoll.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,98 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Test.Golden.Shelley.Governance.VerifyPoll | ||
( golden_shelleyGovernanceVerifyPollVrf | ||
, golden_shelleyGovernanceVerifyPollVrfTempered | ||
, golden_shelleyGovernanceVerifyPollCold | ||
, golden_shelleyGovernanceVerifyPollColdTempered | ||
( golden_shelleyGovernanceVerifyPoll | ||
, golden_shelleyGovernanceVerifyPollMismatch | ||
, golden_shelleyGovernanceVerifyPollNoAnswer | ||
, golden_shelleyGovernanceVerifyPollMalformedAnswer | ||
, golden_shelleyGovernanceVerifyPollInvalidAnswer | ||
) where | ||
|
||
import Cardano.Prelude | ||
import Cardano.Prelude hiding (stdout) | ||
|
||
import Hedgehog (Property) | ||
import Test.OptParse | ||
|
||
import Cardano.Api | ||
import Cardano.CLI.Types (VerificationKeyFile (..)) | ||
import Cardano.CLI.Shelley.Key (VerificationKeyOrFile (..), | ||
readVerificationKeyOrTextEnvFile) | ||
|
||
import qualified Hedgehog as H | ||
import qualified Hedgehog.Internal.Property as H | ||
import qualified Data.ByteString.Char8 as BSC | ||
|
||
{- HLINT ignore "Use camelCase" -} | ||
|
||
golden_shelleyGovernanceVerifyPollVrf :: Property | ||
golden_shelleyGovernanceVerifyPollVrf = propertyOnce $ do | ||
pollFile <- noteInputFile "test/data/golden/shelley/governance/poll.json" | ||
metadataFile <- noteInputFile "test/data/golden/shelley/governance/answer-vrf.json" | ||
golden_shelleyGovernanceVerifyPoll :: Property | ||
golden_shelleyGovernanceVerifyPoll = propertyOnce $ do | ||
pollFile <- noteInputFile "test/data/golden/shelley/governance/polls/basic.json" | ||
txFile <- noteInputFile "test/data/golden/shelley/governance/verify/valid" | ||
vkFile <- VerificationKeyFilePath . VerificationKeyFile <$> | ||
noteInputFile "test/data/golden/shelley/governance/cold.vk" | ||
|
||
void $ execCardanoCLI | ||
stdout <- BSC.pack <$> execCardanoCLI | ||
[ "governance", "verify-poll" | ||
, "--poll-file", pollFile | ||
, "--metadata-file", metadataFile | ||
, "--signed-tx-file", txFile | ||
] | ||
|
||
golden_shelleyGovernanceVerifyPollCold :: Property | ||
golden_shelleyGovernanceVerifyPollCold = propertyOnce $ do | ||
pollFile <- noteInputFile "test/data/golden/shelley/governance/poll.json" | ||
metadataFile <- noteInputFile "test/data/golden/shelley/governance/answer-cold.json" | ||
liftIO (readVerificationKeyOrTextEnvFile AsStakePoolKey vkFile) >>= \case | ||
Left e -> | ||
H.failWith Nothing (displayError e) | ||
Right vk -> do | ||
let expected = prettyPrintJSON $ serialiseToRawBytesHexText <$> [verificationKeyHash vk] | ||
H.assert $ expected `BSC.isInfixOf` stdout | ||
|
||
golden_shelleyGovernanceVerifyPollMismatch :: Property | ||
golden_shelleyGovernanceVerifyPollMismatch = propertyOnce $ do | ||
pollFile <- noteInputFile "test/data/golden/shelley/governance/polls/basic.json" | ||
txFile <- noteInputFile "test/data/golden/shelley/governance/verify/mismatch" | ||
|
||
void $ execCardanoCLI | ||
result <- tryExecCardanoCLI | ||
[ "governance", "verify-poll" | ||
, "--poll-file", pollFile | ||
, "--metadata-file", metadataFile | ||
, "--signed-tx-file", txFile | ||
] | ||
|
||
golden_shelleyGovernanceVerifyPollVrfTempered :: Property | ||
golden_shelleyGovernanceVerifyPollVrfTempered = propertyOnce $ do | ||
pollFile <- noteInputFile "test/data/golden/shelley/governance/poll.json" | ||
metadataFile <- noteInputFile "test/data/golden/shelley/governance/answer-vrf-tempered.json" | ||
either (const H.success) (H.failWith Nothing) result | ||
|
||
golden_shelleyGovernanceVerifyPollNoAnswer :: Property | ||
golden_shelleyGovernanceVerifyPollNoAnswer = propertyOnce $ do | ||
pollFile <- noteInputFile "test/data/golden/shelley/governance/polls/basic.json" | ||
txFile <- noteInputFile "test/data/golden/shelley/governance/verify/none" | ||
|
||
result <- tryExecCardanoCLI | ||
[ "governance", "verify-poll" | ||
, "--poll-file", pollFile | ||
, "--signed-tx-file", txFile | ||
] | ||
|
||
either (const H.success) (H.failWith Nothing) result | ||
|
||
golden_shelleyGovernanceVerifyPollMalformedAnswer :: Property | ||
golden_shelleyGovernanceVerifyPollMalformedAnswer = propertyOnce $ do | ||
pollFile <- noteInputFile "test/data/golden/shelley/governance/polls/basic.json" | ||
txFile <- noteInputFile "test/data/golden/shelley/governance/verify/malformed" | ||
|
||
result <- tryExecCardanoCLI | ||
[ "governance", "verify-poll" | ||
, "--poll-file", pollFile | ||
, "--metadata-file", metadataFile | ||
, "--signed-tx-file", txFile | ||
] | ||
|
||
either (const H.success) (const H.failure) result | ||
either (const H.success) (H.failWith Nothing) result | ||
|
||
golden_shelleyGovernanceVerifyPollColdTempered :: Property | ||
golden_shelleyGovernanceVerifyPollColdTempered = propertyOnce $ do | ||
pollFile <- noteInputFile "test/data/golden/shelley/governance/poll.json" | ||
metadataFile <- noteInputFile "test/data/golden/shelley/governance/answer-cold-tempered.json" | ||
golden_shelleyGovernanceVerifyPollInvalidAnswer :: Property | ||
golden_shelleyGovernanceVerifyPollInvalidAnswer = propertyOnce $ do | ||
pollFile <- noteInputFile "test/data/golden/shelley/governance/polls/basic.json" | ||
txFile <- noteInputFile "test/data/golden/shelley/governance/verify/invalid" | ||
|
||
result <- tryExecCardanoCLI | ||
[ "governance", "verify-poll" | ||
, "--poll-file", pollFile | ||
, "--metadata-file", metadataFile | ||
, "--signed-tx-file", txFile | ||
] | ||
|
||
either (const H.success) (const H.failure) result | ||
either (const H.success) (H.failWith Nothing) result |
37 changes: 0 additions & 37 deletions
37
cardano-cli/test/data/golden/shelley/governance/answer-cold-tempered.json
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
cardano-cli/test/data/golden/shelley/governance/answer-cold.json
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
cardano-cli/test/data/golden/shelley/governance/answer-vrf-tempered.json
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.