Skip to content

Commit

Permalink
core: add delays to tests to prevent output races (#1736)
Browse files Browse the repository at this point in the history
  • Loading branch information
spaced4ndy committed Jan 13, 2023
1 parent e63e158 commit cccdcef
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/ChatTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ testAddContact = versionTestMatrix2 runTestAddContact
concurrently_
(bob <## "alice (Alice): contact is connected")
(alice <## "bob (Bob): contact is connected")
threadDelay 100000
chatsEmpty alice bob
alice #> "@bob hello there 馃檪"
bob <# "alice> hello there 馃檪"
Expand Down Expand Up @@ -2579,6 +2580,7 @@ testUserContactLink = versionTestMatrix3 $ \alice bob cath -> do
concurrently_
(bob <## "alice (Alice): contact is connected")
(alice <## "bob (Bob): contact is connected")
threadDelay 100000
alice @@@ [("@bob", "Voice messages: enabled")]
alice <##> bob

Expand All @@ -2590,6 +2592,7 @@ testUserContactLink = versionTestMatrix3 $ \alice bob cath -> do
concurrently_
(cath <## "alice (Alice): contact is connected")
(alice <## "cath (Catherine): contact is connected")
threadDelay 100000
alice @@@ [("@cath", "Voice messages: enabled"), ("@bob", "hey")]
alice <##> cath

Expand Down Expand Up @@ -2692,6 +2695,7 @@ testDeduplicateContactRequests = testChat3 aliceProfile bobProfile cathProfile $
concurrently_
(cath <## "alice (Alice): contact is connected")
(alice <## "cath (Catherine): contact is connected")
threadDelay 100000
alice @@@ [("@cath", "Voice messages: enabled"), ("@bob", "hey")]
alice <##> cath

Expand Down Expand Up @@ -2764,6 +2768,7 @@ testDeduplicateContactRequestsProfileChange = testChat3 aliceProfile bobProfile
concurrently_
(cath <## "alice (Alice): contact is connected")
(alice <## "cath (Catherine): contact is connected")
threadDelay 100000
alice @@@ [("@cath", "Voice messages: enabled"), ("@robert", "hey")]
alice <##> cath

Expand Down Expand Up @@ -3410,6 +3415,7 @@ testSetConnectionAlias = testChat2 aliceProfile bobProfile $
concurrently_
(alice <## "bob (Bob): contact is connected")
(bob <## "alice (Alice): contact is connected")
threadDelay 100000
alice @@@ [("@bob", "Voice messages: enabled")]
alice ##> "/cs"
alice <## "bob (Bob) (alias: friend)"
Expand Down Expand Up @@ -3815,6 +3821,7 @@ testAsyncInitiatingOffline :: IO ()
testAsyncInitiatingOffline = withTmpFiles $ do
putStrLn "testAsyncInitiatingOffline"
inv <- withNewTestChat "alice" aliceProfile $ \alice -> do
threadDelay 250000
putStrLn "1"
alice ##> "/c"
putStrLn "2"
Expand Down Expand Up @@ -4446,6 +4453,7 @@ testMultipleUserAddresses =
concurrently_
(bob <## "alice (Alice): contact is connected")
(alice <## "bob (Bob): contact is connected")
threadDelay 100000
alice @@@ [("@bob", "Voice messages: enabled")]
alice <##> bob

Expand All @@ -4463,6 +4471,7 @@ testMultipleUserAddresses =
concurrently_
(bob <## "alisa: contact is connected")
(alice <## "bob (Bob): contact is connected")
threadDelay 100000
alice #$> ("/_get chats 2 pcc=on", chats, [("@bob", "Voice messages: enabled")])
alice <##> bob

Expand Down Expand Up @@ -4493,6 +4502,7 @@ testMultipleUserAddresses =
concurrently_
(cath <## "alisa: contact is connected")
(alice <## "cath (Catherine): contact is connected")
threadDelay 100000
alice #$> ("/_get chats 2 pcc=on", chats, [("@cath", "Voice messages: enabled"), ("@bob", "hey")])
alice <##> cath

Expand Down Expand Up @@ -4567,6 +4577,7 @@ testGroupLink =
bob <## "alice (Alice): contact is connected"
bob <## "#team: you joined the group"
]
threadDelay 100000
alice #$> ("/_get chat #1 count=100", chat, [(0, "invited via your group link"), (0, "connected")])
-- contacts connected via group link are not in chat previews
alice @@@ [("#team", "connected")]
Expand Down Expand Up @@ -4713,6 +4724,7 @@ testGroupLinkContactUsed =
bob <## "#team: you joined the group"
]
-- sending/receiving a message marks contact as used
threadDelay 100000
alice @@@ [("#team", "connected")]
bob @@@ [("#team", "connected")]
alice #> "@bob hello"
Expand Down

0 comments on commit cccdcef

Please sign in to comment.