From 18496c3269f3ee35c59e8774f09202f244f4dd3a Mon Sep 17 00:00:00 2001 From: IC Rainbow Date: Sun, 29 Oct 2023 16:21:09 +0200 Subject: [PATCH] Add iOS smoke test at createAgentStore --- src/Simplex/Messaging/Agent/Env/SQLite.hs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Simplex/Messaging/Agent/Env/SQLite.hs b/src/Simplex/Messaging/Agent/Env/SQLite.hs index 3a818f250..92ac86c9a 100644 --- a/src/Simplex/Messaging/Agent/Env/SQLite.hs +++ b/src/Simplex/Messaging/Agent/Env/SQLite.hs @@ -30,6 +30,10 @@ module Simplex.Messaging.Agent.Env.SQLite ) where +-- iOS FunPtr smoke test +import Simplex.Messaging.Crypto.SNTRUP761.Bindings +import Simplex.Messaging.Crypto.SNTRUP761.Bindings.RNG + import Control.Monad.Except import Control.Monad.IO.Unlift import Control.Monad.Reader @@ -195,7 +199,18 @@ newSMPAgentEnv config@AgentConfig {initialClientId} store = do pure Env {config, store, idsDrg, clientCounter, randomServer, ntfSupervisor, xftpAgent} createAgentStore :: FilePath -> String -> MigrationConfirmation -> IO (Either MigrationError SQLiteStore) -createAgentStore dbFilePath dbKey = createSQLiteStore dbFilePath dbKey Migrations.app +createAgentStore dbFilePath dbKey cfg = do + withHaskellRNG $ \rng -> do + (pk, sk) <- sntrup761KeypairWith rng + (c, k) <- sntrup761EncWith rng pk + k' <- sntrup761Dec c sk + if k /= k' then + fail "sntrup761 smoke test failed" + else + putStrLn "sntrup761 smoke test passed" + + createSQLiteStore dbFilePath dbKey Migrations.app cfg + data NtfSupervisor = NtfSupervisor { ntfTkn :: TVar (Maybe NtfToken),