mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-26 13:08:02 +00:00
tests: chat tests using client services (dont merge)
This commit is contained in:
@@ -527,6 +527,21 @@ Query:
|
||||
Plan:
|
||||
SEARCH connections USING PRIMARY KEY (conn_id=?)
|
||||
|
||||
Query:
|
||||
DELETE FROM client_services
|
||||
WHERE user_id = ? AND host = ? AND port = ?
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM servers s
|
||||
WHERE s.host = client_services.host
|
||||
AND s.port = client_services.port
|
||||
AND COALESCE(client_services.server_key_hash, s.key_hash) = ?
|
||||
);
|
||||
|
||||
Plan:
|
||||
SEARCH client_services USING COVERING INDEX idx_server_certs_user_id_host_port (user_id=? AND host=? AND port=?)
|
||||
CORRELATED SCALAR SUBQUERY 1
|
||||
SEARCH s USING PRIMARY KEY (host=? AND port=?)
|
||||
|
||||
Query:
|
||||
DELETE FROM conn_confirmations
|
||||
WHERE conn_id = ?
|
||||
|
||||
@@ -429,8 +429,8 @@ testChatN :: HasCallStack => ChatConfig -> ChatOpts -> [Profile] -> (HasCallStac
|
||||
testChatN cfg opts ps test params =
|
||||
bracket (getTestCCs $ zip ps [1 ..]) endTests test
|
||||
where
|
||||
useClientServices = False
|
||||
-- useClientServices = True
|
||||
-- useClientServices = False
|
||||
useClientServices = True
|
||||
getTestCCs :: [(Profile, Int)] -> IO [TestCC]
|
||||
getTestCCs [] = pure []
|
||||
getTestCCs ((p, db) : envs') = (:) <$> createTestChat params cfg opts (show db) useClientServices p <*> getTestCCs envs'
|
||||
|
||||
@@ -247,14 +247,15 @@ testRetryConnecting ps = testChatCfgOpts2 cfg' opts' aliceProfile bobProfile tes
|
||||
inv <- withSmpServer' serverCfg' $ do
|
||||
alice ##> "/_connect 1"
|
||||
getInvitation alice
|
||||
alice <## "disconnected 1 connections on server localhost"
|
||||
alice <## "disconnected service (1 connections) on server localhost"
|
||||
bob ##> ("/_connect plan 1 " <> inv)
|
||||
bob <## "invitation link: ok to connect"
|
||||
_sLinkData <- getTermLine bob
|
||||
bob ##> ("/_connect 1 " <> inv)
|
||||
bob <##. "smp agent error: BROKER"
|
||||
withSmpServer' serverCfg' $ do
|
||||
alice <## "subscribed 1 connections on server localhost"
|
||||
alice <## "subscribed service (1 connections) on server localhost: ok"
|
||||
alice <## "received messages from service on server localhost"
|
||||
threadDelay 250000
|
||||
bob ##> ("/_connect plan 1 " <> inv)
|
||||
bob <## "invitation link: ok to connect"
|
||||
@@ -268,8 +269,8 @@ testRetryConnecting ps = testChatCfgOpts2 cfg' opts' aliceProfile bobProfile tes
|
||||
bob <# "alice> message 1"
|
||||
bob #> "@alice message 2"
|
||||
alice <# "bob> message 2"
|
||||
bob <## "disconnected 1 connections on server localhost"
|
||||
alice <## "disconnected 1 connections on server localhost"
|
||||
bob <## "disconnected service (1 connections) on server localhost"
|
||||
alice <## "disconnected service (1 connections) on server localhost"
|
||||
serverCfg' =
|
||||
smpServerCfg
|
||||
{ transports = [("7003", transport @TLS, False)],
|
||||
|
||||
@@ -866,7 +866,8 @@ testXFTPMarkToReceive = do
|
||||
bob <## "chat started"
|
||||
|
||||
bob
|
||||
<### [ "subscribed 1 connections on server localhost",
|
||||
<### [ "subscribed service (1 connections) on server localhost: ok",
|
||||
"received messages from service on server localhost",
|
||||
"started receiving file 1 (test.pdf) from alice",
|
||||
"saving file 1 from alice to test.pdf"
|
||||
]
|
||||
|
||||
@@ -324,27 +324,27 @@ testRetryConnectingViaContactLink ps = testChatCfgOpts2 cfg' opts' aliceProfile
|
||||
cLink <- withSmpServer' serverCfg' $ do
|
||||
alice ##> "/ad"
|
||||
getContactLink alice True
|
||||
alice <## "disconnected 1 connections on server localhost"
|
||||
alice <## "disconnected service (1 connections) on server localhost"
|
||||
bob ##> ("/_connect plan 1 " <> cLink)
|
||||
bob <## "contact address: ok to connect"
|
||||
_sLinkData <- getTermLine bob
|
||||
bob ##> ("/_connect 1 " <> cLink)
|
||||
bob <##. "smp agent error: BROKER"
|
||||
withSmpServer' serverCfg' $ do
|
||||
alice <## "subscribed 1 connections on server localhost"
|
||||
alice <### ["subscribed service (1 connections) on server localhost: ok", "received messages from service on server localhost"]
|
||||
threadDelay 250000
|
||||
bob ##> ("/_connect plan 1 " <> cLink)
|
||||
bob <## "contact address: ok to connect"
|
||||
_sLinkData <- getTermLine bob
|
||||
bob ##> ("/_connect 1 " <> cLink)
|
||||
alice <#? bob
|
||||
alice <## "disconnected 1 connections on server localhost"
|
||||
bob <## "disconnected 1 connections on server localhost"
|
||||
alice <## "disconnected service (1 connections) on server localhost"
|
||||
bob <## "disconnected service (1 connections) on server localhost"
|
||||
alice ##> "/ac bob"
|
||||
alice <##. "smp agent error: BROKER"
|
||||
withSmpServer' serverCfg' $ do
|
||||
alice <## "subscribed 1 connections on server localhost"
|
||||
bob <## "subscribed 1 connections on server localhost"
|
||||
alice <### ["subscribed service (1 connections) on server localhost: ok", "received messages from service on server localhost"]
|
||||
bob <### ["subscribed service (1 connections) on server localhost: ok", "received messages from service on server localhost"]
|
||||
alice ##> "/ac bob"
|
||||
alice <## "bob (Bob): accepting contact request, you can send messages to contact"
|
||||
concurrently_
|
||||
@@ -354,8 +354,8 @@ testRetryConnectingViaContactLink ps = testChatCfgOpts2 cfg' opts' aliceProfile
|
||||
bob <# "alice> message 1"
|
||||
bob #> "@alice message 2"
|
||||
alice <# "bob> message 2"
|
||||
alice <## "disconnected 2 connections on server localhost"
|
||||
bob <## "disconnected 1 connections on server localhost"
|
||||
alice <## "disconnected service (2 connections) on server localhost"
|
||||
bob <## "disconnected service (1 connections) on server localhost"
|
||||
serverCfg' =
|
||||
smpServerCfg
|
||||
{ transports = [("7003", transport @TLS, False)],
|
||||
@@ -3038,11 +3038,14 @@ testShortLinkInvitationConnectRetry ps = testChatOpts2 opts' aliceProfile bobPro
|
||||
bob ##> ("/_prepare contact 1 " <> fullLink <> " " <> shortLink <> " " <> contactSLinkData)
|
||||
bob <## "alice: contact is prepared"
|
||||
pure shortLink
|
||||
alice <## "disconnected 1 connections on server localhost"
|
||||
alice <## "disconnected service (1 connections) on server localhost"
|
||||
bob ##> "/_connect contact @2 text hello"
|
||||
bob <##. "smp agent error: BROKER"
|
||||
withSmpServer' serverCfg' $ do
|
||||
alice <## "subscribed 1 connections on server localhost"
|
||||
alice <###
|
||||
[ "subscribed service (1 connections) on server localhost: ok",
|
||||
"received messages from service on server localhost"
|
||||
]
|
||||
threadDelay 250000
|
||||
bob ##> ("/_connect plan 1 " <> shortLink)
|
||||
bob <## "invitation link: known prepared contact alice"
|
||||
@@ -3056,8 +3059,8 @@ testShortLinkInvitationConnectRetry ps = testChatOpts2 opts' aliceProfile bobPro
|
||||
(bob <## "alice (Alice): contact is connected")
|
||||
(alice <## "bob (Bob): contact is connected")
|
||||
alice <##> bob
|
||||
alice <## "disconnected 1 connections on server localhost"
|
||||
bob <## "disconnected 1 connections on server localhost"
|
||||
alice <## "disconnected service (1 connections) on server localhost"
|
||||
bob <## "disconnected service (1 connections) on server localhost"
|
||||
tmp = tmpPath ps
|
||||
serverCfg' =
|
||||
smpServerCfg
|
||||
@@ -3547,15 +3550,17 @@ testShortLinkGroupRetry ps = testChatOpts2 opts' aliceProfile bobProfile test ps
|
||||
bob ##> ("/_prepare group 1 " <> fullLink <> " " <> shortLink <> " " <> groupSLinkData)
|
||||
bob <## "#team: group is prepared"
|
||||
pure shortLink
|
||||
alice <## "disconnected 2 connections on server localhost"
|
||||
bob <## "disconnected 1 connections on server localhost"
|
||||
alice <## "disconnected service (2 connections) on server localhost"
|
||||
bob <## "disconnected service (1 connections) on server localhost"
|
||||
bob ##> "/_connect group #1"
|
||||
bob <##. "smp agent error: BROKER"
|
||||
withSmpServer' serverCfg' $ do
|
||||
bob ##> ("/_connect plan 1 " <> shortLink)
|
||||
bob <## "group link: known prepared group #team"
|
||||
alice <## "subscribed 2 connections on server localhost"
|
||||
bob <## "subscribed 1 connections on server localhost"
|
||||
alice <## "subscribed service (2 connections) on server localhost: ok"
|
||||
alice <## "received messages from service on server localhost"
|
||||
bob <## "subscribed service (1 connections) on server localhost: ok"
|
||||
bob <## "received messages from service on server localhost"
|
||||
threadDelay 250000
|
||||
bob ##> "/_connect group #1"
|
||||
bob <## "#team: connection started"
|
||||
@@ -3574,8 +3579,8 @@ testShortLinkGroupRetry ps = testChatOpts2 opts' aliceProfile bobProfile test ps
|
||||
bob <# "#team alice> 1"
|
||||
bob #> "#team 2"
|
||||
alice <# "#team bob> 2"
|
||||
alice <## "disconnected 3 connections on server localhost"
|
||||
bob <## "disconnected 2 connections on server localhost"
|
||||
alice <## "disconnected service (3 connections) on server localhost"
|
||||
bob <## "disconnected service (2 connections) on server localhost"
|
||||
tmp = tmpPath ps
|
||||
serverCfg' =
|
||||
smpServerCfg
|
||||
|
||||
Reference in New Issue
Block a user