Skip to content

Commit

Permalink
Merge #3820
Browse files Browse the repository at this point in the history
3820: Fixed KeepAlive Convergence test r=bolt12 a=bolt12

# Description

This small PR just extracts a particular commit from #3682 since now the actual PR lives in input-output-hk/io-sim#9.



Co-authored-by: Armando Santos <armando@well-typed.com>
  • Loading branch information
iohk-bors[bot] and bolt12 committed Jun 29, 2022
2 parents 18efc8c + d5d46bb commit 847f8ac
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions ouroboros-network/test/Test/Ouroboros/Network/KeepAlive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -155,27 +155,23 @@ prop_keepAlive_convergenceM tracer (NetworkDelay nd) seed = do
controlMessageV <- newTVarIO Continue
let controlMessageSTM = readTVar controlMessageV
clientId = "client"
timeConstant = 1000 -- Same as in PeerGSV's <> definition
keepAliveInterval = 10

(c_aid, s_aid) <- runKeepAliveClientAndServer (NetworkDelay nd) seed tracer controlMessageSTM
registry clientId (KeepAliveInterval keepAliveInterval)
threadDelay $ timeConstant * keepAliveInterval

atomically $ writeTVar controlMessageV Terminate
void $ wait c_aid
void $ wait s_aid

-- XXX Must be larger than the KeepAliveInterval timeout or we leak threads in the SIM
-- Can be removed after #2631 is merged.
threadDelay (keepAliveInterval + 128)

-- Test that our estimate of PeerGSV's G terms converge to
-- a given constant delay.
prop_keepAlive_convergence :: NetworkDelay -> Int -> Property
prop_keepAlive_convergence nd seed =
let trace = selectTraceEventsDynamic $ runSimTrace $ prop_keepAlive_convergenceM dynamicTracer nd seed in
verifyConvergence trace
let trace = take 1000
. selectTraceEventsDynamic
$ runSimTrace
$ prop_keepAlive_convergenceM dynamicTracer nd seed
in verifyConvergence trace
where
verifyConvergence :: [TraceKeepAliveClient String] -> Property
verifyConvergence [] = property False
Expand Down

0 comments on commit 847f8ac

Please sign in to comment.