@@ -22,7 +22,6 @@ import Prelude hiding (lines)
2222
2323import qualified Control.Concurrent as IO
2424import Control.Monad
25- import Control.Monad.Catch (MonadCatch )
2625import Control.Monad.Trans.Reader (ReaderT )
2726import Control.Monad.Trans.Resource (ResourceT )
2827import Data.Aeson (Value , (.:) )
@@ -39,17 +38,16 @@ import qualified Data.Time.Clock as DTC
3938import Data.Type.Equality
4039import Data.Word (Word8 )
4140import GHC.Stack as GHC
41+ import RIO (throwString )
4242
43- import Testnet.Process.Run
43+ import Testnet.Process.RunIO
4444import Testnet.Start.Types
4545
4646import Hedgehog (MonadTest )
4747import qualified Hedgehog as H
4848import Hedgehog.Extras.Internal.Test.Integration (IntegrationState )
4949import qualified Hedgehog.Extras.Stock.IO.File as IO
50- import Hedgehog.Extras.Test.Base (failMessage )
5150import qualified Hedgehog.Extras.Test.Base as H
52- import qualified Hedgehog.Extras.Test.File as H
5351import Hedgehog.Extras.Test.Process (ExecConfig )
5452
5553newlineBytes :: Word8
@@ -65,23 +63,23 @@ fileJsonGrep fp f = do
6563 return $ L. any f jsons
6664
6765assertByDeadlineIOCustom
68- :: (MonadTest m , MonadIO m , HasCallStack )
66+ :: (MonadIO m , HasCallStack )
6967 => String -> DTC. UTCTime -> IO Bool -> m ()
7068assertByDeadlineIOCustom str deadline f = withFrozenCallStack $ do
71- success <- H. evalIO f
69+ success <- liftIOAnnotated f
7270 unless success $ do
73- currentTime <- H. evalIO DTC. getCurrentTime
71+ currentTime <- liftIOAnnotated DTC. getCurrentTime
7472 if currentTime < deadline
7573 then do
76- H. evalIO $ IO. threadDelay 1_000_000
74+ liftIOAnnotated $ IO. threadDelay 1_000_000
7775 assertByDeadlineIOCustom str deadline f
7876 else do
79- H. annotateShow currentTime
80- H. failMessage GHC. callStack $ " Condition not met by deadline: " <> str
77+ throwString $ " Condition not met by deadline: " <> str
8178
8279-- | A sanity check that confirms that there are the expected number of SPOs in the ledger state
8380assertExpectedSposInLedgerState
84- :: (MonadTest m , MonadCatch m , MonadIO m , HasCallStack )
81+ :: HasCallStack
82+ => MonadIO m
8583 => FilePath -- ^ Stake pools query output filepath
8684 -> NumPools
8785 -> ExecConfig
@@ -92,21 +90,21 @@ assertExpectedSposInLedgerState output (NumPools numExpectedPools) execConfig =
9290 , " --out-file" , output
9391 ]
9492
95- poolSet <- H. evalEither =<< H. evalIO (Aeson. eitherDecodeFileStrict' @ (Set PoolId ) output)
96-
97- H. cat output
98-
99- let numPoolsInLedgerState = Set. size poolSet
100- unless (numPoolsInLedgerState == numExpectedPools) $
101- failMessage GHC. callStack
102- $ unlines [ " Expected number of stake pools not found in ledger state"
103- , " Expected: " , show numExpectedPools
104- , " Actual: " , show numPoolsInLedgerState
105- ]
93+ ePoolSet <- liftIOAnnotated (Aeson. eitherDecodeFileStrict' @ (Set PoolId ) output)
94+ case ePoolSet of
95+ Left err ->
96+ throwString $ " Failed to decode stake pools from ledger state: " <> err
97+ Right poolSet -> do
98+ let numPoolsInLedgerState = Set. size poolSet
99+ unless (numPoolsInLedgerState == numExpectedPools) $
100+ throwString $ unlines
101+ [ " Expected number of stake pooFvls not found in ledger state"
102+ , " Expected: " , show numExpectedPools
103+ , " Actual: " , show numPoolsInLedgerState
104+ ]
106105
107106assertChainExtended
108107 :: HasCallStack
109- => H. MonadTest m
110108 => MonadIO m
111109 => DTC. UTCTime
112110 -> NodeLoggingFormat
0 commit comments