Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for treasury donation. #832

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import Control.Monad (void)

import Test.Cardano.CLI.Util

import Hedgehog (Property)
import Hedgehog
import qualified Hedgehog as H
import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.Golden as H

import Data.List (isInfixOf)
import System.Exit (ExitCode (..))

{- HLINT ignore "Use camelCase" -}

-- | Execute me with:
Expand All @@ -34,3 +38,46 @@ hprop_golden_conway_build_raw_treasury_donation = propertyOnce . H.moduleWorkspa

H.diffFileVsGoldenFile outFile goldenFile

-- Negative test: Missing --current-treasury-value
-- | Execute me with:
-- @cabal test cardano-cli-golden --test-options '-p "/golden conway build raw donation no current treasury value/"'@
hprop_golden_conway_build_raw_donation_no_current_treasury_value :: Property
hprop_golden_conway_build_raw_donation_no_current_treasury_value = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do

-- Key filepaths
outFile <- noteTempFile tempDir "out.json"

(exitCode, _stdout, stderr) <- H.noteShowM $ execDetailCardanoCLI
[ "conway", "transaction", "build-raw"
, "--tx-in", "f62cd7bc15d8c6d2c8519fb8d13c57c0157ab6bab50af62bc63706feb966393d#0"
, "--tx-out", "addr_test1qpmxr8d8jcl25kyz2tz9a9sxv7jxglhddyf475045y8j3zxjcg9vquzkljyfn3rasfwwlkwu7hhm59gzxmsyxf3w9dps8832xh+1199989833223"
, "--tx-out", "addr_test1vpqgspvmh6m2m5pwangvdg499srfzre2dd96qq57nlnw6yctpasy4+10000000"
, "--treasury-donation", "1000343"
, "--fee", "166777"
, "--out-file", outFile
]

exitCode H.=== ExitFailure 1
H.assertWith stderr ("Missing: --current-treasury-value LOVELACE" `isInfixOf`)

-- Negative test: Missing --treasury-donation
-- | Execute me with:
-- @cabal test cardano-cli-golden --test-options '-p "/golden conway build raw donation no treasury donation/"'@
hprop_golden_conway_build_raw_donation_no_treasury_donation :: Property
hprop_golden_conway_build_raw_donation_no_treasury_donation = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do

-- Key filepaths
outFile <- noteTempFile tempDir "out.json"

(exitCode, _stdout, stderr) <- H.noteShowM $ execDetailCardanoCLI
[ "conway", "transaction", "build-raw"
, "--tx-in", "f62cd7bc15d8c6d2c8519fb8d13c57c0157ab6bab50af62bc63706feb966393d#0"
, "--tx-out", "addr_test1qpmxr8d8jcl25kyz2tz9a9sxv7jxglhddyf475045y8j3zxjcg9vquzkljyfn3rasfwwlkwu7hhm59gzxmsyxf3w9dps8832xh+1199989833223"
, "--tx-out", "addr_test1vpqgspvmh6m2m5pwangvdg499srfzre2dd96qq57nlnw6yctpasy4+10000000"
, "--current-treasury-value", "1000343"
, "--fee", "166777"
, "--out-file", outFile
]

exitCode H.=== ExitFailure 1
H.assertWith stderr ("Missing: --treasury-donation LOVELACE" `isInfixOf`)
Loading