From 86937931cba28d5395942490080cbc8ec96bb5c2 Mon Sep 17 00:00:00 2001 From: "Evgeny @ SimpleX Chat" <259188159+evgeny-simplex@users.noreply.github.com> Date: Thu, 24 Sep 2026 20:42:21 +0000 Subject: [PATCH] fix tests --- tests/ChatClient.hs | 4 ++-- tests/ChatTests/Utils.hs | 13 ++++++++----- tests/Test.hs | 11 +---------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/tests/ChatClient.hs b/tests/ChatClient.hs index d1c83ddc39..3d2e84035c 100644 --- a/tests/ChatClient.hs +++ b/tests/ChatClient.hs @@ -540,7 +540,7 @@ getTermLine = getTermLine' Nothing getTermLine' :: HasCallStack => Maybe String -> TestCC -> IO String getTermLine' expected cc@TestCC {printOutput} = - 5000000 `timeout` atomically (readTQueue $ termQ cc) >>= \case + 20000000 `timeout` atomically (readTQueue $ termQ cc) >>= \case Just s -> do -- remove condition to always echo virtual terminal -- when True $ do @@ -553,7 +553,7 @@ getTermLine' expected cc@TestCC {printOutput} = let expectedMsg = case expected of Just e -> ", expected: " <> show e Nothing -> "" - error $ name <> ": no output for 5 seconds" <> expectedMsg + error $ name <> ": no output for 20 seconds" <> expectedMsg userName :: TestCC -> IO [Char] userName TestCC {chatController = ChatController {currentUser}} = diff --git a/tests/ChatTests/Utils.hs b/tests/ChatTests/Utils.hs index 1dd552055e..a7687a8dfd 100644 --- a/tests/ChatTests/Utils.hs +++ b/tests/ChatTests/Utils.hs @@ -34,6 +34,7 @@ import Simplex.Chat.Store.Profiles (getUserContactProfiles) import Simplex.Chat.Types import Simplex.Chat.Types.Preferences import Simplex.Chat.Types.Shared +import Simplex.FileTransfer.Description (FileSize (..)) import Simplex.Messaging.Agent.Client (agentClientStore) import Simplex.Messaging.Agent.Store.AgentStore (maybeFirstRow, withTransaction) import qualified Simplex.Messaging.Agent.Store.DB as DB @@ -42,9 +43,8 @@ import Simplex.Messaging.Crypto.Ratchet (PQEncryption (..), PQSupport, pattern P import Simplex.Messaging.Encoding.String import Simplex.Messaging.Version import System.Directory (doesFileExist) -import System.Environment (getExecutablePath, lookupEnv) +import System.Environment (lookupEnv) import System.Info (os) -import System.Process (readProcess) import Test.Hspec hiding (it) import qualified Test.Hspec as Hspec import UnliftIO (timeout) @@ -889,9 +889,12 @@ linkAnotherSchema link | otherwise = error "link starts with neither https://simplex.chat/ nor simplex:/" xftpCLI :: [String] -> IO [String] -xftpCLI params = do - exe <- getExecutablePath - lines <$> readProcess exe ("xftp-cli" : params) "" +xftpCLI = \case + ["rand", path, size] -> do + let FileSize n = fromString size :: FileSize Int + B.writeFile path =<< atomically . C.randomBytes n =<< C.newRandom + pure ["File created: " <> path] + params -> error $ "unsupported xftp CLI command: " <> unwords params setRelativePaths :: HasCallStack => TestCC -> String -> String -> IO () setRelativePaths cc filesFolder tempFolder = do diff --git a/tests/Test.hs b/tests/Test.hs index 96b2c4efd4..bb5749b3f5 100644 --- a/tests/Test.hs +++ b/tests/Test.hs @@ -1,6 +1,5 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DuplicateRecordFields #-} -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE TupleSections #-} @@ -23,8 +22,6 @@ import ProtocolTests import OperatorTests import RandomServers import RemoteTests -import Simplex.FileTransfer.Client.Main (xftpClientCLI) -import System.Environment (getArgs, withArgs) import Test.Hspec hiding (it) import UnliftIO.Temporary (withTempDirectory) import ValidNames @@ -43,13 +40,7 @@ import WebRTCTests #endif main :: IO () -main = - getArgs >>= \case - "xftp-cli" : params -> withArgs params xftpClientCLI - _ -> runTests - -runTests :: IO () -runTests = do +main = do setLogLevel LogError #if !defined(dbPostgres) chatQueryStats <- TM.emptyIO