Skip to content

Commit 0e63fac

Browse files
committed
Adapt E2E test
1 parent 3ecd834 commit 0e63fac

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

mithril-test-lab/mithril-end-to-end/test/Test/EndToEndSpec.hs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,19 @@ assertClientCanVerifySnapshot workDir aggregator digest =
8282
void $ runClient workDir aggregator ["restore", digest]
8383

8484
assertNodeIsProducingSnapshot :: Tracer IO ClusterLog -> RunningNode -> Int -> IO Text
85-
assertNodeIsProducingSnapshot _tracer _cardanoNode aggregatorPort = do
86-
request <- parseRequest $ "http://localhost:" <> show aggregatorPort <> "/aggregator/certificate-pending"
87-
CertificatePending {beacon} <- getResponseBody <$> httpJSON request
88-
pure $ digestOf beacon
85+
assertNodeIsProducingSnapshot _tracer _cardanoNode aggregatorPort = go 10
86+
where
87+
go :: Int -> IO ()
88+
go 0 = failure "Timeout exhausted"
89+
go n = do
90+
request <- parseRequest $ "http://localhost:" <> show aggregatorPort <> "/aggregator/certificate-pending"
91+
response <- httpLBS request
92+
case getResponseStatusCode response of
93+
204 -> threadDelay 1 >> go (n -1)
94+
200 -> do
95+
CertificatePending {beacon} <- getResponseBody <$> httpJSON request
96+
pure $ digestOf beacon
97+
other -> failure $ "unexpected status code: " <> show other
8998

9099
assertNetworkIsProducingBlock :: Tracer IO ClusterLog -> RunningCluster -> IO ()
91100
assertNetworkIsProducingBlock tracer = failAfter 30 . go (-1)

0 commit comments

Comments
 (0)