Skip to content

Commit

Permalink
Better use of golden/input terms
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Oct 4, 2023
1 parent 931e5b6 commit 5add478
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import qualified Hedgehog.Extras.Test.Golden as H

hprop_golden_governanceAnswerPollNeg1Invalid :: Property
hprop_golden_governanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json"
pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json"
outFile <- H.noteTempFile tempDir "answer-file.json"

result <- tryExecCardanoCLI
Expand All @@ -32,8 +32,8 @@ hprop_golden_governanceAnswerPollNeg1Invalid = propertyOnce . H.moduleWorkspace

hprop_golden_governanceAnswerPoll0 :: Property
hprop_golden_governanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json"
expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.answer.0.json"
pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json"
goldenAnswerFile <- H.note "test/cardano-cli-golden/files/golden/governance/polls/basic.answer.0.json"
outFile <- H.noteTempFile tempDir "answer-file.json"

void $ execCardanoCLI
Expand All @@ -43,12 +43,12 @@ hprop_golden_governanceAnswerPoll0 = propertyOnce . H.moduleWorkspace "governanc
, "--out-file", outFile
]

H.diffFileVsGoldenFile outFile expectedAnswerFile
H.diffFileVsGoldenFile outFile goldenAnswerFile

hprop_golden_governanceAnswerPollPos1 :: Property
hprop_golden_governanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json"
expectedAnswerFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.answer.1.json"
pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json"
goldenAnswerFile <- H.note "test/cardano-cli-golden/files/golden/governance/polls/basic.answer.1.json"
outFile <- H.noteTempFile tempDir "answer-file.json"

void $ execCardanoCLI
Expand All @@ -58,11 +58,11 @@ hprop_golden_governanceAnswerPollPos1 = propertyOnce . H.moduleWorkspace "govern
, "--out-file", outFile
]

H.diffFileVsGoldenFile outFile expectedAnswerFile
H.diffFileVsGoldenFile outFile goldenAnswerFile

hprop_golden_governanceAnswerPollPos2Invalid :: Property
hprop_golden_governanceAnswerPollPos2Invalid = propertyOnce . H.moduleWorkspace "governance-answer-poll" $ \tempDir -> do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json"
pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json"
outFile <- H.noteTempFile tempDir "answer-file.json"

result <- tryExecCardanoCLI
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ hprop_golden_governanceCreatePoll =
]

void $ H.readFile pollFile
noteInputFile "test/cardano-cli-golden/files/golden/governance/create/basic.json"
noteInputFile "test/cardano-cli-golden/files/input/governance/create/basic.json"
>>= H.readFile
>>= (H.===) stdout
H.assertFileOccurences 1 "GovernancePoll" pollFile
Expand All @@ -47,7 +47,7 @@ hprop_golden_governanceCreateLongPoll =
]

void $ H.readFile pollFile
noteInputFile "test/cardano-cli-golden/files/golden/governance/create/long-text.json"
noteInputFile "test/cardano-cli-golden/files/input/governance/create/long-text.json"
>>= H.readFile
>>= (H.===) stdout
H.assertFileOccurences 1 "GovernancePoll" pollFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@ import Test.Cardano.CLI.Util
import Hedgehog (Property)
import qualified Hedgehog as H
import qualified Hedgehog.Internal.Property as H
import qualified Hedgehog.Extras as H

{- HLINT ignore "Use camelCase" -}

hprop_golden_governanceVerifyPoll :: Property
hprop_golden_governanceVerifyPoll = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/valid"
vkFile <- VerificationKeyFilePath . File <$>
noteInputFile "test/cardano-cli-golden/files/golden/governance/cold.vk"
pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/valid"
goldenVkFile <- VerificationKeyFilePath . File <$>
H.note "test/cardano-cli-golden/files/golden/governance/cold.vk"

stdout <- BSC.pack <$> execCardanoCLI
[ "babbage", "governance", "verify-poll"
, "--poll-file", pollFile
, "--tx-file", txFile
]

liftIO (readVerificationKeyOrTextEnvFile AsStakePoolKey vkFile) >>= \case
liftIO (readVerificationKeyOrTextEnvFile AsStakePoolKey goldenVkFile) >>= \case
Left e ->
H.failWith Nothing (displayError e)
Right vk -> do
Expand All @@ -41,8 +42,8 @@ hprop_golden_governanceVerifyPoll = propertyOnce $ do

hprop_golden_governanceVerifyPollMismatch :: Property
hprop_golden_governanceVerifyPollMismatch = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/mismatch"
pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/mismatch"

result <- tryExecCardanoCLI
[ "babbage", "governance", "verify-poll"
Expand All @@ -54,8 +55,8 @@ hprop_golden_governanceVerifyPollMismatch = propertyOnce $ do

hprop_golden_governanceVerifyPollNoAnswer :: Property
hprop_golden_governanceVerifyPollNoAnswer = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/none"
pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/none"

result <- tryExecCardanoCLI
[ "babbage", "governance", "verify-poll"
Expand All @@ -67,8 +68,8 @@ hprop_golden_governanceVerifyPollNoAnswer = propertyOnce $ do

hprop_golden_governanceVerifyPollMalformedAnswer :: Property
hprop_golden_governanceVerifyPollMalformedAnswer = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/malformed"
pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/malformed"

result <- tryExecCardanoCLI
[ "babbage", "governance", "verify-poll"
Expand All @@ -80,8 +81,8 @@ hprop_golden_governanceVerifyPollMalformedAnswer = propertyOnce $ do

hprop_golden_governanceVerifyPollInvalidAnswer :: Property
hprop_golden_governanceVerifyPollInvalidAnswer = propertyOnce $ do
pollFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/golden/governance/verify/invalid"
pollFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/polls/basic.json"
txFile <- noteInputFile "test/cardano-cli-golden/files/input/governance/verify/invalid"

result <- tryExecCardanoCLI
[ "babbage", "governance", "verify-poll"
Expand Down

0 comments on commit 5add478

Please sign in to comment.