-
Notifications
You must be signed in to change notification settings - Fork 720
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
128 additions
and
242 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
86 changes: 59 additions & 27 deletions
86
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,64 +1,96 @@ | ||
{-# 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 Control.Monad (void) | ||
import Control.Monad.IO.Class (liftIO) | ||
import Hedgehog (Property) | ||
import Test.OptParse | ||
|
||
import Cardano.Api | ||
import Cardano.CLI.Shelley.Key | ||
(VerificationKeyOrFile (..), | ||
readVerificationKeyOrTextEnvFile) | ||
|
||
import qualified Hedgehog 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 . File <$> | ||
noteInputFile "test/data/golden/shelley/governance/cold.vk" | ||
|
||
void $ execCardanoCLI | ||
stdout <- BSC.pack <$> execCardanoCLI | ||
[ "governance", "verify-poll" | ||
, "--poll-file", pollFile | ||
, "--metadata-file", metadataFile | ||
, "--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{} -> | ||
H.failure | ||
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 | ||
, "--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) (const H.failure) 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 | ||
, "--tx-file", txFile | ||
] | ||
|
||
either (const H.success) (const H.failure) 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 | ||
, "--tx-file", txFile | ||
] | ||
|
||
either (const H.success) (const H.failure) 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 | ||
, "--tx-file", txFile | ||
] | ||
|
||
either (const H.success) (const H.failure) 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.