core: fix connecting via prepared connection with contact card (#7575)

* core: fix connecting via prepared connection with contact card

* simplify

* merge transactions

* update query plans

---------

Co-authored-by: Evgeny @ SimpleX Chat <259188159+evgeny-simplex@users.noreply.github.com>
This commit is contained in:
EvgenyandEvgeny @ SimpleX Chat authored and GitHub committed 2026-09-24 08:11:29 +01:00
1 parent 2214b8990c
commit 9a9ce70b2f
8 files changed
+82 -13

No files matched your search

+3
View File
@@ -5234,6 +5234,9 @@ testMemberContactAccept =
cath #$> ("/_get chat @3 count=1", chat, [(0, "requested connection from group team")])
cath ##> "/_connect contact 1 3"
cath <## "bad chat command: contact is a member contact request"
cath ##> "/accept_member_contact @bob"
cath <## "contact bob is accepted, starting connection"
concurrently_
+45
View File
@@ -67,6 +67,7 @@ chatProfileTests = do
it "rotate address ratchet keys" testRotateAddressRatchetKeys
it "create address on specified server" testCreateAddressOnServer
it "retry connecting via contact link" testRetryConnectingViaContactLink
it "retry connecting via address in contact profile after address keys rotation" testRetryConnectingContactViaAddress
it "add contact link to profile" testProfileLink
it "auto accept contact requests" testUserContactLinkAutoAccept
it "deduplicate contact requests" testDeduplicateContactRequests
@@ -822,6 +823,50 @@ testRetryConnectingViaContactLink ps = testChatCfgOpts2 cfg' opts' aliceProfile
}
}
testRetryConnectingContactViaAddress :: HasCallStack => TestParams -> IO ()
testRetryConnectingContactViaAddress ps =
withNewTestChatOpts ps testOptsNoFullLinks "alice" aliceProfile $ \alice ->
withNewTestChatCfgOpts ps cfg' opts' "bob" bobProfile $ \bob -> do
alice ##> "/ad"
sLink <- getContactLink_ alice True
alice ##> "/pa on"
alice <## "new contact address set"
rotateAddressKeys alice
case A.parseOnly strP (B.pack sLink) of
Left _ -> error "error parsing contact link"
Right shortLink -> do
void $ withCCUser bob $ \user -> withCCTransaction bob $ \db -> runExceptT $ createContact db (storeCxt $ chatController bob) user aliceProfile {contactLink = Just shortLink}
bob ##> "/_connect contact 1 2"
bob <##. "smp agent error: BROKER"
rotateAddressKeys alice
withSmpServer' serverCfg' $ do
bob ##> "/_connect contact 1 2"
bob <## "connection request sent!"
alice <## "bob (Bob) wants to connect to you!"
alice <## "to accept: /ac bob"
alice <## "to reject: /rc bob (the sender will NOT be notified)"
alice ##> "/ac bob"
alice <## "bob (Bob): accepting contact request, you can send messages to contact"
concurrently_
(bob <## "alice (Alice): contact is connected")
(alice <## "bob (Bob): contact is connected")
alice <##> bob
bob <## "disconnected 1 connections on server localhost"
where
rotateAddressKeys alice = do
alice ##> "/_rotate_address_keys 1"
_ <- getContactLink_ alice False
alice <## "auto_accept off"
serverCfg' = smpServerCfg {transports = [("7003", transport @TLS, False)]}
cfg' = testCfg {agentConfig = testAgentCfg {persistErrorInterval = 0}}
opts' =
testOpts
{ coreOptions =
testCoreOpts
{ smpServers = ["smp://LcJUMfVhwD8yxjAiSaDzzGF3-kLG4Uh0Fl_ZIjrRwjI=:server_password@localhost:7003"]
}
}
testProfileLink :: HasCallStack => TestParams -> IO ()
testProfileLink =
testChat3 aliceProfile bobProfile cathProfile $