From 58d76c6e865b6e66760eff539c0cacdca2b2f785 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Thu, 4 Jun 2026 18:32:19 +0400 Subject: [PATCH] wip --- src/Simplex/Chat/Store/Groups.hs | 15 --------------- tests/ChatTests/Groups.hs | 12 ++++++++---- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/Simplex/Chat/Store/Groups.hs b/src/Simplex/Chat/Store/Groups.hs index e744b87114..92b93a80e8 100644 --- a/src/Simplex/Chat/Store/Groups.hs +++ b/src/Simplex/Chat/Store/Groups.hs @@ -87,7 +87,6 @@ module Simplex.Chat.Store.Groups getGroupRelays, getConnectedGroupRelays, setGroupRosterVersion, - setGroupRoster, getGroupRoster, getRosterBlob, setRosterPending, @@ -1417,20 +1416,6 @@ setGroupRosterVersion db GroupInfo {groupId} v = do currentTs <- getCurrentTime DB.execute db "UPDATE groups SET roster_version = ?, updated_at = ? WHERE group_id = ?" (v, currentTs, groupId) --- Relay saves the verbatim signed roster (parts + sending owner + broker ts) to re-forward to joiners. -setGroupRoster :: DB.Connection -> GroupInfo -> VersionRoster -> GroupMemberId -> UTCTime -> SignedMsg -> IO () -setGroupRoster db GroupInfo {groupId} v ownerGMId brokerTs SignedMsg {chatBinding, signatures, signedBody} = do - currentTs <- getCurrentTime - DB.execute - db - [sql| - UPDATE groups - SET roster_version = ?, roster_sending_owner_gm_id = ?, roster_broker_ts = ?, - roster_msg_chat_binding = ?, roster_msg_signatures = ?, roster_msg_body = ?, updated_at = ? - WHERE group_id = ? - |] - ((v, ownerGMId, brokerTs, chatBinding) :. (Binary (smpEncode signatures), Binary signedBody, currentTs, groupId)) - getGroupRoster :: DB.Connection -> GroupInfo -> IO (Maybe (GroupMemberId, UTCTime, SignedMsg)) getGroupRoster db GroupInfo {groupId} = (>>= toRoster) diff --git a/tests/ChatTests/Groups.hs b/tests/ChatTests/Groups.hs index 0ff1e49daf..04b9e81b3a 100644 --- a/tests/ChatTests/Groups.hs +++ b/tests/ChatTests/Groups.hs @@ -10454,13 +10454,17 @@ testChannelRosterDigestMismatchRejected ps = threadDelay 100000 memberJoinChannel "team" [bob] [alice, cath] shortLink fullLink frank threadDelay 100000 - checkRosterVersionBelow frank 1 + checkRosterNotApplied frank where - checkRosterVersionBelow :: HasCallStack => TestCC -> Int64 -> IO () - checkRosterVersionBelow cc target = do + -- frank learns cath via the moderator introduction (XGrpMemIntro) regardless of the roster, + -- so checkMemberRow cannot distinguish applied vs rejected. The roster's authoritative effect + -- is its version: it must NOT advance to the corrupted roster's version 1, and frank must + -- actually hold the group (non-vacuous) so a NULL roster_version cannot pass by emptiness. + checkRosterNotApplied :: HasCallStack => TestCC -> IO () + checkRosterNotApplied cc = do vs <- withCCTransaction cc $ \db -> DB.query_ db "SELECT roster_version FROM groups" :: IO [Only (Maybe Int64)] - all (< target) [v | Only (Just v) <- vs] `shouldBe` True + map (\(Only v) -> v) vs `shouldSatisfy` (\versions -> not (null versions) && Just 1 `notElem` versions) testChannelRemoveRelay :: HasCallStack => TestParams -> IO () testChannelRemoveRelay ps =