fix race in test

This commit is contained in:
Alexander Bondarenko
2024-05-29 21:41:21 +03:00
parent 4d2452b03f
commit 73bd003984
4 changed files with 7 additions and 8 deletions
+6 -4
View File
@@ -3384,8 +3384,9 @@ subscribeUserConnections vr onlyNeeded user = do
getContactConns = do
ctConns <- withStore_ getUserContactConnIds
ctConns' <- mapMaybe contactConnId . filter contactActive <$> withStore_ (`getUserContacts` vr)
unless (S.fromList ctConns == S.fromList ctConns') $
unless (S.fromList ctConns == S.fromList ctConns') $ do
logError $ "getContactConns differ: " <> tshow (ctConns, ctConns')
fail "abandon ship!"
pure ctConns -- (map fst cts', M.fromList cts')
getUserContactLinkConns :: CM ([ConnId], Map ConnId UserContact)
getUserContactLinkConns = do
@@ -3397,10 +3398,11 @@ subscribeUserConnections vr onlyNeeded user = do
gs <- withStore_ (`getUserGroupMemberConnIds` vr)
let mConns = S.fromList (concatMap snd gs)
gs' <- withStore_ (`getUserGroups` vr)
let mPairs = concatMap (\(Group _ ms) -> mapMaybe memberConnId (filter (not . memberRemoved) ms)) gs'
let mConns' = S.fromList mPairs
unless (mConns == mConns') $
let mPairs = concatMap (\(Group _ ms) -> mapMaybe (\m -> (,m) <$> memberConnId m) (filter (not . memberRemoved) ms)) gs'
let mConns' = S.fromList (map fst mPairs)
unless (mConns == mConns') $ do
logError $ "getGroupMemberConns differ: " <> tshow (mConns, mConns')
fail "abandon ship!"
pure (gs, concatMap snd gs)
getSndFileTransferConns :: CM ([ConnId], Map ConnId SndFileTransfer)
getSndFileTransferConns = do
-2
View File
@@ -721,8 +721,6 @@ data ChatResponse
| CRCallExtraInfo {user :: User, contact :: Contact, extraInfo :: WebRTCExtraInfo}
| CRCallEnded {user :: User, contact :: Contact}
| CRCallInvitations {callInvitations :: [RcvCallInvitation]}
| CRUserContactLinkSubscribed -- TODO delete
| CRUserContactLinkSubError {chatError :: ChatError} -- TODO delete
| CRNtfTokenStatus {status :: NtfTknStatus}
| CRNtfToken {token :: DeviceToken, status :: NtfTknStatus, ntfMode :: NotificationsMode, ntfServer :: NtfServer}
| CRNtfMessages {user_ :: Maybe User, connEntity_ :: Maybe ConnectionEntity, msgTs :: Maybe UTCTime, ntfMessages :: [NtfMsgInfo]}
-2
View File
@@ -283,8 +283,6 @@ responseToView hu@(currentRH, user_) ChatConfig {logLevel, showReactions, showRe
CRCallExtraInfo {user = u, contact} -> ttyUser u ["call extra info from " <> ttyContact' contact]
CRCallEnded {user = u, contact} -> ttyUser u ["call with " <> ttyContact' contact <> " ended"]
CRCallInvitations _ -> []
CRUserContactLinkSubscribed -> ["Your address is active! To show: " <> highlight' "/sa"]
CRUserContactLinkSubError e -> ["user address error: " <> sShow e, "to delete your address: " <> highlight' "/da"]
CRContactConnectionDeleted u PendingContactConnection {pccConnId} -> ttyUser u ["connection :" <> sShow pccConnId <> " deleted"]
CRNtfTokenStatus status -> ["device token status: " <> plain (smpEncode status)]
CRNtfToken _ status mode srv -> ["device token status: " <> plain (smpEncode status) <> ", notifications mode: " <> plain (strEncode mode) <> ", server: " <> sShow srv]
+1
View File
@@ -2580,6 +2580,7 @@ testPlanGroupLinkConnecting :: HasCallStack => FilePath -> IO ()
testPlanGroupLinkConnecting tmp = do
-- gLink <- withNewTestChatCfg tmp cfg "alice" aliceProfile $ \alice -> do
gLink <- withNewTestChatCfg tmp cfg "alice" aliceProfile $ \a -> withTestOutput a $ \alice -> do
threadDelay 100000
alice ##> "/g team"
alice <## "group #team is created"
alice <## "to add members use /a team <name> or /create link #team"