Skip to content

Commit 6eff178

Browse files
committed
Remove assertByDeadlineMCustom function
1 parent fdc57f5 commit 6eff178

File tree

4 files changed

+16
-33
lines changed

4 files changed

+16
-33
lines changed

Diff for: cardano-testnet/src/Testnet/Babbage.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ babbageTestnet testnetOptions H.Conf {..} = do
335335
return $ PoolNode runtime key
336336

337337
now <- H.noteShowIO DTC.getCurrentTime
338-
deadline <- H.noteShow $ DTC.addUTCTime 110 now
338+
deadline <- H.noteShow $ DTC.addUTCTime 90 now
339339

340340
forM_ spoNodes $ \node -> do
341341
nodeStdoutFile <- H.noteTempFile logDir $ node <> ".stdout.log"

Diff for: cardano-testnet/src/Util/Process.hs

-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module Util.Process
22
( assertByDeadlineIOCustom
3-
, assertByDeadlineMCustom
43
, bashPath
54
, execCli
65
, execCli_
@@ -132,26 +131,10 @@ assertByDeadlineIOCustom str deadline f = GHC.withFrozenCallStack $ do
132131
success <- liftIO f
133132
unless success $ do
134133
currentTime <- liftIO DTC.getCurrentTime
135-
note_ $ "Current time: " <> show currentTime
136134
if currentTime < deadline
137135
then do
138136
liftIO $ IO.threadDelay 1000000
139137
assertByDeadlineIOCustom str deadline f
140138
else do
141139
H.annotateShow currentTime
142140
failMessage GHC.callStack $ "Condition not met by deadline: " <> str
143-
144-
assertByDeadlineMCustom
145-
:: (MonadTest m, MonadIO m, HasCallStack)
146-
=> String -> UTCTime -> m Bool -> m ()
147-
assertByDeadlineMCustom str deadline f = GHC.withFrozenCallStack $ do
148-
success <- f
149-
unless success $ do
150-
currentTime <- liftIO DTC.getCurrentTime
151-
if currentTime < deadline
152-
then do
153-
liftIO $ IO.threadDelay 1000000
154-
assertByDeadlineMCustom str deadline f
155-
else do
156-
H.annotateShow currentTime
157-
failMessage GHC.callStack $ "Condition not met by deadline: " <> str

Diff for: cardano-testnet/test/Test/Cli/Alonzo/LeadershipSchedule.hs

+7-7
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ import qualified System.Directory as IO
4242
import System.Environment (getEnvironment)
4343
import System.FilePath ((</>))
4444
import qualified System.Info as SYS
45-
import Testnet ( TestnetOptions (CardanoOnlyTestnetOptions), testnet)
45+
import Testnet (TestnetOptions (CardanoOnlyTestnetOptions), testnet)
4646
import Testnet.Cardano as TC (CardanoTestnetOptions (..), defaultTestnetOptions)
4747
import qualified Testnet.Conf as H
4848
import Testnet.Utils (waitUntilEpoch)
4949
import qualified Util.Assert as H
5050
import qualified Util.Base as H
5151
import qualified Util.Process as H
52-
import Util.Runtime (LeadershipSlot (..))
5352
import qualified Util.Runtime as TR
53+
import Util.Runtime (LeadershipSlot (..))
5454

5555
hprop_leadershipSchedule :: Property
5656
hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo" $ \tempAbsBasePath' -> do
@@ -454,8 +454,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo"
454454
now <- H.noteShowIO DTC.getCurrentTime
455455
deadline <- H.noteShow $ DTC.addUTCTime 90 now
456456

457-
H.assertByDeadlineMCustom "stdout does not contain \"until genesis start time\"" deadline $ do
458-
H.threadDelay 1000000
457+
H.byDeadlineM 10 deadline $ do
459458
void $ H.execCli' execConfig
460459
[ "query", "tip"
461460
, "--testnet-magic", show @Int testnetMagic
@@ -470,7 +469,7 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo"
470469
Just currEpoch3 -> return currEpoch3
471470

472471
H.note_ $ "Current Epoch: " <> show currEpoch3
473-
return (currEpoch3 > currEpoch2 + 1)
472+
H.assert $ currEpoch3 > currEpoch2 + 1
474473

475474
ledgerStateJson <- H.execCli' execConfig
476475
[ "query", "ledger-state"
@@ -503,11 +502,12 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo"
503502

504503
leadershipDeadline <- H.noteShowM $ DTC.addUTCTime 90 <$> H.noteShowIO DTC.getCurrentTime
505504

506-
H.assertByDeadlineMCustom "Leader schedule is correct" leadershipDeadline $ do
505+
-- Leader schedule is correct
506+
H.byDeadlineM 10 leadershipDeadline $ do
507507
leaderSlots <- H.getRelevantLeaderSlots (TR.nodeStdout $ TR.poolRuntime poolNode1) (minimum expectedLeadershipSlotNumbers)
508508
maxSlotExpected <- H.noteShow $ maximum expectedLeadershipSlotNumbers
509509
maxActualSlot <- H.noteShow $ maximum leaderSlots
510-
return $ maxActualSlot >= maxSlotExpected
510+
H.assert $ maxActualSlot >= maxSlotExpected
511511

512512
leaderSlots <- H.getRelevantLeaderSlots (TR.poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers)
513513

Diff for: cardano-testnet/test/Test/Cli/Babbage/LeadershipSchedule.hs

+8-8
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import qualified Data.Time.Clock as DTC
3333
import qualified Hedgehog as H
3434
import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO
3535
import qualified Hedgehog.Extras.Test.Base as H
36-
import qualified Hedgehog.Extras.Test.Concurrent as H
3736
import qualified Hedgehog.Extras.Test.File as H
3837
import qualified Hedgehog.Extras.Test.Process as H
3938
import qualified System.Directory as IO
@@ -90,7 +89,6 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo"
9089

9190
-- stdout must contain \"until genesis start time\""
9291
H.byDeadlineM 10 tipDeadline $ do
93-
H.threadDelay 5000000
9492
void $ H.execCli' execConfig
9593
[ "query", "tip"
9694
, "--testnet-magic", show @Int testnetMagic
@@ -138,14 +136,15 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo"
138136

139137
leadershipDeadline <- H.noteShowM $ DTC.addUTCTime 90 <$> H.noteShowIO DTC.getCurrentTime
140138

141-
H.assertByDeadlineMCustom "Retrieve actual slots" leadershipDeadline $ do
139+
-- Retrieve actual slots
140+
H.byDeadlineM 10 leadershipDeadline $ do
142141
leaderSlots <- H.getRelevantLeaderSlots (TR.poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers)
143142
maxSlotExpected <- H.noteShow $ maximum expectedLeadershipSlotNumbers
144143
if L.null leaderSlots
145-
then return False
144+
then H.failure
146145
else do
147146
maxActualSlot <- H.noteShow $ maximum leaderSlots
148-
return $ maxActualSlot >= maxSlotExpected
147+
H.assert $ maxActualSlot >= maxSlotExpected
149148

150149
leaderSlots <- H.getRelevantLeaderSlots (TR.poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers)
151150

@@ -180,13 +179,14 @@ hprop_leadershipSchedule = H.integration . H.runFinallies . H.workspace "alonzo"
180179

181180
leadershipDeadline <- H.noteShowM $ DTC.addUTCTime 90 <$> H.noteShowIO DTC.getCurrentTime
182181

183-
H.assertByDeadlineMCustom "Retrieve actual slots" leadershipDeadline $ do
182+
-- Retrieve actual slots
183+
H.byDeadlineM 10 leadershipDeadline $ do
184184
leaderSlots <- H.getRelevantLeaderSlots (TR.poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers)
185185
if L.null leaderSlots
186-
then return False
186+
then H.failure
187187
else do
188188
maxActualSlot <- H.noteShow $ maximum leaderSlots
189-
return $ maxActualSlot >= maxSlotExpected
189+
H.assert $ maxActualSlot >= maxSlotExpected
190190

191191
leaderSlots <- H.getRelevantLeaderSlots (TR.poolNodeStdout poolNode1) (minimum expectedLeadershipSlotNumbers)
192192

0 commit comments

Comments
 (0)