-
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.
create-testnet-data: add a golden test
- Loading branch information
Showing
3 changed files
with
104 additions
and
0 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
54 changes: 54 additions & 0 deletions
54
cardano-cli/test/cardano-cli-golden/Test/Golden/CreateTestnetData.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,54 @@ | ||
module Test.Golden.CreateTestnetData where | ||
|
||
import Control.Monad (filterM, void) | ||
import Control.Monad.IO.Class | ||
import Data.List (intercalate, sort) | ||
import System.Directory | ||
import System.FilePath | ||
|
||
import Test.Cardano.CLI.Util (execCardanoCLI) | ||
|
||
import Hedgehog (Property) | ||
import Hedgehog.Extras (moduleWorkspace, propertyOnce) | ||
import qualified Hedgehog.Extras as H | ||
import qualified Hedgehog.Extras.Test.Golden as H | ||
|
||
{- HLINT ignore "Use camelCase" -} | ||
|
||
-- | Given a root directory, returns files within this root (recursively) | ||
tree :: FilePath -> IO [FilePath] | ||
tree root = do | ||
-- listDirectory returns a path relative to 'root'. We need to prepend | ||
-- root to it for queries below. | ||
content <- map (root </>) <$> listDirectory root | ||
files <- filterM doesFileExist content | ||
subs <- filterM doesDirectoryExist content | ||
subTrees <- mapM tree subs | ||
return $ files ++ concat subTrees | ||
|
||
hprop_golden_create_testnet_data :: Property | ||
hprop_golden_create_testnet_data = | ||
propertyOnce $ moduleWorkspace "tmp" $ \tempDir -> do | ||
|
||
let outputDir = tempDir </> "out" | ||
|
||
void $ | ||
execCardanoCLI | ||
["conway", "genesis", "create-testnet-data" | ||
, "--genesis-keys", "2" | ||
, "--utxo-keys", "3" | ||
, "--out-dir", outputDir | ||
, "--testnet-magic", "42" | ||
, "--pools", "2" | ||
] | ||
|
||
generated <- liftIO $ tree outputDir | ||
-- Sort output for stability, and make relative to avoid storing | ||
-- a path that changes everytime (/tmp/nix-shell.[0-9]+/tmp-Test...) | ||
let generated' = intercalate "\n" $ sort $ map (makeRelative outputDir) generated | ||
-- On Windows, the path separator is backslash. Normalize it to slash, like on Unix | ||
-- so that this test can run on all platforms. | ||
generated'' = map (\c -> if c == '\\' then '/' else c) generated' | ||
void $ H.note generated'' | ||
|
||
H.diffVsGoldenFile generated'' "test/cardano-cli-golden/files/golden/conway/create-testnet-data.out" |
48 changes: 48 additions & 0 deletions
48
cardano-cli/test/cardano-cli-golden/files/golden/conway/create-testnet-data.out
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,48 @@ | ||
delegate-keys/delegate1/kes.skey | ||
delegate-keys/delegate1/kes.vkey | ||
delegate-keys/delegate1/key.skey | ||
delegate-keys/delegate1/key.vkey | ||
delegate-keys/delegate1/opcert.cert | ||
delegate-keys/delegate1/opcert.counter | ||
delegate-keys/delegate1/vrf.skey | ||
delegate-keys/delegate1/vrf.vkey | ||
delegate-keys/delegate2/kes.skey | ||
delegate-keys/delegate2/kes.vkey | ||
delegate-keys/delegate2/key.skey | ||
delegate-keys/delegate2/key.vkey | ||
delegate-keys/delegate2/opcert.cert | ||
delegate-keys/delegate2/opcert.counter | ||
delegate-keys/delegate2/vrf.skey | ||
delegate-keys/delegate2/vrf.vkey | ||
genesis-keys/genesis1/key.skey | ||
genesis-keys/genesis1/key.vkey | ||
genesis-keys/genesis2/key.skey | ||
genesis-keys/genesis2/key.vkey | ||
genesis-shelley.json | ||
genesis.json | ||
pools-keys/pool1/cold.skey | ||
pools-keys/pool1/cold.vkey | ||
pools-keys/pool1/kes.skey | ||
pools-keys/pool1/kes.vkey | ||
pools-keys/pool1/opcert.cert | ||
pools-keys/pool1/opcert.counter | ||
pools-keys/pool1/staking-reward.skey | ||
pools-keys/pool1/staking-reward.vkey | ||
pools-keys/pool1/vrf.skey | ||
pools-keys/pool1/vrf.vkey | ||
pools-keys/pool2/cold.skey | ||
pools-keys/pool2/cold.vkey | ||
pools-keys/pool2/kes.skey | ||
pools-keys/pool2/kes.vkey | ||
pools-keys/pool2/opcert.cert | ||
pools-keys/pool2/opcert.counter | ||
pools-keys/pool2/staking-reward.skey | ||
pools-keys/pool2/staking-reward.vkey | ||
pools-keys/pool2/vrf.skey | ||
pools-keys/pool2/vrf.vkey | ||
utxo-keys/utxo1/utxo.skey | ||
utxo-keys/utxo1/utxo.vkey | ||
utxo-keys/utxo2/utxo.skey | ||
utxo-keys/utxo2/utxo.vkey | ||
utxo-keys/utxo3/utxo.skey | ||
utxo-keys/utxo3/utxo.vkey |