-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #459 from input-output-hk/smelc/governance-hash-wr…
…ite-to-file conway governance hash: add option to write hash to file (--out-file)
- Loading branch information
Showing
9 changed files
with
73 additions
and
13 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
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
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
42 changes: 42 additions & 0 deletions
42
cardano-cli/test/cardano-cli-test/Test/Cli/Governance/Hash.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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{- HLINT ignore "Use camelCase" -} | ||
|
||
module Test.Cli.Governance.Hash where | ||
|
||
import Control.Monad (void) | ||
|
||
import Test.Cardano.CLI.Util | ||
|
||
import Hedgehog (Property) | ||
import qualified Hedgehog as H | ||
import qualified Hedgehog.Extras as H | ||
|
||
hprop_governance_hash_trip :: Property | ||
hprop_governance_hash_trip = | ||
propertyOnce $ do | ||
governance_hash_trip_fun "foo" | ||
governance_hash_trip_fun "longerText" | ||
governance_hash_trip_fun "nonAscii: 你好" | ||
governance_hash_trip_fun "nonAscii: à la mode de Cæn" | ||
|
||
-- Test that @cardano-cli conway governance hash --text > file1@ and | ||
-- @cardano-cli conway governance hash --text --out-file file2@ yields | ||
-- similar @file1@ and @file2@ files. | ||
governance_hash_trip_fun :: String -> H.PropertyT IO () | ||
governance_hash_trip_fun input = | ||
H.moduleWorkspace "tmp" $ \tempDir -> do | ||
hashFile <- noteTempFile tempDir "hash.txt" | ||
|
||
hash <- execCardanoCLI | ||
[ "conway", "governance", "hash" | ||
, "--text", input | ||
] | ||
|
||
void $ execCardanoCLI | ||
[ "conway", "governance", "hash" | ||
, "--text", input | ||
, "--out-file", hashFile | ||
] | ||
|
||
hashFromFile <- H.readFile hashFile | ||
|
||
H.diff hash (==) hashFromFile |