-
Notifications
You must be signed in to change notification settings - Fork 723
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1378: Add golden test for stake pool metadata hash command r=intricate a=intricate Co-authored-by: Luke Nadur <19835357+intricate@users.noreply.github.com>
- Loading branch information
Showing
7 changed files
with
73 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
|
||
module Test.Metadata | ||
( tests | ||
) where | ||
|
||
import Cardano.Prelude | ||
|
||
import Hedgehog (Property, (===)) | ||
import qualified Hedgehog as H | ||
|
||
import Test.OptParse | ||
|
||
golden_stakePoolMetadataHash :: Property | ||
golden_stakePoolMetadataHash = | ||
propertyOnce $ do | ||
let stakePoolMetadataFp = "stake-pool-metadata.json" | ||
outputStakePoolMetadataHashFp = "stake-pool-metadata-hash.txt" | ||
allFiles = [stakePoolMetadataFp, outputStakePoolMetadataHashFp] | ||
|
||
-- Write the example stake pool metadata to disk | ||
liftIO $ writeFile stakePoolMetadataFp exampleStakePoolMetadata | ||
assertFilesExist [stakePoolMetadataFp] | ||
|
||
-- Hash the stake pool metadata | ||
execCardanoCLIParser | ||
allFiles | ||
$ evalCardanoCLIParser [ "shelley","stake-pool","metadata-hash" | ||
, "--pool-metadata-file", stakePoolMetadataFp | ||
, "--out-file", outputStakePoolMetadataHashFp | ||
] | ||
|
||
-- Check for existence of the stake pool metadata hash file. | ||
assertFilesExist [outputStakePoolMetadataHashFp] | ||
|
||
-- Check that the stake pool metadata hash file content is correct. | ||
expectedStakePoolMetadataHash <- liftIO $ | ||
readFile "test/Test/golden/shelley/stake_pool_metadata/stake_pool_metadata_hash" | ||
actualStakePoolMetadataHash <- liftIO $ readFile outputStakePoolMetadataHashFp | ||
expectedStakePoolMetadataHash === actualStakePoolMetadataHash | ||
|
||
liftIO $ fileCleanup allFiles | ||
|
||
H.success | ||
where | ||
exampleStakePoolMetadata :: Text | ||
exampleStakePoolMetadata = "{\"homepage\":\"https://iohk.io\",\"name\":\"Genesis Pool C\",\"ticker\":\"GPC\",\"description\":\"Lorem Ipsum Dolor Sit Amet.\"}" | ||
|
||
tests :: IO Bool | ||
tests = | ||
H.checkSequential | ||
$ H.Group "Stake pool metadata" | ||
[ ("golden_stakePoolMetadataHash", golden_stakePoolMetadataHash) | ||
] |
1 change: 1 addition & 0 deletions
1
cardano-cli/test/Test/golden/shelley/stake_pool_metadata/stake_pool_metadata_hash
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 @@ | ||
8241de08075886a7d09c847c9bbd1719459dac0bd0a2f085e673611ebb9a5965 |
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