From 4079160ed2db3f49f64b32470a35f385deae4707 Mon Sep 17 00:00:00 2001 From: SionoiS Date: Mon, 18 Mar 2024 09:51:28 -0400 Subject: [PATCH] Fix test cursor and ordering --- tests/node/test_wakunode_store.nim | 815 +++++++++++++++++++---------- 1 file changed, 536 insertions(+), 279 deletions(-) diff --git a/tests/node/test_wakunode_store.nim b/tests/node/test_wakunode_store.nim index e6cea171aa..58bd67a7d7 100644 --- a/tests/node/test_wakunode_store.nim +++ b/tests/node/test_wakunode_store.nim @@ -1,7 +1,7 @@ {.used.} import - std/options, + std/[options, sequtils, algorithm], stew/shims/net as stewNet, testutils/unittests, chronos, @@ -13,6 +13,7 @@ import node/waku_node, node/peer_manager, waku_core, + waku_core/message/digest, waku_store, waku_store/client, waku_archive, @@ -28,8 +29,8 @@ suite "Waku Store - End to End - Sorted Archive": var contentTopic {.threadvar.}: ContentTopic var contentTopicSeq {.threadvar.}: seq[ContentTopic] - var archiveMessages {.threadvar.}: seq[WakuMessage] - var historyQuery {.threadvar.}: HistoryQuery + var archiveMessages {.threadvar.}: seq[WakuMessageKeyValue] + var storeQuery {.threadvar.}: StoreQueryRequest var server {.threadvar.}: WakuNode var client {.threadvar.}: WakuNode @@ -44,7 +45,7 @@ suite "Waku Store - End to End - Sorted Archive": contentTopicSeq = @[contentTopic] let timeOrigin = now() - archiveMessages = + let messages = @[ fakeWakuMessage(@[byte 00], ts = ts(00, timeOrigin)), fakeWakuMessage(@[byte 01], ts = ts(10, timeOrigin)), @@ -57,13 +58,20 @@ suite "Waku Store - End to End - Sorted Archive": fakeWakuMessage(@[byte 08], ts = ts(80, timeOrigin)), fakeWakuMessage(@[byte 09], ts = ts(90, timeOrigin)), ] - - historyQuery = HistoryQuery( - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.Forward, - pageSize: 5, - ) + archiveMessages = + messages.mapIt( + WakuMessageKeyValue( + messageHash: computeMessageHash(pubsubTopic, it), + message: it, + )) + + storeQuery = + StoreQueryRequest( + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.Forward, + paginationLimit: some(uint64(5)), + ) let serverKey = generateSecp256k1Key() @@ -72,7 +80,7 @@ suite "Waku Store - End to End - Sorted Archive": server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - archiveDriver = newArchiveDriverWithMessages(pubsubTopic, archiveMessages) + archiveDriver = newArchiveDriverWithMessages(pubsubTopic, messages) let mountArchiveResult = server.mountArchive(archiveDriver) assert mountArchiveResult.isOk() @@ -90,20 +98,22 @@ suite "Waku Store - End to End - Sorted Archive": suite "Message Pagination": asyncTest "Forward Pagination": # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: queryResponse.get().messages == archiveMessages[0 ..< 5] # Given the next query - var otherHistoryQuery = HistoryQuery( - cursor: queryResponse.get().cursor, - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 5, - ) + var + otherHistoryQuery = + StoreQueryRequest( + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationCursor: queryResponse.get().paginationCursor, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(5)), + ) # When making the next history query let otherQueryResponse = @@ -115,23 +125,25 @@ suite "Waku Store - End to End - Sorted Archive": asyncTest "Backward Pagination": # Given the history query is backward - historyQuery.direction = PagingDirection.BACKWARD + storeQuery.paginationForward = PagingDirection.BACKWARD # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: queryResponse.get().messages == archiveMessages[5 ..< 10] # Given the next query - var nextHistoryQuery = HistoryQuery( - cursor: queryResponse.get().cursor, - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.BACKWARD, - pageSize: 5, - ) + var + nextHistoryQuery = + StoreQueryRequest( + paginationCursor: queryResponse.get().paginationCursor, + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.BACKWARD, + paginationLimit: some(uint64(5)), + ) # When making the next history query let otherQueryResponse = @@ -144,23 +156,25 @@ suite "Waku Store - End to End - Sorted Archive": suite "Pagination with Differente Page Sizes": asyncTest "Pagination with Small Page Size": # Given the first query (1/5) - historyQuery.pageSize = 2 + storeQuery.paginationLimit = some(uint64(2)) # When making a history query - let queryResponse1 = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse1 = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: queryResponse1.get().messages == archiveMessages[0 ..< 2] # Given the next query (2/5) - let historyQuery2 = HistoryQuery( - cursor: queryResponse1.get().cursor, - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 2, - ) + let + historyQuery2 = + StoreQueryRequest( + paginationCursor: queryResponse1.get().paginationCursor, + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(2)), + ) # When making the next history query let queryResponse2 = await client.query(historyQuery2, serverRemotePeerInfo) @@ -170,13 +184,15 @@ suite "Waku Store - End to End - Sorted Archive": queryResponse2.get().messages == archiveMessages[2 ..< 4] # Given the next query (3/5) - let historyQuery3 = HistoryQuery( - cursor: queryResponse2.get().cursor, - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 2, - ) + let + historyQuery3 = + StoreQueryRequest( + paginationCursor: queryResponse2.get().paginationCursor, + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(2)), + ) # When making the next history query let queryResponse3 = await client.query(historyQuery3, serverRemotePeerInfo) @@ -186,13 +202,15 @@ suite "Waku Store - End to End - Sorted Archive": queryResponse3.get().messages == archiveMessages[4 ..< 6] # Given the next query (4/5) - let historyQuery4 = HistoryQuery( - cursor: queryResponse3.get().cursor, - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 2, - ) + let + historyQuery4 = + StoreQueryRequest( + paginationCursor: queryResponse3.get().paginationCursor, + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(2)), + ) # When making the next history query let queryResponse4 = await client.query(historyQuery4, serverRemotePeerInfo) @@ -202,13 +220,15 @@ suite "Waku Store - End to End - Sorted Archive": queryResponse4.get().messages == archiveMessages[6 ..< 8] # Given the next query (5/5) - let historyQuery5 = HistoryQuery( - cursor: queryResponse4.get().cursor, - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 2, - ) + let + historyQuery5 = + StoreQueryRequest( + paginationCursor: queryResponse4.get().paginationCursor, + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(2)), + ) # When making the next history query let queryResponse5 = await client.query(historyQuery5, serverRemotePeerInfo) @@ -219,23 +239,25 @@ suite "Waku Store - End to End - Sorted Archive": asyncTest "Pagination with Large Page Size": # Given the first query (1/2) - historyQuery.pageSize = 8 + storeQuery.paginationLimit = some(uint64(8)) # When making a history query - let queryResponse1 = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse1 = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: queryResponse1.get().messages == archiveMessages[0 ..< 8] # Given the next query (2/2) - let historyQuery2 = HistoryQuery( - cursor: queryResponse1.get().cursor, - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 8, - ) + let + historyQuery2 = + StoreQueryRequest( + paginationCursor: queryResponse1.get().paginationCursor, + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(8)), + ) # When making the next history query let queryResponse2 = await client.query(historyQuery2, serverRemotePeerInfo) @@ -246,10 +268,10 @@ suite "Waku Store - End to End - Sorted Archive": asyncTest "Pagination with Excessive Page Size": # Given the first query (1/1) - historyQuery.pageSize = 100 + storeQuery.paginationLimit = some(uint64(100)) # When making a history query - let queryResponse1 = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse1 = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: @@ -257,23 +279,25 @@ suite "Waku Store - End to End - Sorted Archive": asyncTest "Pagination with Mixed Page Size": # Given the first query (1/3) - historyQuery.pageSize = 2 + storeQuery.paginationLimit = some(uint64(2)) # When making a history query - let queryResponse1 = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse1 = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: queryResponse1.get().messages == archiveMessages[0 ..< 2] # Given the next query (2/3) - let historyQuery2 = HistoryQuery( - cursor: queryResponse1.get().cursor, - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 4, - ) + let + historyQuery2 = + StoreQueryRequest( + paginationCursor: queryResponse1.get().paginationCursor, + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(4)), + ) # When making the next history query let queryResponse2 = await client.query(historyQuery2, serverRemotePeerInfo) @@ -283,13 +307,15 @@ suite "Waku Store - End to End - Sorted Archive": queryResponse2.get().messages == archiveMessages[2 ..< 6] # Given the next query (3/3) - let historyQuery3 = HistoryQuery( - cursor: queryResponse2.get().cursor, - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 6, - ) + let + historyQuery3 = + StoreQueryRequest( + paginationCursor: queryResponse2.get().paginationCursor, + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(6)), + ) # When making the next history query let queryResponse3 = await client.query(historyQuery3, serverRemotePeerInfo) @@ -305,7 +331,7 @@ suite "Waku Store - End to End - Sorted Archive": "This test requires a store with more than (DefaultPageSize) messages" let missingMessagesAmount = archive.DefaultPageSize - currentStoreLen + 5 - let lastMessageTimestamp = archiveMessages[archiveMessages.len - 1].timestamp + let lastMessageTimestamp = archiveMessages[archiveMessages.len - 1].message.timestamp var extraMessages: seq[WakuMessage] = @[] for i in 0 ..< missingMessagesAmount: let @@ -316,26 +342,33 @@ suite "Waku Store - End to End - Sorted Archive": extraMessages.add(message) discard archiveDriver.put(pubsubTopic, extraMessages) - let totalMessages = archiveMessages & extraMessages + let totalMessages = + archiveMessages & extraMessages.mapIt( + WakuMessageKeyValue( + messageHash: computeMessageHash(pubsubTopic, it), + message: it, + )) # Given the a query with zero page size (1/2) - historyQuery.pageSize = 0 + storeQuery.paginationLimit = none(uint64) # When making a history query - let queryResponse1 = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse1 = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the archive.DefaultPageSize messages check: queryResponse1.get().messages == totalMessages[0 ..< archive.DefaultPageSize] # Given the next query (2/2) - let historyQuery2 = HistoryQuery( - cursor: queryResponse1.get().cursor, - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 0, - ) + let + historyQuery2 = + StoreQueryRequest( + paginationCursor: queryResponse1.get().paginationCursor, + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: none(uint64), + ) # When making the next history query let queryResponse2 = await client.query(historyQuery2, serverRemotePeerInfo) @@ -352,7 +385,7 @@ suite "Waku Store - End to End - Sorted Archive": "This test requires a store with more than (DefaultPageSize) messages" let missingMessagesAmount = archive.DefaultPageSize - currentStoreLen + 5 - let lastMessageTimestamp = archiveMessages[archiveMessages.len - 1].timestamp + let lastMessageTimestamp = archiveMessages[archiveMessages.len - 1].message.timestamp var extraMessages: seq[WakuMessage] = @[] for i in 0 ..< missingMessagesAmount: let @@ -363,29 +396,37 @@ suite "Waku Store - End to End - Sorted Archive": extraMessages.add(message) discard archiveDriver.put(pubsubTopic, extraMessages) - let totalMessages = archiveMessages & extraMessages + let totalMessages = + archiveMessages & extraMessages.mapIt( + WakuMessageKeyValue( + messageHash: computeMessageHash(pubsubTopic, it), + message: it, + )) # Given a query with default page size (1/2) - historyQuery = HistoryQuery( - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - ) + storeQuery = + StoreQueryRequest( + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + ) # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: queryResponse.get().messages == totalMessages[0 ..< archive.DefaultPageSize] # Given the next query (2/2) - let historyQuery2 = HistoryQuery( - cursor: queryResponse.get().cursor, - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - ) + let + historyQuery2 = + StoreQueryRequest( + paginationCursor: queryResponse.get().paginationCursor, + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + ) # When making the next history query let queryResponse2 = await client.query(historyQuery2, serverRemotePeerInfo) @@ -397,39 +438,39 @@ suite "Waku Store - End to End - Sorted Archive": suite "Pagination with Different Cursors": asyncTest "Starting Cursor": - # Given a cursor pointing to the first message - let cursor = computeHistoryCursor(pubsubTopic, archiveMessages[0]) - historyQuery.cursor = some(cursor) - historyQuery.pageSize = 1 + # Given a paginationCursor pointing to the first message + let paginationCursor = archiveMessages[0].messageHash + storeQuery.paginationCursor = some(paginationCursor) + storeQuery.paginationLimit = some(uint64(1)) # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the message check: queryResponse.get().messages == archiveMessages[1 ..< 2] asyncTest "Middle Cursor": - # Given a cursor pointing to the middle message1 - let cursor = computeHistoryCursor(pubsubTopic, archiveMessages[5]) - historyQuery.cursor = some(cursor) - historyQuery.pageSize = 1 + # Given a paginationCursor pointing to the middle message1 + let paginationCursor = archiveMessages[5].messageHash + storeQuery.paginationCursor = some(paginationCursor) + storeQuery.paginationLimit = some(uint64(1)) # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the message check: queryResponse.get().messages == archiveMessages[6 ..< 7] asyncTest "Ending Cursor": - # Given a cursor pointing to the last message - let cursor = computeHistoryCursor(pubsubTopic, archiveMessages[9]) - historyQuery.cursor = some(cursor) - historyQuery.pageSize = 1 + # Given a paginationCursor pointing to the last message + let paginationCursor = archiveMessages[9].messageHash + storeQuery.paginationCursor = some(paginationCursor) + storeQuery.paginationLimit = some(uint64(1)) # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains no messages check: @@ -440,7 +481,7 @@ suite "Waku Store - End to End - Sorted Archive": # Given a different server node with the same archive let otherArchiveDriverWithMessages = - newArchiveDriverWithMessages(pubsubTopic, archiveMessages) + newArchiveDriverWithMessages(pubsubTopic, archiveMessages.mapIt(it.message)) otherServerKey = generateSecp256k1Key() otherServer = newTestWakuNode(otherServerKey, ValidIpAddress.init("0.0.0.0"), Port(0)) @@ -454,25 +495,28 @@ suite "Waku Store - End to End - Sorted Archive": let otherServerRemotePeerInfo = otherServer.peerInfo.toRemotePeerInfo() # When making a history query to the first server node - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: queryResponse.get().messages == archiveMessages[0 ..< 5] - # Given the cursor from the first query - let cursor = queryResponse.get().cursor + # Given the paginationCursor from the first query + let paginationCursor = queryResponse.get().paginationCursor # When making a history query to the second server node - let otherHistoryQuery = HistoryQuery( - cursor: cursor, - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 5, - ) - let otherQueryResponse = - await client.query(otherHistoryQuery, otherServerRemotePeerInfo) + let + otherHistoryQuery = + StoreQueryRequest( + paginationCursor: paginationCursor, + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(5)), + ) + let + otherQueryResponse = + await client.query(otherHistoryQuery, otherServerRemotePeerInfo) # Then the response contains the remaining messages check: @@ -486,8 +530,8 @@ suite "Waku Store - End to End - Unsorted Archive": var contentTopic {.threadvar.}: ContentTopic var contentTopicSeq {.threadvar.}: seq[ContentTopic] - var historyQuery {.threadvar.}: HistoryQuery - var unsortedArchiveMessages {.threadvar.}: seq[WakuMessage] + var storeQuery {.threadvar.}: StoreQueryRequest + var unsortedArchiveMessages {.threadvar.}: seq[WakuMessageKeyValue] var server {.threadvar.}: WakuNode var client {.threadvar.}: WakuNode @@ -499,27 +543,33 @@ suite "Waku Store - End to End - Unsorted Archive": contentTopic = DefaultContentTopic contentTopicSeq = @[contentTopic] - historyQuery = HistoryQuery( - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 5, - ) + storeQuery = + StoreQueryRequest( + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(5)), + ) let timeOrigin = now() - unsortedArchiveMessages = - @[ # SortIndex (by timestamp and digest) - fakeWakuMessage(@[byte 00], ts = ts(00, timeOrigin)), # 1 - fakeWakuMessage(@[byte 03], ts = ts(00, timeOrigin)), # 2 - fakeWakuMessage(@[byte 08], ts = ts(00, timeOrigin)), # 0 - fakeWakuMessage(@[byte 07], ts = ts(10, timeOrigin)), # 4 - fakeWakuMessage(@[byte 02], ts = ts(10, timeOrigin)), # 3 - fakeWakuMessage(@[byte 09], ts = ts(10, timeOrigin)), # 5 - fakeWakuMessage(@[byte 06], ts = ts(20, timeOrigin)), # 6 - fakeWakuMessage(@[byte 01], ts = ts(20, timeOrigin)), # 9 - fakeWakuMessage(@[byte 04], ts = ts(20, timeOrigin)), # 7 - fakeWakuMessage(@[byte 05], ts = ts(20, timeOrigin)), # 8 + let messages = + @[ + fakeWakuMessage(@[byte 00], ts = ts(00, timeOrigin)), + fakeWakuMessage(@[byte 03], ts = ts(00, timeOrigin)), + fakeWakuMessage(@[byte 08], ts = ts(00, timeOrigin)), + fakeWakuMessage(@[byte 07], ts = ts(10, timeOrigin)), + fakeWakuMessage(@[byte 02], ts = ts(10, timeOrigin)), + fakeWakuMessage(@[byte 09], ts = ts(10, timeOrigin)), + fakeWakuMessage(@[byte 06], ts = ts(20, timeOrigin)), + fakeWakuMessage(@[byte 01], ts = ts(20, timeOrigin)), + fakeWakuMessage(@[byte 04], ts = ts(20, timeOrigin)), + fakeWakuMessage(@[byte 05], ts = ts(20, timeOrigin)) ] + unsortedArchiveMessages = messages.mapIt( + WakuMessageKeyValue( + messageHash: computeMessageHash(pubsubTopic, it), + message: it, + )) let serverKey = generateSecp256k1Key() @@ -530,7 +580,7 @@ suite "Waku Store - End to End - Unsorted Archive": let unsortedArchiveDriverWithMessages = - newArchiveDriverWithMessages(pubsubTopic, unsortedArchiveMessages) + newArchiveDriverWithMessages(pubsubTopic, messages) mountUnsortedArchiveResult = server.mountArchive(unsortedArchiveDriverWithMessages) @@ -546,80 +596,260 @@ suite "Waku Store - End to End - Unsorted Archive": asyncTeardown: waitFor allFutures(client.stop(), server.stop()) - asyncTest "Basic (Timestamp and Digest) Sorting Validation": + asyncTest "Basic (Timestamp and Hash) Sorting Validation": # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) - # Then the response contains the messages + # Check the ordering check: - queryResponse.get().messages == - @[ - unsortedArchiveMessages[2], - unsortedArchiveMessages[0], - unsortedArchiveMessages[1], - unsortedArchiveMessages[4], - unsortedArchiveMessages[3], - ] + queryResponse.get().messages.len == 5 + + queryResponse.get().messages[0].message.timestamp == + queryResponse.get().messages[1].message.timestamp + + queryResponse.get().messages[1].message.timestamp == + queryResponse.get().messages[2].message.timestamp + + queryResponse.get().messages[2].message.timestamp < + queryResponse.get().messages[3].message.timestamp + + queryResponse.get().messages[3].message.timestamp == + queryResponse.get().messages[4].message.timestamp + + toHex(queryResponse.get().messages[0].messageHash) < + toHex(queryResponse.get().messages[1].messageHash) + + toHex(queryResponse.get().messages[1].messageHash) < + toHex(queryResponse.get().messages[2].messageHash) + + toHex(queryResponse.get().messages[3].messageHash) < + toHex(queryResponse.get().messages[4].messageHash) # Given the next query - var historyQuery2 = HistoryQuery( - cursor: queryResponse.get().cursor, - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 5, - ) + var + historyQuery2 = + StoreQueryRequest( + paginationCursor: queryResponse.get().paginationCursor, + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(5)), + ) # When making the next history query let queryResponse2 = await client.query(historyQuery2, serverRemotePeerInfo) - # Then the response contains the messages + # Check the ordering check: - queryResponse2.get().messages == - @[ - unsortedArchiveMessages[5], - unsortedArchiveMessages[6], - unsortedArchiveMessages[8], - unsortedArchiveMessages[9], - unsortedArchiveMessages[7], - ] + queryResponse2.get().messages[0].message.timestamp < + queryResponse2.get().messages[1].message.timestamp + + queryResponse2.get().messages[1].message.timestamp == + queryResponse2.get().messages[2].message.timestamp + + queryResponse2.get().messages[2].message.timestamp == + queryResponse2.get().messages[3].message.timestamp + + queryResponse2.get().messages[3].message.timestamp == + queryResponse2.get().messages[4].message.timestamp + + toHex(queryResponse2.get().messages[1].messageHash) < + toHex(queryResponse2.get().messages[2].messageHash) + + toHex(queryResponse2.get().messages[2].messageHash) < + toHex(queryResponse2.get().messages[3].messageHash) + + toHex(queryResponse2.get().messages[3].messageHash) < + toHex(queryResponse2.get().messages[4].messageHash) asyncTest "Backward pagination with Ascending Sorting": # Given a history query with backward pagination - let cursor = computeHistoryCursor(pubsubTopic, unsortedArchiveMessages[4]) - historyQuery.direction = PagingDirection.BACKWARD - historyQuery.cursor = some(cursor) + # Pick the right cursor based on the ordering + var cursor = unsortedArchiveMessages[3].messageHash + if toHex(cursor) > toHex(unsortedArchiveMessages[4].messageHash): + cursor = unsortedArchiveMessages[4].messageHash + if toHex(cursor) > toHex(unsortedArchiveMessages[5].messageHash): + cursor = unsortedArchiveMessages[5].messageHash + + storeQuery.paginationForward = PagingDirection.BACKWARD + storeQuery.paginationCursor = some(cursor) + + # When making a history query + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) + + # Then check the response ordering + check: + queryResponse.get().messages.len == 3 + + queryResponse.get().messages[0].message.timestamp == + queryResponse.get().messages[1].message.timestamp + + queryResponse.get().messages[1].message.timestamp == + queryResponse.get().messages[2].message.timestamp + + toHex(queryResponse.get().messages[0].messageHash) < + toHex(queryResponse.get().messages[1].messageHash) + + toHex(queryResponse.get().messages[1].messageHash) < + toHex(queryResponse.get().messages[2].messageHash) + + asyncTest "Forward Pagination with Ascending Sorting": + # Given a history query with forward pagination + + # Pick the right cursor based on the ordering + var cursor = unsortedArchiveMessages[3].messageHash + if toHex(cursor) > toHex(unsortedArchiveMessages[4].messageHash): + cursor = unsortedArchiveMessages[4].messageHash + if toHex(cursor) > toHex(unsortedArchiveMessages[5].messageHash): + cursor = unsortedArchiveMessages[5].messageHash + + storeQuery.paginationForward = PagingDirection.FORWARD + storeQuery.paginationCursor = some(cursor) + storeQuery.paginationLimit = some(uint64(6)) + + # When making a history query + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) + + # Then check the response ordering + check: + queryResponse.get().messages.len == 6 + + queryResponse.get().messages[0].message.timestamp == + queryResponse.get().messages[1].message.timestamp + + queryResponse.get().messages[1].message.timestamp < + queryResponse.get().messages[2].message.timestamp + + queryResponse.get().messages[2].message.timestamp == + queryResponse.get().messages[3].message.timestamp + + queryResponse.get().messages[3].message.timestamp == + queryResponse.get().messages[4].message.timestamp + + queryResponse.get().messages[4].message.timestamp == + queryResponse.get().messages[5].message.timestamp + + toHex(queryResponse.get().messages[0].messageHash) < + toHex(queryResponse.get().messages[1].messageHash) + + toHex(queryResponse.get().messages[2].messageHash) < + toHex(queryResponse.get().messages[3].messageHash) + + toHex(queryResponse.get().messages[3].messageHash) < + toHex(queryResponse.get().messages[4].messageHash) + + toHex(queryResponse.get().messages[4].messageHash) < + toHex(queryResponse.get().messages[5].messageHash) + +suite "Waku Store - End to End - Unsorted Archive without provided Timestamp": + var pubsubTopic {.threadvar.}: PubsubTopic + var contentTopic {.threadvar.}: ContentTopic + var contentTopicSeq {.threadvar.}: seq[ContentTopic] + + var storeQuery {.threadvar.}: StoreQueryRequest + var unsortedArchiveMessages {.threadvar.}: seq[WakuMessageKeyValue] + + var server {.threadvar.}: WakuNode + var client {.threadvar.}: WakuNode + + var serverRemotePeerInfo {.threadvar.}: RemotePeerInfo + + asyncSetup: + pubsubTopic = DefaultPubsubTopic + contentTopic = DefaultContentTopic + contentTopicSeq = @[contentTopic] + + storeQuery = + StoreQueryRequest( + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(5)), + ) + + let messages = + @[ # Not providing explicit timestamp means it will be set in "arrive" order + fakeWakuMessage(@[byte 09]), + fakeWakuMessage(@[byte 07]), + fakeWakuMessage(@[byte 05]), + fakeWakuMessage(@[byte 03]), + fakeWakuMessage(@[byte 01]), + fakeWakuMessage(@[byte 00]), + fakeWakuMessage(@[byte 02]), + fakeWakuMessage(@[byte 04]), + fakeWakuMessage(@[byte 06]), + fakeWakuMessage(@[byte 08]) + ] + unsortedArchiveMessages = messages.mapIt( + WakuMessageKeyValue( + messageHash: computeMessageHash(pubsubTopic, it), + message: it, + )) + + let + serverKey = generateSecp256k1Key() + clientKey = generateSecp256k1Key() + + server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) + + let + unsortedArchiveDriverWithMessages = + newArchiveDriverWithMessages(pubsubTopic, messages) + mountUnsortedArchiveResult = + server.mountArchive(unsortedArchiveDriverWithMessages) + + assert mountUnsortedArchiveResult.isOk() + + waitFor server.mountStore() + client.mountStoreClient() + + waitFor allFutures(server.start(), client.start()) + + serverRemotePeerInfo = server.peerInfo.toRemotePeerInfo() + + asyncTeardown: + waitFor allFutures(client.stop(), server.stop()) + + asyncTest "Sorting using receiverTime": # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: queryResponse.get().messages == @[ - unsortedArchiveMessages[2], unsortedArchiveMessages[0], unsortedArchiveMessages[1], + unsortedArchiveMessages[2], + unsortedArchiveMessages[3], + unsortedArchiveMessages[4] ] - asyncTest "Forward Pagination with Ascending Sorting": - # Given a history query with forward pagination - let cursor = computeHistoryCursor(pubsubTopic, unsortedArchiveMessages[4]) - historyQuery.direction = PagingDirection.FORWARD - historyQuery.cursor = some(cursor) + # Given the next query + var + historyQuery2 = + StoreQueryRequest( + paginationCursor: queryResponse.get().paginationCursor, + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(5)), + ) - # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + # When making the next history query + let queryResponse2 = await client.query(historyQuery2, serverRemotePeerInfo) # Then the response contains the messages check: - queryResponse.get().messages == + queryResponse2.get().messages == @[ - unsortedArchiveMessages[3], unsortedArchiveMessages[5], unsortedArchiveMessages[6], + unsortedArchiveMessages[7], unsortedArchiveMessages[8], - unsortedArchiveMessages[9], + unsortedArchiveMessages[9] ] suite "Waku Store - End to End - Archive with Multiple Topics": @@ -631,9 +861,9 @@ suite "Waku Store - End to End - Archive with Multiple Topics": var contentTopicSpecials {.threadvar.}: ContentTopic var contentTopicSeq {.threadvar.}: seq[ContentTopic] - var historyQuery {.threadvar.}: HistoryQuery + var storeQuery {.threadvar.}: StoreQueryRequest var originTs {.threadvar.}: proc(offset: int): Timestamp {.gcsafe, raises: [].} - var archiveMessages {.threadvar.}: seq[WakuMessage] + var archiveMessages {.threadvar.}: seq[WakuMessageKeyValue] var server {.threadvar.}: WakuNode var client {.threadvar.}: WakuNode @@ -650,18 +880,21 @@ suite "Waku Store - End to End - Archive with Multiple Topics": contentTopicSeq = @[contentTopic, contentTopicB, contentTopicC, contentTopicSpecials] - historyQuery = HistoryQuery( - pubsubTopic: some(pubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 5, - ) + storeQuery = + StoreQueryRequest( + pubsubTopic: some(pubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(5)), + ) let timeOrigin = now() originTs = proc(offset = 0): Timestamp {.gcsafe, raises: [].} = ts(offset, timeOrigin) - archiveMessages = + originTs = myOriginTs + + let messages = @[ fakeWakuMessage(@[byte 00], ts = originTs(00), contentTopic = contentTopic), fakeWakuMessage(@[byte 01], ts = originTs(10), contentTopic = contentTopicB), @@ -677,6 +910,16 @@ suite "Waku Store - End to End - Archive with Multiple Topics": ), ] + archiveMessages = messages.mapIt( + WakuMessageKeyValue( + messageHash: computeMessageHash(pubsubTopic, it), + message: it, + )) + + for i in 6..<10: + archiveMessages[i].messagehash = + computeMessageHash(pubsubTopicB, archiveMessages[i].message) + let serverKey = generateSecp256k1Key() clientKey = generateSecp256k1Key() @@ -684,10 +927,12 @@ suite "Waku Store - End to End - Archive with Multiple Topics": server = newTestWakuNode(serverKey, ValidIpAddress.init("0.0.0.0"), Port(0)) client = newTestWakuNode(clientKey, ValidIpAddress.init("0.0.0.0"), Port(0)) - let archiveDriver = newSqliteArchiveDriver() - .put(pubsubTopic, archiveMessages[0 ..< 6]) - .put(pubsubTopicB, archiveMessages[6 ..< 10]) - let mountSortedArchiveResult = server.mountArchive(archiveDriver) + let + archiveDriver = + newSqliteArchiveDriver().put(pubsubTopic, messages[0..<6]).put( + pubsubTopicB, messages[6..<10] + ) + let mountUnsortedArchiveResult = server.mountArchive(archiveDriver) assert mountSortedArchiveResult.isOk() @@ -704,10 +949,10 @@ suite "Waku Store - End to End - Archive with Multiple Topics": suite "Validation of Content Filtering": asyncTest "Basic Content Filtering": # Given a history query with content filtering - historyQuery.contentTopics = @[contentTopic] + storeQuery.contentTopics = @[contentTopic] # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: @@ -715,10 +960,10 @@ suite "Waku Store - End to End - Archive with Multiple Topics": asyncTest "Multiple Content Filters": # Given a history query with multiple content filtering - historyQuery.contentTopics = @[contentTopic, contentTopicB] + storeQuery.contentTopics = @[contentTopic, contentTopicB] # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: @@ -732,23 +977,25 @@ suite "Waku Store - End to End - Archive with Multiple Topics": asyncTest "Empty Content Filtering": # Given a history query with empty content filtering - historyQuery.contentTopics = @[] + storeQuery.contentTopics = @[] # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: queryResponse.get().messages == archiveMessages[0 ..< 5] # Given the next query - let historyQuery2 = HistoryQuery( - cursor: queryResponse.get().cursor, - pubsubTopic: none(PubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 5, - ) + let + historyQuery2 = + StoreQueryRequest( + paginationCursor: queryResponse.get().paginationCursor, + pubsubTopic: none(PubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(5)), + ) # When making the next history query let queryResponse2 = await client.query(historyQuery2, serverRemotePeerInfo) @@ -759,10 +1006,10 @@ suite "Waku Store - End to End - Archive with Multiple Topics": asyncTest "Non-Existent Content Topic": # Given a history query with non-existent content filtering - historyQuery.contentTopics = @["non-existent-topic"] + storeQuery.contentTopics = @["non-existent-topic"] # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains no messages check: @@ -770,11 +1017,11 @@ suite "Waku Store - End to End - Archive with Multiple Topics": asyncTest "Special Characters in Content Filtering": # Given a history query with special characters in content filtering - historyQuery.pubsubTopic = some(pubsubTopicB) - historyQuery.contentTopics = @["!@#$%^&*()_+"] + storeQuery.pubsubTopic = some(pubsubTopicB) + storeQuery.contentTopics = @["!@#$%^&*()_+"] # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains no messages check: @@ -782,10 +1029,10 @@ suite "Waku Store - End to End - Archive with Multiple Topics": asyncTest "PubsubTopic Specified": # Given a history query with pubsub topic specified - historyQuery.pubsubTopic = some(pubsubTopicB) + storeQuery.pubsubTopic = some(pubsubTopicB) # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: @@ -799,23 +1046,25 @@ suite "Waku Store - End to End - Archive with Multiple Topics": asyncTest "PubsubTopic Left Empty": # Given a history query with pubsub topic left empty - historyQuery.pubsubTopic = none(PubsubTopic) + storeQuery.pubsubTopic = none(PubsubTopic) # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: queryResponse.get().messages == archiveMessages[0 ..< 5] # Given the next query - let historyQuery2 = HistoryQuery( - cursor: queryResponse.get().cursor, - pubsubTopic: none(PubsubTopic), - contentTopics: contentTopicSeq, - direction: PagingDirection.FORWARD, - pageSize: 5, - ) + let + historyQuery2 = + StoreQueryRequest( + paginationCursor: queryResponse.get().paginationCursor, + pubsubTopic: none(PubsubTopic), + contentTopics: contentTopicSeq, + paginationForward: PagingDirection.FORWARD, + paginationLimit: some(uint64(5)), + ) # When making the next history query let queryResponse2 = await client.query(historyQuery2, serverRemotePeerInfo) @@ -827,11 +1076,11 @@ suite "Waku Store - End to End - Archive with Multiple Topics": suite "Validation of Time-based Filtering": asyncTest "Basic Time Filtering": # Given a history query with start and end time - historyQuery.startTime = some(originTs(20)) - historyQuery.endTime = some(originTs(40)) + storeQuery.startTime = some(originTs(20)) + storeQuery.endTime = some(originTs(40)) # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: @@ -840,11 +1089,11 @@ suite "Waku Store - End to End - Archive with Multiple Topics": asyncTest "Only Start Time Specified": # Given a history query with only start time - historyQuery.startTime = some(originTs(20)) - historyQuery.endTime = none(Timestamp) + storeQuery.startTime = some(originTs(20)) + storeQuery.endTime = none(Timestamp) # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: @@ -858,11 +1107,11 @@ suite "Waku Store - End to End - Archive with Multiple Topics": asyncTest "Only End Time Specified": # Given a history query with only end time - historyQuery.startTime = none(Timestamp) - historyQuery.endTime = some(originTs(40)) + storeQuery.startTime = none(Timestamp) + storeQuery.endTime = some(originTs(40)) # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains no messages check: @@ -877,11 +1126,11 @@ suite "Waku Store - End to End - Archive with Multiple Topics": asyncTest "Invalid Time Range": # Given a history query with invalid time range - historyQuery.startTime = some(originTs(60)) - historyQuery.endTime = some(originTs(40)) + storeQuery.startTime = some(originTs(60)) + storeQuery.endTime = some(originTs(40)) # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains no messages check: @@ -889,12 +1138,12 @@ suite "Waku Store - End to End - Archive with Multiple Topics": asyncTest "Time Filtering with Content Filtering": # Given a history query with time and content filtering - historyQuery.startTime = some(originTs(20)) - historyQuery.endTime = some(originTs(60)) - historyQuery.contentTopics = @[contentTopicC] + storeQuery.startTime = some(originTs(20)) + storeQuery.endTime = some(originTs(60)) + storeQuery.contentTopics = @[contentTopicC] # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains the messages check: @@ -902,11 +1151,11 @@ suite "Waku Store - End to End - Archive with Multiple Topics": asyncTest "Messages Outside of Time Range": # Given a history query with a valid time range which does not contain any messages - historyQuery.startTime = some(originTs(100)) - historyQuery.endTime = some(originTs(200)) + storeQuery.startTime = some(originTs(100)) + storeQuery.endTime = some(originTs(200)) # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response contains no messages check: @@ -940,8 +1189,8 @@ suite "Waku Store - End to End - Archive with Multiple Topics": let ephemeralServerRemotePeerInfo = ephemeralServer.peerInfo.toRemotePeerInfo() # When making a history query to the server with only ephemeral messages - let queryResponse = - await client.query(historyQuery, ephemeralServerRemotePeerInfo) + let + queryResponse = await client.query(storeQuery, ephemeralServerRemotePeerInfo) # Then the response contains no messages check: @@ -982,7 +1231,7 @@ suite "Waku Store - End to End - Archive with Multiple Topics": let mixedServerRemotePeerInfo = mixedServer.peerInfo.toRemotePeerInfo() # When making a history query to the server with mixed messages - let queryResponse = await client.query(historyQuery, mixedServerRemotePeerInfo) + let queryResponse = await client.query(storeQuery, mixedServerRemotePeerInfo) # Then the response contains the non-ephemeral messages check: @@ -1009,7 +1258,7 @@ suite "Waku Store - End to End - Archive with Multiple Topics": let emptyServerRemotePeerInfo = emptyServer.peerInfo.toRemotePeerInfo() # When making a history query to the server with an empty archive - let queryResponse = await client.query(historyQuery, emptyServerRemotePeerInfo) + let queryResponse = await client.query(storeQuery, emptyServerRemotePeerInfo) # Then the response contains no messages check: @@ -1020,12 +1269,20 @@ suite "Waku Store - End to End - Archive with Multiple Topics": asyncTest "Voluminous Message Store": # Given a voluminous archive (1M+ messages) - var voluminousArchiveMessages: seq[WakuMessage] = @[] - for i in 0 ..< 100000: + var messages: seq[WakuMessage] = @[] + for i in 0..<100000: let topic = "topic" & $i - voluminousArchiveMessages.add(fakeWakuMessage(@[byte i], contentTopic = topic)) - let voluminousArchiveDriverWithMessages = - newArchiveDriverWithMessages(pubsubTopic, voluminousArchiveMessages) + messages.add(fakeWakuMessage(@[byte i], contentTopic = topic)) + + let voluminousArchiveMessages = messages.mapIt( + WakuMessageKeyValue( + messageHash: computeMessageHash(pubsubTopic, it), + message: it, + )) + + let + voluminousArchiveDriverWithMessages = + newArchiveDriverWithMessages(pubsubTopic, messages) # And a server node with the voluminous archive let @@ -1041,12 +1298,12 @@ suite "Waku Store - End to End - Archive with Multiple Topics": let voluminousServerRemotePeerInfo = voluminousServer.peerInfo.toRemotePeerInfo() # Given the following history query - historyQuery.contentTopics = + storeQuery.contentTopics = @["topic10000", "topic30000", "topic50000", "topic70000", "topic90000"] # When making a history query to the server with a voluminous archive - let queryResponse = - await client.query(historyQuery, voluminousServerRemotePeerInfo) + let + queryResponse = await client.query(storeQuery, voluminousServerRemotePeerInfo) # Then the response contains the messages check: @@ -1064,13 +1321,13 @@ suite "Waku Store - End to End - Archive with Multiple Topics": asyncTest "Large contentFilters Array": # Given a history query with the max contentFilters len, 10 - historyQuery.contentTopics = @[contentTopic] - for i in 0 ..< 9: + storeQuery.contentTopics = @[contentTopic] + for i in 0..<9: let topic = "topic" & $i - historyQuery.contentTopics.add(topic) + storeQuery.contentTopics.add(topic) # When making a history query - let queryResponse = await client.query(historyQuery, serverRemotePeerInfo) + let queryResponse = await client.query(storeQuery, serverRemotePeerInfo) # Then the response should trigger no errors check: