From f2568b65c0306b351bd38a1f09f4363d02e2d3e9 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Sat, 28 Dec 2024 20:00:44 +0000 Subject: [PATCH] use option in test --- src/Simplex/Chat/Core.hs | 4 ++-- src/Simplex/Chat/Mobile.hs | 4 ++-- src/Simplex/Chat/Options.hs | 4 ++-- tests/ChatClient.hs | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Simplex/Chat/Core.hs b/src/Simplex/Chat/Core.hs index 24c5812f7e..8e40469d84 100644 --- a/src/Simplex/Chat/Core.hs +++ b/src/Simplex/Chat/Core.hs @@ -34,14 +34,14 @@ import Text.Read (readMaybe) import UnliftIO.Async simplexChatCore :: ChatConfig -> ChatOpts -> (User -> ChatController -> IO ()) -> IO () -simplexChatCore cfg@ChatConfig {confirmMigrations, testView} opts@ChatOpts {coreOptions = CoreChatOpts {dbFilePrefix, dbKey, logAgent, yesToUpMigrations, vaccumOnMigration}} chat = +simplexChatCore cfg@ChatConfig {confirmMigrations, testView} opts@ChatOpts {coreOptions = CoreChatOpts {dbFilePrefix, dbKey, logAgent, yesToUpMigrations, vacuumOnMigration}} chat = case logAgent of Just level -> do setLogLevel level withGlobalLogging logCfg initRun _ -> initRun where - initRun = createChatDatabase dbFilePrefix dbKey False confirm' vaccumOnMigration >>= either exit run + initRun = createChatDatabase dbFilePrefix dbKey False confirm' vacuumOnMigration >>= either exit run confirm' = if confirmMigrations == MCConsole && yesToUpMigrations then MCYesUp else confirmMigrations exit e = do putStrLn $ "Error opening database: " <> show e diff --git a/src/Simplex/Chat/Mobile.hs b/src/Simplex/Chat/Mobile.hs index bc2cb894ed..f8b044676a 100644 --- a/src/Simplex/Chat/Mobile.hs +++ b/src/Simplex/Chat/Mobile.hs @@ -202,7 +202,7 @@ mobileChatOpts dbFilePrefix = tbqSize = 1024, highlyAvailable = False, yesToUpMigrations = False, - vaccumOnMigration = True + vacuumOnMigration = True }, deviceName = Nothing, chatCmd = "", @@ -247,7 +247,7 @@ chatMigrateInitKey dbFilePrefix dbKey keepKey confirm backgroundMode = runExcept newChatController db user_ defaultMobileConfig opts backgroundMode migrate createStore dbFile confirmMigrations = ExceptT $ - (first (DBMErrorMigration dbFile) <$> createStore dbFile dbKey keepKey confirmMigrations (vaccumOnMigration $ coreOptions opts)) + (first (DBMErrorMigration dbFile) <$> createStore dbFile dbKey keepKey confirmMigrations (vacuumOnMigration $ coreOptions opts)) `catch` (pure . checkDBError) `catchAll` (pure . dbError) where diff --git a/src/Simplex/Chat/Options.hs b/src/Simplex/Chat/Options.hs index 367efce5a7..e034bd03f0 100644 --- a/src/Simplex/Chat/Options.hs +++ b/src/Simplex/Chat/Options.hs @@ -67,7 +67,7 @@ data CoreChatOpts = CoreChatOpts tbqSize :: Natural, highlyAvailable :: Bool, yesToUpMigrations :: Bool, - vaccumOnMigration :: Bool + vacuumOnMigration :: Bool } data ChatCmdLog = CCLAll | CCLMessages | CCLNone @@ -272,7 +272,7 @@ coreChatOptsP appDir defaultDbFileName = do tbqSize, highlyAvailable, yesToUpMigrations, - vaccumOnMigration = not disableVacuum + vacuumOnMigration = not disableVacuum } where useTcpTimeout p t = 1000000 * if t > 0 then t else maybe 7 (const 15) p diff --git a/tests/ChatClient.hs b/tests/ChatClient.hs index 5070dd615a..42f139f05d 100644 --- a/tests/ChatClient.hs +++ b/tests/ChatClient.hs @@ -107,7 +107,7 @@ testCoreOpts = tbqSize = 16, highlyAvailable = False, yesToUpMigrations = False, - vaccumOnMigration = True + vacuumOnMigration = True } getTestOpts :: Bool -> ScrubbedBytes -> ChatOpts @@ -248,15 +248,15 @@ groupLinkViaContactVRange :: VersionRangeChat groupLinkViaContactVRange = mkVersionRange (VersionChat 1) (VersionChat 2) createTestChat :: FilePath -> ChatConfig -> ChatOpts -> String -> Profile -> IO TestCC -createTestChat tmp cfg opts@ChatOpts {coreOptions = CoreChatOpts {dbKey}} dbPrefix profile = do - Right db@ChatDatabase {chatStore, agentStore} <- createChatDatabase (tmp dbPrefix) dbKey False MCError True +createTestChat tmp cfg opts@ChatOpts {coreOptions = CoreChatOpts {dbKey, vacuumOnMigration}} dbPrefix profile = do + Right db@ChatDatabase {chatStore, agentStore} <- createChatDatabase (tmp dbPrefix) dbKey False MCError vacuumOnMigration withTransaction agentStore (`DB.execute_` "INSERT INTO users (user_id) VALUES (1);") Right user <- withTransaction chatStore $ \db' -> runExceptT $ createUserRecord db' (AgentUserId 1) profile True startTestChat_ db cfg opts user startTestChat :: FilePath -> ChatConfig -> ChatOpts -> String -> IO TestCC -startTestChat tmp cfg opts@ChatOpts {coreOptions = CoreChatOpts {dbKey}} dbPrefix = do - Right db@ChatDatabase {chatStore} <- createChatDatabase (tmp dbPrefix) dbKey False MCError True +startTestChat tmp cfg opts@ChatOpts {coreOptions = CoreChatOpts {dbKey, vacuumOnMigration}} dbPrefix = do + Right db@ChatDatabase {chatStore} <- createChatDatabase (tmp dbPrefix) dbKey False MCError vacuumOnMigration Just user <- find activeUser <$> withTransaction chatStore getUsers startTestChat_ db cfg opts user