From d04aa5a37f71c58dd55d2ad4685e04a8a78382b7 Mon Sep 17 00:00:00 2001 From: Carlos LopezDeLara Date: Tue, 9 Jul 2024 01:23:07 -0600 Subject: [PATCH] Add tests for missing flags on treasury donation with build raw. --- .../Golden/Conway/Transaction/BuildRaw.hs | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/cardano-cli/test/cardano-cli-golden/Test/Golden/Conway/Transaction/BuildRaw.hs b/cardano-cli/test/cardano-cli-golden/Test/Golden/Conway/Transaction/BuildRaw.hs index 9d7e60ea19..f1c6e80bf9 100644 --- a/cardano-cli/test/cardano-cli-golden/Test/Golden/Conway/Transaction/BuildRaw.hs +++ b/cardano-cli/test/cardano-cli-golden/Test/Golden/Conway/Transaction/BuildRaw.hs @@ -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: @@ -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`)