-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
55 additions
and
42 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
File renamed without changes.
File renamed without changes.
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
43 changes: 43 additions & 0 deletions
43
cardano-cli/test/cardano-cli-test/Test/Cli/Shelley/Run/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,43 @@ | ||
{- HLINT ignore "Use camelCase" -} | ||
{-# LANGUAGE TypeApplications #-} | ||
Check warning Code scanning / HLint Unused LANGUAGE pragma Warning test
cardano-cli/test/cardano-cli-test/Test/Cli/Shelley/Run/Hash.hs:2:1-33: Warning: Unused LANGUAGE pragma
Found: {-# LANGUAGE TypeApplications #-} Perhaps you should remove it. |
||
|
||
module Test.Cli.Shelley.Run.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_hash_trip :: Property | ||
hprop_hash_trip = | ||
propertyOnce $ do | ||
hash_trip_fun "foo" | ||
hash_trip_fun "longerText" | ||
hash_trip_fun "nonAscii: 你好" | ||
hash_trip_fun "nonAscii: à la mode de Cæn" | ||
|
||
-- Test that @cardano-cli hash --text > file1@ and | ||
-- @cardano-cli --text --out-file file2@ yields | ||
-- similar @file1@ and @file2@ files. | ||
hash_trip_fun :: String -> H.PropertyT IO () | ||
hash_trip_fun input = | ||
H.moduleWorkspace "tmp" $ \tempDir -> do | ||
hashFile <- noteTempFile tempDir "hash.txt" | ||
|
||
hash <- execCardanoCLI | ||
[ "hash", "anchor-data" | ||
, "--text", input | ||
] | ||
|
||
void $ execCardanoCLI | ||
[ "hash", "anchor-data" | ||
, "--text", input | ||
, "--out-file", hashFile | ||
] | ||
|
||
hashFromFile <- H.readFile hashFile | ||
|
||
H.diff hash (==) hashFromFile |