Skip to content

Commit

Permalink
Fix issue with paths in Hydra CI
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Sep 23, 2024
1 parent 3378203 commit b1941b9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
cardano-cli/test/cardano-cli-golden/files/input/example_anchor_data.txt -text
cardano-cli/test/cardano-cli-test/files/input/example_anchor_data.txt -text
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Control.Monad.Catch (MonadCatch)
import Control.Monad.Trans.Control (MonadBaseControl)

import Test.Cardano.CLI.Hash (exampleAnchorDataHash, exampleAnchorDataIpfsHash,
exampleAnchorDataPath, serveFileWhile)
exampleAnchorDataPathGolden, serveFileWhile)
import qualified Test.Cardano.CLI.Util as H
import Test.Cardano.CLI.Util (execCardanoCLI, execCardanoCLIWithEnvVars, expectFailure,
noteInputFile, noteTempFile, propertyOnce)
Expand Down Expand Up @@ -216,7 +216,7 @@ base_golden_conway_governance_action_view_create_info_json_outfile hash tempDir
let relativeUrl = ["ipfs", exampleAnchorDataIpfsHash]
serveFileWhile
relativeUrl
exampleAnchorDataPath
exampleAnchorDataPathGolden
( \port -> do
void $
execCardanoCLIWithEnvVars
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This is just a random file with content that is used for
testing the hashing of anchor data files.
16 changes: 13 additions & 3 deletions cardano-cli/test/cardano-cli-test-lib/Test/Cardano/CLI/Hash.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{-# LANGUAGE FlexibleContexts #-}

module Test.Cardano.CLI.Hash (exampleAnchorDataHash, serveFileWhile, exampleAnchorDataPath, exampleAnchorDataIpfsHash) where
module Test.Cardano.CLI.Hash
( exampleAnchorDataHash
, serveFileWhile
, exampleAnchorDataPathTest
, exampleAnchorDataPathGolden
, exampleAnchorDataIpfsHash
)
where

import Cardano.Api (MonadIO)

Expand All @@ -26,8 +33,11 @@ import Hedgehog.Internal.Source (HasCallStack)
exampleAnchorDataHash :: String
exampleAnchorDataHash = "de38a4f5b8b9d8372386cc923bad19d1a0662298cf355bbe947e5eedf127fa9c"

exampleAnchorDataPath :: String
exampleAnchorDataPath = "test/cardano-cli-test/files/input/example_anchor_data.txt"
exampleAnchorDataPathGolden :: String
exampleAnchorDataPathGolden = "test/cardano-cli-golden/files/input/example_anchor_data.txt"

exampleAnchorDataPathTest :: String
exampleAnchorDataPathTest = "test/cardano-cli-test/files/input/example_anchor_data.txt"

exampleAnchorDataIpfsHash :: String
exampleAnchorDataIpfsHash = "QmbL5EBFJLf8DdPkWAskG3Euin9tHY8naqQ2JDoHnWHHXJ"
Expand Down
14 changes: 7 additions & 7 deletions cardano-cli/test/cardano-cli-test/Test/Cli/Hash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import System.FilePath (dropTrailingPathSeparator)
import System.FilePath.Posix (splitDirectories)

import Test.Cardano.CLI.Hash (exampleAnchorDataHash, exampleAnchorDataIpfsHash,
exampleAnchorDataPath, serveFileWhile)
exampleAnchorDataPathTest, serveFileWhile)
import Test.Cardano.CLI.Util

import Hedgehog as H
Expand All @@ -26,7 +26,7 @@ hprop_generate_anchor_data_hash_from_file =
[ "hash"
, "anchor-data"
, "--file-binary"
, exampleAnchorDataPath
, exampleAnchorDataPathTest
]
result === exampleAnchorDataHash

Expand All @@ -40,7 +40,7 @@ hprop_check_anchor_data_hash_from_file =
[ "hash"
, "anchor-data"
, "--file-binary"
, exampleAnchorDataPath
, exampleAnchorDataPathTest
, "--expected-hash"
, exampleAnchorDataHash
]
Expand All @@ -55,7 +55,7 @@ hprop_check_anchor_data_hash_from_file_fails =
[ "hash"
, "anchor-data"
, "--file-binary"
, exampleAnchorDataPath
, exampleAnchorDataPathTest
, "--expected-hash"
, 'c' : drop 1 exampleAnchorDataHash
]
Expand All @@ -73,7 +73,7 @@ hprop_generate_anchor_data_hash_from_file_uri =
[ "hash"
, "anchor-data"
, "--url"
, "file://" ++ posixCwd ++ "/" ++ exampleAnchorDataPath
, "file://" ++ posixCwd ++ "/" ++ exampleAnchorDataPathTest
]
result === exampleAnchorDataHash
where
Expand All @@ -100,7 +100,7 @@ hprop_check_anchor_data_hash_from_http_uri =
let relativeUrl = ["example", "url", "file.txt"]
serveFileWhile
relativeUrl
exampleAnchorDataPath
exampleAnchorDataPathTest
( \port -> do
void $
execCardanoCLI
Expand All @@ -121,7 +121,7 @@ hprop_check_anchor_data_hash_from_ipfs_uri =
let relativeUrl = ["ipfs", exampleAnchorDataIpfsHash]
serveFileWhile
relativeUrl
exampleAnchorDataPath
exampleAnchorDataPathTest
( \port -> do
void $
execCardanoCLIWithEnvVars
Expand Down

0 comments on commit b1941b9

Please sign in to comment.