From 5f0cbca2ba3a4c01beedd59d84a9b5ff8ff67499 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:34:41 +0400 Subject: [PATCH] fix, tests --- src/Simplex/Chat.hs | 2 +- tests/ChatTests/Files.hs | 16 ++-------------- tests/ChatTests/Forward.hs | 24 +++--------------------- tests/ChatTests/Utils.hs | 9 +++++++++ 4 files changed, 15 insertions(+), 36 deletions(-) diff --git a/src/Simplex/Chat.hs b/src/Simplex/Chat.hs index 7aa1015bdc..8615dcf8b2 100644 --- a/src/Simplex/Chat.hs +++ b/src/Simplex/Chat.hs @@ -860,7 +860,7 @@ processChatCommand' vr = \case throwChatError (CECommandError $ "reaction already " <> if add then "added" else "removed") when (add && length rs >= maxMsgReactions) $ throwChatError (CECommandError "too many reactions") - APIForwardChatItem fromChatRef (ChatRef toCType toChatId) itemId -> withUser $ \user -> withChatLock "forwardChatItem" $ case toCType of + APIForwardChatItem fromChatRef (ChatRef toCType toChatId) itemId -> withUser $ \user -> case toCType of CTDirect -> withContactLock "sendMessage" toChatId $ do cm <- prepareForward user sendContactContentMessage user toChatId False Nothing cm True diff --git a/tests/ChatTests/Files.hs b/tests/ChatTests/Files.hs index e50b20844a..572d9294a9 100644 --- a/tests/ChatTests/Files.hs +++ b/tests/ChatTests/Files.hs @@ -617,20 +617,8 @@ testXFTPWithRelativePaths = withXFTPServer $ do -- agent is passed xftp work directory only on chat start, -- so for test we work around by stopping and starting chat - alice ##> "/_stop" - alice <## "chat stopped" - alice #$> ("/_files_folder ./tests/fixtures", id, "ok") - alice #$> ("/_temp_folder ./tests/tmp/alice_xftp", id, "ok") - alice ##> "/_start" - alice <## "chat started" - - bob ##> "/_stop" - bob <## "chat stopped" - bob #$> ("/_files_folder ./tests/tmp/bob_files", id, "ok") - bob #$> ("/_temp_folder ./tests/tmp/bob_xftp", id, "ok") - bob ##> "/_start" - bob <## "chat started" - + setRelativePaths alice "./tests/fixtures" "./tests/tmp/alice_xftp" + setRelativePaths bob "./tests/tmp/bob_files" "./tests/tmp/bob_xftp" connectUsers alice bob alice #> "/f @bob test.pdf" diff --git a/tests/ChatTests/Forward.hs b/tests/ChatTests/Forward.hs index 8be70a3b75..cf59f271a7 100644 --- a/tests/ChatTests/Forward.hs +++ b/tests/ChatTests/Forward.hs @@ -279,27 +279,9 @@ testForwardFileRelativePaths :: HasCallStack => FilePath -> IO () testForwardFileRelativePaths = testChat3 aliceProfile bobProfile cathProfile $ \alice bob cath -> withXFTPServer $ do - alice ##> "/_stop" - alice <## "chat stopped" - alice #$> ("/_files_folder ./tests/fixtures", id, "ok") - alice #$> ("/_temp_folder ./tests/tmp/alice_xftp", id, "ok") - alice ##> "/_start" - alice <## "chat started" - - bob ##> "/_stop" - bob <## "chat stopped" - bob #$> ("/_files_folder ./tests/tmp/bob_files", id, "ok") - bob #$> ("/_temp_folder ./tests/tmp/bob_xftp", id, "ok") - bob ##> "/_start" - bob <## "chat started" - - cath ##> "/_stop" - cath <## "chat stopped" - cath #$> ("/_files_folder ./tests/tmp/cath_files", id, "ok") - cath #$> ("/_temp_folder ./tests/tmp/cath_xftp", id, "ok") - cath ##> "/_start" - cath <## "chat started" - + setRelativePaths alice "./tests/fixtures" "./tests/tmp/alice_xftp" + setRelativePaths bob "./tests/tmp/bob_files" "./tests/tmp/bob_xftp" + setRelativePaths cath "./tests/tmp/cath_files" "./tests/tmp/cath_xftp" connectUsers alice bob connectUsers bob cath diff --git a/tests/ChatTests/Utils.hs b/tests/ChatTests/Utils.hs index 98227fcd0c..aa6579efee 100644 --- a/tests/ChatTests/Utils.hs +++ b/tests/ChatTests/Utils.hs @@ -723,3 +723,12 @@ linkAnotherSchema link xftpCLI :: [String] -> IO [String] xftpCLI params = lines <$> capture_ (withArgs params xftpClientCLI) + +setRelativePaths :: HasCallStack => TestCC -> String -> String -> IO () +setRelativePaths cc filesFolder tempFolder = do + cc ##> "/_stop" + cc <## "chat stopped" + cc #$> ("/_files_folder " <> filesFolder, id, "ok") + cc #$> ("/_temp_folder " <> tempFolder, id, "ok") + cc ##> "/_start" + cc <## "chat started"