mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
Merge branch 'stable'
This commit is contained in:
@@ -1067,7 +1067,7 @@ testChatWorking alice bob = do
|
||||
alice <# "bob> hello too"
|
||||
|
||||
testMaintenanceModeWithFiles :: HasCallStack => FilePath -> IO ()
|
||||
testMaintenanceModeWithFiles tmp = do
|
||||
testMaintenanceModeWithFiles tmp = withXFTPServer $ do
|
||||
withNewTestChat tmp "bob" bobProfile $ \bob -> do
|
||||
withNewTestChatOpts tmp testOpts {maintenance = True} "alice" aliceProfile $ \alice -> do
|
||||
alice ##> "/_start"
|
||||
@@ -1075,12 +1075,26 @@ testMaintenanceModeWithFiles tmp = do
|
||||
alice ##> "/_files_folder ./tests/tmp/alice_files"
|
||||
alice <## "ok"
|
||||
connectUsers alice bob
|
||||
startFileTransferWithDest' bob alice "test.jpg" "136.5 KiB / 139737 bytes" Nothing
|
||||
bob <## "completed sending file 1 (test.jpg) to alice"
|
||||
|
||||
bob #> "/f @alice ./tests/fixtures/test.jpg"
|
||||
bob <## "use /fc 1 to cancel sending"
|
||||
alice <# "bob> sends file test.jpg (136.5 KiB / 139737 bytes)"
|
||||
alice <## "use /fr 1 [<dir>/ | <path>] to receive it"
|
||||
bob <## "completed uploading file 1 (test.jpg) for alice"
|
||||
|
||||
alice ##> "/fr 1"
|
||||
alice
|
||||
<### [ "saving file 1 from bob to test.jpg",
|
||||
"started receiving file 1 (test.jpg) from bob"
|
||||
]
|
||||
alice <## "completed receiving file 1 (test.jpg) from bob"
|
||||
|
||||
src <- B.readFile "./tests/fixtures/test.jpg"
|
||||
B.readFile "./tests/tmp/alice_files/test.jpg" `shouldReturn` src
|
||||
dest <- B.readFile "./tests/tmp/alice_files/test.jpg"
|
||||
dest `shouldBe` src
|
||||
|
||||
threadDelay 500000
|
||||
|
||||
alice ##> "/_stop"
|
||||
alice <## "chat stopped"
|
||||
alice ##> "/_db export {\"archivePath\": \"./tests/tmp/alice-chat.zip\"}"
|
||||
|
||||
+143
-867
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@ import Control.Monad (void, when)
|
||||
import qualified Data.ByteString as B
|
||||
import Data.List (isInfixOf)
|
||||
import qualified Data.Text as T
|
||||
import Simplex.Chat.Controller (ChatConfig (..), XFTPFileConfig (..))
|
||||
import Simplex.Chat.Controller (ChatConfig (..))
|
||||
import Simplex.Chat.Protocol (supportedChatVRange)
|
||||
import Simplex.Chat.Store (agentStoreFile, chatStoreFile)
|
||||
import Simplex.Chat.Types (GroupMemberRole (..))
|
||||
@@ -4321,7 +4321,7 @@ testGroupMsgForwardDeletion =
|
||||
|
||||
testGroupMsgForwardFile :: HasCallStack => FilePath -> IO ()
|
||||
testGroupMsgForwardFile =
|
||||
testChatCfg3 cfg aliceProfile bobProfile cathProfile $
|
||||
testChat3 aliceProfile bobProfile cathProfile $
|
||||
\alice bob cath -> withXFTPServer $ do
|
||||
setupGroupForwarding3 "team" alice bob cath
|
||||
|
||||
@@ -4343,8 +4343,6 @@ testGroupMsgForwardFile =
|
||||
src <- B.readFile "./tests/fixtures/test.jpg"
|
||||
dest <- B.readFile "./tests/tmp/test.jpg"
|
||||
dest `shouldBe` src
|
||||
where
|
||||
cfg = testCfg {xftpFileConfig = Just $ XFTPFileConfig {minFileSize = 0}, tempDir = Just "./tests/tmp"}
|
||||
|
||||
testGroupMsgForwardChangeRole :: HasCallStack => FilePath -> IO ()
|
||||
testGroupMsgForwardChangeRole =
|
||||
@@ -4577,7 +4575,7 @@ testGroupHistoryPreferenceOff =
|
||||
|
||||
testGroupHistoryHostFile :: HasCallStack => FilePath -> IO ()
|
||||
testGroupHistoryHostFile =
|
||||
testChatCfg3 cfg aliceProfile bobProfile cathProfile $
|
||||
testChat3 aliceProfile bobProfile cathProfile $
|
||||
\alice bob cath -> withXFTPServer $ do
|
||||
createGroup2 "team" alice bob
|
||||
|
||||
@@ -4613,12 +4611,10 @@ testGroupHistoryHostFile =
|
||||
src <- B.readFile "./tests/fixtures/test.jpg"
|
||||
dest <- B.readFile "./tests/tmp/test.jpg"
|
||||
dest `shouldBe` src
|
||||
where
|
||||
cfg = testCfg {xftpFileConfig = Just $ XFTPFileConfig {minFileSize = 0}, tempDir = Just "./tests/tmp"}
|
||||
|
||||
testGroupHistoryMemberFile :: HasCallStack => FilePath -> IO ()
|
||||
testGroupHistoryMemberFile =
|
||||
testChatCfg3 cfg aliceProfile bobProfile cathProfile $
|
||||
testChat3 aliceProfile bobProfile cathProfile $
|
||||
\alice bob cath -> withXFTPServer $ do
|
||||
createGroup2 "team" alice bob
|
||||
|
||||
@@ -4654,8 +4650,6 @@ testGroupHistoryMemberFile =
|
||||
src <- B.readFile "./tests/fixtures/test.jpg"
|
||||
dest <- B.readFile "./tests/tmp/test.jpg"
|
||||
dest `shouldBe` src
|
||||
where
|
||||
cfg = testCfg {xftpFileConfig = Just $ XFTPFileConfig {minFileSize = 0}, tempDir = Just "./tests/tmp"}
|
||||
|
||||
testGroupHistoryLargeFile :: HasCallStack => FilePath -> IO ()
|
||||
testGroupHistoryLargeFile =
|
||||
@@ -4713,11 +4707,11 @@ testGroupHistoryLargeFile =
|
||||
destCath <- B.readFile "./tests/tmp/testfile_2"
|
||||
destCath `shouldBe` src
|
||||
where
|
||||
cfg = testCfg {xftpDescrPartSize = 200, xftpFileConfig = Just $ XFTPFileConfig {minFileSize = 0}, tempDir = Just "./tests/tmp"}
|
||||
cfg = testCfg {xftpDescrPartSize = 200}
|
||||
|
||||
testGroupHistoryMultipleFiles :: HasCallStack => FilePath -> IO ()
|
||||
testGroupHistoryMultipleFiles =
|
||||
testChatCfg3 cfg aliceProfile bobProfile cathProfile $
|
||||
testChat3 aliceProfile bobProfile cathProfile $
|
||||
\alice bob cath -> withXFTPServer $ do
|
||||
xftpCLI ["rand", "./tests/tmp/testfile_bob", "2mb"] `shouldReturn` ["File created: " <> "./tests/tmp/testfile_bob"]
|
||||
xftpCLI ["rand", "./tests/tmp/testfile_alice", "1mb"] `shouldReturn` ["File created: " <> "./tests/tmp/testfile_alice"]
|
||||
@@ -4794,12 +4788,10 @@ testGroupHistoryMultipleFiles =
|
||||
`shouldContain` [ ((0, "hi alice"), Just "./tests/tmp/testfile_bob_1"),
|
||||
((0, "hey bob"), Just "./tests/tmp/testfile_alice_1")
|
||||
]
|
||||
where
|
||||
cfg = testCfg {xftpFileConfig = Just $ XFTPFileConfig {minFileSize = 0}, tempDir = Just "./tests/tmp"}
|
||||
|
||||
testGroupHistoryFileCancel :: HasCallStack => FilePath -> IO ()
|
||||
testGroupHistoryFileCancel =
|
||||
testChatCfg3 cfg aliceProfile bobProfile cathProfile $
|
||||
testChat3 aliceProfile bobProfile cathProfile $
|
||||
\alice bob cath -> withXFTPServer $ do
|
||||
xftpCLI ["rand", "./tests/tmp/testfile_bob", "2mb"] `shouldReturn` ["File created: " <> "./tests/tmp/testfile_bob"]
|
||||
xftpCLI ["rand", "./tests/tmp/testfile_alice", "1mb"] `shouldReturn` ["File created: " <> "./tests/tmp/testfile_alice"]
|
||||
@@ -4851,12 +4843,10 @@ testGroupHistoryFileCancel =
|
||||
bob <## "#team: alice added cath (Catherine) to the group (connecting...)"
|
||||
bob <## "#team: new member cath is connected"
|
||||
]
|
||||
where
|
||||
cfg = testCfg {xftpFileConfig = Just $ XFTPFileConfig {minFileSize = 0}, tempDir = Just "./tests/tmp"}
|
||||
|
||||
testGroupHistoryFileCancelNoText :: HasCallStack => FilePath -> IO ()
|
||||
testGroupHistoryFileCancelNoText =
|
||||
testChatCfg3 cfg aliceProfile bobProfile cathProfile $
|
||||
testChat3 aliceProfile bobProfile cathProfile $
|
||||
\alice bob cath -> withXFTPServer $ do
|
||||
xftpCLI ["rand", "./tests/tmp/testfile_bob", "2mb"] `shouldReturn` ["File created: " <> "./tests/tmp/testfile_bob"]
|
||||
xftpCLI ["rand", "./tests/tmp/testfile_alice", "1mb"] `shouldReturn` ["File created: " <> "./tests/tmp/testfile_alice"]
|
||||
@@ -4912,8 +4902,6 @@ testGroupHistoryFileCancelNoText =
|
||||
bob <## "#team: alice added cath (Catherine) to the group (connecting...)"
|
||||
bob <## "#team: new member cath is connected"
|
||||
]
|
||||
where
|
||||
cfg = testCfg {xftpFileConfig = Just $ XFTPFileConfig {minFileSize = 0}, tempDir = Just "./tests/tmp"}
|
||||
|
||||
testGroupHistoryQuotes :: HasCallStack => FilePath -> IO ()
|
||||
testGroupHistoryQuotes =
|
||||
|
||||
+13
-14
@@ -12,7 +12,6 @@ import Simplex.Chat.Controller (ChatConfig (..), InlineFilesConfig (..), default
|
||||
import System.Directory (copyFile, doesFileExist)
|
||||
import System.FilePath ((</>))
|
||||
import Test.Hspec hiding (it)
|
||||
import UnliftIO.Async (concurrently_)
|
||||
|
||||
chatLocalChatsTests :: SpecWith FilePath
|
||||
chatLocalChatsTests = do
|
||||
@@ -158,24 +157,24 @@ testFiles tmp = withNewTestChat tmp "alice" aliceProfile $ \alice -> do
|
||||
|
||||
testOtherFiles :: FilePath -> IO ()
|
||||
testOtherFiles =
|
||||
testChatCfg2 cfg aliceProfile bobProfile $ \alice bob -> do
|
||||
testChatCfg2 cfg aliceProfile bobProfile $ \alice bob -> withXFTPServer $ do
|
||||
connectUsers alice bob
|
||||
createCCNoteFolder bob
|
||||
bob ##> "/_files_folder ./tests/tmp/"
|
||||
bob <## "ok"
|
||||
alice ##> "/_send @2 json {\"msgContent\":{\"type\":\"voice\", \"duration\":10, \"text\":\"\"}, \"filePath\":\"./tests/fixtures/test.jpg\"}"
|
||||
alice <# "@bob voice message (00:10)"
|
||||
alice <# "/f @bob ./tests/fixtures/test.jpg"
|
||||
-- below is not shown in "sent" mode
|
||||
-- alice <## "use /fc 1 to cancel sending"
|
||||
bob <# "alice> voice message (00:10)"
|
||||
|
||||
alice #> "/f @bob ./tests/fixtures/test.jpg"
|
||||
alice <## "use /fc 1 to cancel sending"
|
||||
bob <# "alice> sends file test.jpg (136.5 KiB / 139737 bytes)"
|
||||
-- below is not shown in "sent" mode
|
||||
-- bob <## "use /fr 1 [<dir>/ | <path>] to receive it"
|
||||
bob <## "started receiving file 1 (test.jpg) from alice"
|
||||
concurrently_
|
||||
(alice <## "completed sending file 1 (test.jpg) to bob")
|
||||
(bob <## "completed receiving file 1 (test.jpg) from alice")
|
||||
bob <## "use /fr 1 [<dir>/ | <path>] to receive it"
|
||||
alice <## "completed uploading file 1 (test.jpg) for bob"
|
||||
|
||||
bob ##> "/fr 1"
|
||||
bob
|
||||
<### [ "saving file 1 from alice to test.jpg",
|
||||
"started receiving file 1 (test.jpg) from alice"
|
||||
]
|
||||
bob <## "completed receiving file 1 (test.jpg) from alice"
|
||||
|
||||
bob /* "test"
|
||||
bob ##> "/tail *"
|
||||
|
||||
@@ -1493,7 +1493,7 @@ testSetConnectionAlias = testChat2 aliceProfile bobProfile $
|
||||
|
||||
testSetContactPrefs :: HasCallStack => FilePath -> IO ()
|
||||
testSetContactPrefs = testChat2 aliceProfile bobProfile $
|
||||
\alice bob -> do
|
||||
\alice bob -> withXFTPServer $ do
|
||||
alice #$> ("/_files_folder ./tests/tmp/alice", id, "ok")
|
||||
bob #$> ("/_files_folder ./tests/tmp/bob", id, "ok")
|
||||
createDirectoryIfMissing True "./tests/tmp/alice"
|
||||
@@ -1528,15 +1528,24 @@ testSetContactPrefs = testChat2 aliceProfile bobProfile $
|
||||
bob #$> ("/_get chat @2 count=100", chat, startFeatures <> [(0, "Voice messages: enabled for you")])
|
||||
alice ##> sendVoice
|
||||
alice <## voiceNotAllowed
|
||||
|
||||
-- sending voice message allowed
|
||||
bob ##> sendVoice
|
||||
bob <# "@alice voice message (00:10)"
|
||||
bob <# "/f @alice test.txt"
|
||||
bob <## "completed sending file 1 (test.txt) to alice"
|
||||
bob <## "use /fc 1 to cancel sending"
|
||||
alice <# "bob> voice message (00:10)"
|
||||
alice <# "bob> sends file test.txt (11 bytes / 11 bytes)"
|
||||
alice <## "started receiving file 1 (test.txt) from bob"
|
||||
alice <## "use /fr 1 [<dir>/ | <path>] to receive it"
|
||||
bob <## "completed uploading file 1 (test.txt) for alice"
|
||||
alice ##> "/fr 1"
|
||||
alice
|
||||
<### [ "saving file 1 from bob to test_1.txt",
|
||||
"started receiving file 1 (test.txt) from bob"
|
||||
]
|
||||
alice <## "completed receiving file 1 (test.txt) from bob"
|
||||
(bob </)
|
||||
|
||||
-- alice ##> "/_profile 1 {\"displayName\": \"alice\", \"fullName\": \"Alice\", \"preferences\": {\"voice\": {\"allow\": \"no\"}}}"
|
||||
alice ##> "/set voice no"
|
||||
alice <## "updated preferences:"
|
||||
|
||||
@@ -19,7 +19,7 @@ import Data.Maybe (fromMaybe)
|
||||
import Data.String
|
||||
import qualified Data.Text as T
|
||||
import Database.SQLite.Simple (Only (..))
|
||||
import Simplex.Chat.Controller (ChatConfig (..), ChatController (..), InlineFilesConfig (..), defaultInlineFilesConfig)
|
||||
import Simplex.Chat.Controller (ChatConfig (..), ChatController (..))
|
||||
import Simplex.Chat.Protocol
|
||||
import Simplex.Chat.Store.NoteFolders (createNoteFolder)
|
||||
import Simplex.Chat.Store.Profiles (getUserContactProfiles)
|
||||
@@ -32,7 +32,6 @@ import Simplex.Messaging.Encoding.String
|
||||
import Simplex.Messaging.Version
|
||||
import System.Directory (doesFileExist)
|
||||
import System.Environment (lookupEnv, withArgs)
|
||||
import System.FilePath ((</>))
|
||||
import System.IO.Silently (capture_)
|
||||
import System.Info (os)
|
||||
import Test.Hspec hiding (it)
|
||||
@@ -96,29 +95,6 @@ versionTestMatrix3 runTest = do
|
||||
it "curr to prev" $ runTestCfg3 testCfgVPrev testCfg testCfg runTest
|
||||
it "curr+prev to prev" $ runTestCfg3 testCfgVPrev testCfg testCfgVPrev runTest
|
||||
|
||||
inlineCfg :: Integer -> ChatConfig
|
||||
inlineCfg n = testCfg {inlineFiles = defaultInlineFilesConfig {sendChunks = 0, offerChunks = n, receiveChunks = n}}
|
||||
|
||||
fileTestMatrix2 :: (HasCallStack => TestCC -> TestCC -> IO ()) -> SpecWith FilePath
|
||||
fileTestMatrix2 runTest = do
|
||||
it "via connection" $ runTestCfg2 viaConn viaConn runTest
|
||||
it "inline (accepting)" $ runTestCfg2 inline inline runTest
|
||||
it "via connection (inline offered)" $ runTestCfg2 inline viaConn runTest
|
||||
it "via connection (inline supported)" $ runTestCfg2 viaConn inline runTest
|
||||
where
|
||||
inline = inlineCfg 100
|
||||
viaConn = inlineCfg 0
|
||||
|
||||
fileTestMatrix3 :: (HasCallStack => TestCC -> TestCC -> TestCC -> IO ()) -> SpecWith FilePath
|
||||
fileTestMatrix3 runTest = do
|
||||
it "via connection" $ runTestCfg3 viaConn viaConn viaConn runTest
|
||||
it "inline" $ runTestCfg3 inline inline inline runTest
|
||||
it "via connection (inline offered)" $ runTestCfg3 inline viaConn viaConn runTest
|
||||
it "via connection (inline supported)" $ runTestCfg3 viaConn inline inline runTest
|
||||
where
|
||||
inline = inlineCfg 100
|
||||
viaConn = inlineCfg 0
|
||||
|
||||
runTestCfg2 :: ChatConfig -> ChatConfig -> (HasCallStack => TestCC -> TestCC -> IO ()) -> FilePath -> IO ()
|
||||
runTestCfg2 aliceCfg bobCfg runTest tmp =
|
||||
withNewTestChatCfg tmp aliceCfg "alice" aliceProfile $ \alice ->
|
||||
@@ -595,20 +571,6 @@ checkActionDeletesFile file action = do
|
||||
fileExistsAfter <- doesFileExist file
|
||||
fileExistsAfter `shouldBe` False
|
||||
|
||||
startFileTransferWithDest' :: HasCallStack => TestCC -> TestCC -> String -> String -> Maybe String -> IO ()
|
||||
startFileTransferWithDest' cc1 cc2 fileName fileSize fileDest_ = do
|
||||
name1 <- userName cc1
|
||||
name2 <- userName cc2
|
||||
cc1 #> ("/f @" <> name2 <> " ./tests/fixtures/" <> fileName)
|
||||
cc1 <## "use /fc 1 to cancel sending"
|
||||
cc2 <# (name1 <> "> sends file " <> fileName <> " (" <> fileSize <> ")")
|
||||
cc2 <## "use /fr 1 [<dir>/ | <path>] to receive it"
|
||||
cc2 ##> ("/fr 1" <> maybe "" (" " <>) fileDest_)
|
||||
cc2 <## ("saving file 1 from " <> name1 <> " to " <> maybe id (</>) fileDest_ fileName)
|
||||
concurrently_
|
||||
(cc2 <## ("started receiving file 1 (" <> fileName <> ") from " <> name1))
|
||||
(cc1 <## ("started sending file 1 (" <> fileName <> ") to " <> name2))
|
||||
|
||||
currentChatVRangeInfo :: String
|
||||
currentChatVRangeInfo =
|
||||
"peer chat protocol version range: " <> vRangeStr supportedChatVRange
|
||||
|
||||
Reference in New Issue
Block a user