From c8ea87367417c09feea78c439f768b7dc8eae5d1 Mon Sep 17 00:00:00 2001 From: shum Date: Thu, 22 Oct 2026 00:04:04 +0000 Subject: [PATCH 1/3] tests: import for both database flavours --- tests/ChatTests/Direct.hs | 2 +- tests/ChatTests/Groups.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/ChatTests/Direct.hs b/tests/ChatTests/Direct.hs index 930a0fa22d..81753beaa3 100644 --- a/tests/ChatTests/Direct.hs +++ b/tests/ChatTests/Direct.hs @@ -46,6 +46,7 @@ import Simplex.Messaging.Transport import Simplex.Messaging.Util (safeDecodeUtf8) import Simplex.Messaging.Version import System.Directory (copyFile, doesDirectoryExist, doesFileExist) +import System.FilePath (()) import System.Mem.Weak (deRefWeak) import Test.Hspec hiding (it) #if defined(dbPostgres) @@ -53,7 +54,6 @@ import Database.PostgreSQL.Simple (Only (..)) #else import Database.SQLite.Simple (Only (..)) import Simplex.Chat.Options.DB -import System.FilePath (()) #endif chatDirectTests :: SpecWith TestParams diff --git a/tests/ChatTests/Groups.hs b/tests/ChatTests/Groups.hs index d319d50bf1..a127b160f5 100644 --- a/tests/ChatTests/Groups.hs +++ b/tests/ChatTests/Groups.hs @@ -58,6 +58,7 @@ import Simplex.Messaging.Server.Env.STM hiding (subscriptions) import Simplex.Messaging.Transport import Simplex.Messaging.Version import System.Directory (copyFile, doesFileExist) +import System.FilePath (()) import Test.Hspec hiding (it) #if defined(dbPostgres) import Database.PostgreSQL.Simple (Only (..)) @@ -66,7 +67,6 @@ import Database.PostgreSQL.Simple.SqlQQ (sql) import Database.SQLite.Simple (Only (..)) import Database.SQLite.Simple.QQ (sql) import Simplex.Chat.Options.DB -import System.FilePath (()) #endif chatGroupTests :: SpecWith TestParams From 358f3f85b127ceb05072bebe33a520b66a1cc846 Mon Sep 17 00:00:00 2001 From: shum Date: Thu, 22 Oct 2026 00:24:47 +0000 Subject: [PATCH 2/3] store: space joined SQL fragments for Postgres --- apps/simplex-store-service/src/StoreService/Names/Store.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/simplex-store-service/src/StoreService/Names/Store.hs b/apps/simplex-store-service/src/StoreService/Names/Store.hs index 6d8799bb05..362c801ff3 100644 --- a/apps/simplex-store-service/src/StoreService/Names/Store.hs +++ b/apps/simplex-store-service/src/StoreService/Names/Store.hs @@ -401,7 +401,8 @@ registrationColumns = registrationFrom :: Query registrationFrom = - [sql| + " " + <> [sql| FROM sx_badge_service_name_registrations r LEFT JOIN sx_badge_service_name_invoices ni ON ni.registration_id = r.registration_id |] From 5cdeef4b118c7ec533383bb053be460b1c12b576 Mon Sep 17 00:00:00 2001 From: shum Date: Thu, 22 Oct 2026 01:07:51 +0000 Subject: [PATCH 3/3] tests: await bot replies on the member console --- tests/Bots/StoreService/GroupIntegrationTests.hs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/Bots/StoreService/GroupIntegrationTests.hs b/tests/Bots/StoreService/GroupIntegrationTests.hs index 0f31f1deb0..2a7136666d 100644 --- a/tests/Bots/StoreService/GroupIntegrationTests.hs +++ b/tests/Bots/StoreService/GroupIntegrationTests.hs @@ -155,6 +155,7 @@ revokeInGroup :: HasCallStack => ChatController -> TestCC -> Text -> Text -> IO revokeInGroup cc member code outcome = do sendGroupCmd member (revokeCmd code) waitStoredItem cc (revokeReply code outcome) + awaitOnConsole member (revokeReply code outcome) -- The name is quoted because console output quotes a name with a space. botName :: String @@ -537,6 +538,7 @@ testBlockedMemberCommandIgnored ps = do deleted `shouldBe` blockedByAdminMark content `shouldSatisfy` T.isInfixOf "/bulk legend months 255 count 100" ownerIssuesNext cc alice 1 + awaitOnConsole alice "Code: SB-" -- The lane is a single FIFO drainer, so the owner's next code proves every earlier command was handled. ownerIssuesNext :: HasCallStack => ChatController -> TestCC -> Int -> IO () @@ -555,6 +557,7 @@ testSupportScopeIgnored ps = send alice "/_send #1(_support) text /issue legend" waitStoredItem cc "/issue legend" ownerIssuesNext cc alice 1 + awaitOnConsole alice "Code: SB-" testLiveMessageIgnored :: HasCallStack => TestParams -> IO () testLiveMessageIgnored ps = @@ -562,6 +565,7 @@ testLiveMessageIgnored ps = send alice ("/live #" <> groupName <> " /issue legend") waitStoredItem cc "/issue legend" ownerIssuesNext cc alice 1 + awaitOnConsole alice "Code: SB-" testOtherGroupEventIgnored :: HasCallStack => TestParams -> IO () testOtherGroupEventIgnored ps = do @@ -591,6 +595,7 @@ testIssueMonths ps = withGroupOwner ps $ \_ cc _ alice -> do sendGroupCmd alice "/issue legend months 12" waitCodeMonths cc "legend" `shouldReturn` 12 + awaitOnConsole alice "Code: SB-" freeCodeCount cc `shouldReturn` 1 testBulkPartialFailureListsIssued :: HasCallStack => TestParams -> IO () @@ -849,6 +854,7 @@ testGroupRevokeRepairsTracker ps = retired <- waitItemText cc trackerItemId "Revoked" retired `shouldBe` retiredText code waitStoredItem cc (revokeReply code "Already revoked.") + awaitOnConsole alice (revokeReply code "Already revoked.") revokedTrackerCount cc `shouldReturn` 1 testRevokeRepeatPastWindow :: HasCallStack => TestParams -> IO () @@ -1336,7 +1342,14 @@ replyTo :: HasCallStack => ChatController -> TestCC -> String -> IO Text replyTo cc member cmd = do lastId <- maxChatItemId cc sendGroupCmd member cmd - waitReceivedItemId cc lastId (T.pack cmd) >>= waitReplyAfter cc + reply <- waitReceivedItemId cc lastId (T.pack cmd) >>= waitReplyAfter cc + awaitOnConsole member reply + pure reply + +-- A line left unread when the test ends fails the per-core teardown check, however late the bot's reply arrives. +awaitOnConsole :: HasCallStack => TestCC -> Text -> IO () +awaitOnConsole member reply = + drainUntil member ["#" <> groupName <> " " <> botName <> "> " <> T.unpack (T.takeWhile (/= '\n') reply)] maxChatItemId :: ChatController -> IO Int64 maxChatItemId cc = fromMaybe 0 <$> queryFirst cc "SELECT COALESCE(MAX(chat_item_id), 0) FROM chat_items"