Skip to content

Commit

Permalink
Replace with byDeadlineM with waitUntilEpoch in hprop_stakeSnapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Mar 5, 2024
1 parent 4d9140c commit e8be723
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ module Cardano.Testnet.Test.Cli.Babbage.StakeSnapshot
) where

import Cardano.Api
import qualified Cardano.Api as Api

import Cardano.CLI.Types.Output (QueryTipLocalStateOutput (..))
import Cardano.Testnet

import Prelude

import Control.Monad
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.KeyMap as KM
import qualified Data.Time.Clock as DTC
import GHC.Stack (callStack)
import qualified System.Info as SYS

import Testnet.Process.Cli (execCliStdoutToJson)
Expand All @@ -29,6 +28,7 @@ import Testnet.Runtime

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

hprop_stakeSnapshot :: Property
Expand All @@ -49,22 +49,15 @@ hprop_stakeSnapshot = H.integrationRetryWorkspace 2 "babbage-stake-snapshot" $ \
TestnetRuntime
{ testnetMagic
, poolNodes
, configurationFile
} <- cardanoTestnetDefault options conf

poolNode1 <- H.headM poolNodes
poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1
execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic
tipDeadline <- H.noteShowM $ DTC.addUTCTime 210 <$> H.noteShowIO DTC.getCurrentTime

H.byDeadlineM 10 tipDeadline "Wait for two epochs" $ do
tip <- execCliStdoutToJson execConfig [ "query", "tip" ]

currEpoch <- case mEpoch tip of
Nothing -> H.failMessage callStack "cardano-cli query tip returned Nothing for EpochNo"
Just currEpoch -> return currEpoch

H.note_ $ "Current Epoch: " <> show currEpoch
H.assert $ currEpoch > 2
void $ waitUntilEpoch (Api.File configurationFile)
(Api.File $ IO.sprocketSystemName poolSprocket1) (EpochNo 3)

json <- execCliStdoutToJson execConfig [ "query", "stake-snapshot", "--all-stake-pools" ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ module Cardano.Testnet.Test.Cli.Conway.StakeSnapshot
( hprop_stakeSnapshot
) where

import Cardano.Api
import Cardano.Api as Api

import Cardano.CLI.Types.Output (QueryTipLocalStateOutput (..))
import Cardano.Testnet

import Prelude

import Control.Monad
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.KeyMap as KM
import qualified Data.Time.Clock as DTC
import GHC.Stack (callStack)
import qualified System.Info as SYS

import Testnet.Process.Cli (execCliStdoutToJson)
Expand All @@ -29,6 +27,7 @@ import Testnet.Runtime

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

hprop_stakeSnapshot :: Property
Expand All @@ -48,23 +47,16 @@ hprop_stakeSnapshot = H.integrationRetryWorkspace 2 "conway-stake-snapshot" $ \t
TestnetRuntime
{ testnetMagic
, poolNodes
, configurationFile
} <- cardanoTestnetDefault options conf

poolNode1 <- H.headM poolNodes
poolSprocket1 <- H.noteShow $ nodeSprocket $ poolRuntime poolNode1
execConfig <- H.mkExecConfig tempBaseAbsPath poolSprocket1 testnetMagic

tipDeadline <- H.noteShowM $ DTC.addUTCTime 210 <$> H.noteShowIO DTC.getCurrentTime
void $ waitUntilEpoch (Api.File configurationFile)
(Api.File $ IO.sprocketSystemName poolSprocket1) (EpochNo 3)

H.byDeadlineM 10 tipDeadline "Wait for two epochs" $ do
tip <- execCliStdoutToJson execConfig [ "query", "tip" ]

currEpoch <- case mEpoch tip of
Nothing -> H.failMessage callStack "cardano-cli query tip returned Nothing for EpochNo"
Just currEpoch -> return currEpoch

H.note_ $ "Current Epoch: " <> show currEpoch
H.assert $ currEpoch > 2

json <- execCliStdoutToJson execConfig [ "query", "stake-snapshot", "--all-stake-pools" ]

Expand Down

0 comments on commit e8be723

Please sign in to comment.