Skip to content

Commit

Permalink
Add governance Info action test
Browse files Browse the repository at this point in the history
  • Loading branch information
carbolymer committed Feb 2, 2024
1 parent 91317d4 commit dfc7f4c
Show file tree
Hide file tree
Showing 5 changed files with 421 additions and 49 deletions.
1 change: 1 addition & 0 deletions cardano-testnet/cardano-testnet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ test-suite cardano-testnet-test
Cardano.Testnet.Test.Misc

Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitution
Cardano.Testnet.Test.LedgerEvents.Gov.InfoAction
Cardano.Testnet.Test.LedgerEvents.SanityCheck

Cardano.Testnet.Test.Node.Shutdown
Expand Down
28 changes: 27 additions & 1 deletion cardano-testnet/src/Testnet/Property/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Testnet.Property.Utils
, QueryTipOutput(..)
, queryTip
, waitUntilEpoch
, queryUtxos

-- ** Parsers
, pMaxLovelaceSupply
Expand All @@ -35,13 +36,17 @@ import qualified Data.Aeson as Aeson
import Data.Aeson.Key
import Data.Aeson.KeyMap
import qualified Data.ByteString as BS
import Data.IORef
import Data.Map.Strict (Map)
import Data.Text (Text)
import qualified Data.Text as Text
import Data.Word
import GHC.Stack
import qualified GHC.Stack as GHC
import Options.Applicative
import System.Directory (doesFileExist, removeFile)
import qualified System.Environment as IO
import System.FilePath ((</>))
import System.Info (os)
import qualified System.IO.Unsafe as IO

Expand All @@ -51,7 +56,7 @@ import qualified Hedgehog.Extras.Test.Concurrent as H
import qualified Hedgehog.Extras.Test.File as H
import Hedgehog.Extras.Test.Process (ExecConfig)
import Hedgehog.Internal.Property (MonadTest)

import Testnet.Components.SPO (decodeEraUTxO)
import qualified Testnet.Process.Run as H

disableRetries :: Bool
Expand Down Expand Up @@ -139,6 +144,27 @@ queryTip (QueryTipOutput fp) execConfig = do
newtype QueryTipOutput = QueryTipOutput { unQueryTipOutput :: FilePath}


queryUtxos
:: (HasCallStack, MonadIO m, MonadTest m, MonadCatch m, IsShelleyBasedEra era)
=> ExecConfig
-> FilePath -- ^ working directory
-> IORef Int -- ^ filename counter, initialize with 1 usually
-> ShelleyBasedEra era
-> Text -- ^ payment address
-> m (Map TxIn (TxOut CtxUTxO era))
queryUtxos execConfig work counter sbe address = withFrozenCallStack $ do
i <- liftIO $ atomicModifyIORef' counter (\i -> (i+1, i))
let utxoFp = work </> "utxo-" <> show i <> ".json"
void $ H.execCli' execConfig
[ "conway", "query", "utxo"
, "--address", Text.unpack address
, "--cardano-mode"
, "--out-file", utxoFp
]

utxoJson <- H.leftFailM . H.readJsonFile $ utxoFp
H.noteShowM . fmap unUTxO $ decodeEraUTxO sbe utxoJson

-- Parsers

pMaxLovelaceSupply :: Parser Word64
Expand Down
Loading

0 comments on commit dfc7f4c

Please sign in to comment.