Skip to content

Commit

Permalink
Replace foldBlocks test with foldEpochState test
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Apr 28, 2024
1 parent d1f30b5 commit fcc35c1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cardano-testnet/cardano-testnet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ test-suite cardano-testnet-test
Cardano.Testnet.Test.Cli.KesPeriodInfo
Cardano.Testnet.Test.Cli.Queries
Cardano.Testnet.Test.Cli.QuerySlotNumber
Cardano.Testnet.Test.FoldBlocks
Cardano.Testnet.Test.FoldEpochState
Cardano.Testnet.Test.Misc

Cardano.Testnet.Test.LedgerEvents.Gov.DRepDeposits
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}

module Cardano.Testnet.Test.FoldEpochState where

import Cardano.Api hiding (cardanoEra)
import qualified Cardano.Api as Api

import Cardano.Testnet as TN

import Prelude

import Control.Concurrent.Async ()
import Control.Monad.Trans.State.Strict
import qualified System.Directory as IO
import System.FilePath ((</>))

import qualified Testnet.Property.Utils as H
import Testnet.Runtime

import Hedgehog ((===))
import qualified Hedgehog as H
import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as H
import qualified Hedgehog.Extras.Test as H

prop_foldEpochState :: H.Property
prop_foldEpochState = H.integrationWorkspace "foldEpochState" $ \tempAbsBasePath' -> do
conf <- TN.mkConf tempAbsBasePath'

let tempAbsPath' = unTmpAbsPath $ tempAbsPath conf
era = BabbageEra
options = cardanoDefaultTestnetOptions
{ cardanoNodeEra = AnyCardanoEra era
}

runtime@TestnetRuntime{configurationFile} <- cardanoTestnetDefault options conf

socketPathAbs <- do
socketPath' <- H.sprocketArgumentName <$> H.headM (poolSprockets runtime)
H.noteIO (IO.canonicalizePath $ tempAbsPath' </> socketPath')

let handler :: ()
=> AnyNewEpochState
-> SlotNo
-> BlockNo
-> StateT [(SlotNo, BlockNo)] IO LedgerStateCondition
handler _ slotNo blockNo = do
modify ((slotNo, blockNo):)
s <- get
if length s >= 10
then pure ConditionMet
else pure ConditionNotMet

(_, nums) <- H.leftFailM $ H.evalIO $ runExceptT $
Api.foldEpochState (File configurationFile) (Api.File socketPathAbs) Api.QuickValidation (EpochNo maxBound) [] handler

length nums === 10
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import qualified Cardano.Testnet.Test.Cli.Conway.Plutus
import qualified Cardano.Testnet.Test.Cli.KesPeriodInfo
import qualified Cardano.Testnet.Test.Cli.Queries
import qualified Cardano.Testnet.Test.Cli.QuerySlotNumber
import qualified Cardano.Testnet.Test.FoldBlocks
import qualified Cardano.Testnet.Test.FoldEpochState
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.DRepActivity
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.DRepDeposits
import qualified Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitution
Expand Down Expand Up @@ -80,7 +80,7 @@ tests = do
-- as a result of the kes-period-info output to stdout.
, H.ignoreOnWindows "kes-period-info" Cardano.Testnet.Test.Cli.KesPeriodInfo.hprop_kes_period_info
, H.ignoreOnWindows "query-slot-number" Cardano.Testnet.Test.Cli.QuerySlotNumber.hprop_querySlotNumber
, H.ignoreOnWindows "foldBlocks receives ledger state" Cardano.Testnet.Test.FoldBlocks.prop_foldBlocks
, H.ignoreOnWindows "foldEpochState receives ledger state" Cardano.Testnet.Test.FoldEpochState.prop_foldEpochState
, H.ignoreOnWindows "CliQueries" Cardano.Testnet.Test.Cli.Queries.hprop_cli_queries
]
]
Expand Down

0 comments on commit fcc35c1

Please sign in to comment.