diff --git a/src/Simplex/Messaging/Agent/Store/SQLite.hs b/src/Simplex/Messaging/Agent/Store/SQLite.hs index d7e8ec586..99b53d43e 100644 --- a/src/Simplex/Messaging/Agent/Store/SQLite.hs +++ b/src/Simplex/Messaging/Agent/Store/SQLite.hs @@ -294,6 +294,7 @@ instance MonadUnliftIO m => MonadAgentStore SQLiteStore m where >>= return . fmap (SomeConn SCSend . SendConnection connAlias) Right (_, _) -> return $ Left SEBadConn + -- TODO make transactional addSndQueue :: SQLiteStore -> ConnAlias -> SendQueue -> m (Either StoreError (Connection CDuplex)) addSndQueue st connAlias sndQueue = do serverId <- upsertServer st (server (sndQueue :: SendQueue)) diff --git a/tests/AgentTests/SQLite.hs b/tests/AgentTests/SQLite.hs index bcde13419..5bd701fb9 100644 --- a/tests/AgentTests/SQLite.hs +++ b/tests/AgentTests/SQLite.hs @@ -27,7 +27,7 @@ storeTests = withStore do testCreateRcvConn :: SpecWith SQLiteStore testCreateRcvConn = do - it "should create and get receive connection" $ \store -> do + it "should create receive connection and add send queue" $ \store -> do let rcvQueue = ReceiveQueue { server = SMPServer "smp.simplex.im" (Just "5223") (Just "1234"), @@ -44,6 +44,20 @@ testCreateRcvConn = do `shouldReturn` Right (ReceiveConnection "1" rcvQueue) getConn store "1" `shouldReturn` Right (SomeConn SCReceive $ ReceiveConnection "1" rcvQueue) + let sndQueue = + SendQueue + { server = SMPServer "smp.simplex.im" (Just "5223") (Just "1234"), + sndId = "1234", + sndPrivateKey = "abcd", + encryptKey = "dcba", + signKey = "edcb", + status = New, + ackMode = AckMode On + } + addSndQueue store "1" sndQueue + `shouldReturn` Right (DuplexConnection "1" rcvQueue sndQueue) + getConn store "1" + `shouldReturn` Right (SomeConn SCDuplex $ DuplexConnection "1" rcvQueue sndQueue) testCreateSndConn :: SpecWith SQLiteStore testCreateSndConn = do diff --git a/tests/Test.hs b/tests/Test.hs index 3b2e915c8..6404e5ca8 100644 --- a/tests/Test.hs +++ b/tests/Test.hs @@ -6,5 +6,5 @@ import Test.Hspec main :: IO () main = hspec do - describe "SMP server" serverTests + -- describe "SMP server" serverTests describe "SMP client agent" agentTests