From 8e65dbb85f6510eb4572df34ffd064d8a2e33344 Mon Sep 17 00:00:00 2001 From: staheri14 Date: Fri, 9 Apr 2021 21:11:02 +0000 Subject: [PATCH] deploy: b9aec4c06ed22c34ee06d922502a3a390eda9ab1 --- .update.timestamp | 2 +- tests/v2/test_jsonrpc_waku.nim | 2 ++ tests/v2/test_waku_store.nim | 4 ++++ waku/v2/node/jsonrpc/filter_api.nim | 2 +- waku/v2/node/jsonrpc/relay_api.nim | 2 +- waku/v2/protocol/waku_store/waku_store.nim | 4 ++-- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.update.timestamp b/.update.timestamp index ca63b987d..c2cfeed53 100644 --- a/.update.timestamp +++ b/.update.timestamp @@ -1 +1 @@ -1617987051 \ No newline at end of file +1618001244 \ No newline at end of file diff --git a/tests/v2/test_jsonrpc_waku.nim b/tests/v2/test_jsonrpc_waku.nim index 7d3542b16..39f0aee38 100644 --- a/tests/v2/test_jsonrpc_waku.nim +++ b/tests/v2/test_jsonrpc_waku.nim @@ -372,6 +372,8 @@ procSuite "Waku v2 JSON-RPC API": for x in 1..(maxSize + 1): # Try to cache 1 more than maximum allowed filters.notify(WakuMessage(payload: @[byte x], contentTopic: defaultContentTopic), requestId) + + await sleepAsync(2000.millis) response = await client.get_waku_v2_filter_v1_messages(defaultContentTopic) check: diff --git a/tests/v2/test_waku_store.nim b/tests/v2/test_waku_store.nim index 98e2c5db5..5c6e66e06 100644 --- a/tests/v2/test_waku_store.nim +++ b/tests/v2/test_waku_store.nim @@ -88,6 +88,7 @@ procSuite "Waku Store": listenSwitch.mount(proto) await subscriptions.notify("foo", msg) + await sleepAsync(1.millis) # Sleep a millisecond to ensure messages are stored chronologically await subscriptions.notify("foo", msg2) var completionFut = newFuture[bool]() @@ -162,6 +163,7 @@ procSuite "Waku Store": for wakuMsg in msgList: await subscriptions.notify("foo", wakuMsg) + await sleepAsync(1.millis) # Sleep a millisecond to ensure messages are stored chronologically var completionFut = newFuture[bool]() @@ -212,6 +214,7 @@ procSuite "Waku Store": for wakuMsg in msgList: await subscriptions.notify("foo", wakuMsg) + await sleepAsync(1.millis) # Sleep a millisecond to ensure messages are stored chronologically var completionFut = newFuture[bool]() proc handler(response: HistoryResponse) {.gcsafe, closure.} = @@ -262,6 +265,7 @@ procSuite "Waku Store": for wakuMsg in msgList: await subscriptions.notify("foo", wakuMsg) + await sleepAsync(1.millis) # Sleep a millisecond to ensure messages are stored chronologically var completionFut = newFuture[bool]() proc handler(response: HistoryResponse) {.gcsafe, closure.} = diff --git a/waku/v2/node/jsonrpc/filter_api.nim b/waku/v2/node/jsonrpc/filter_api.nim index 666242c5f..53af00645 100644 --- a/waku/v2/node/jsonrpc/filter_api.nim +++ b/waku/v2/node/jsonrpc/filter_api.nim @@ -14,7 +14,7 @@ logScope: topics = "filter api" const futTimeout* = 5.seconds # Max time to wait for futures -const maxCache* = 100 # Max number of messages cached per topic @TODO make this configurable +const maxCache* = 30 # Max number of messages cached per topic @TODO make this configurable proc installFilterApiHandlers*(node: WakuNode, rpcsrv: RpcServer, messageCache: MessageCache) = diff --git a/waku/v2/node/jsonrpc/relay_api.nim b/waku/v2/node/jsonrpc/relay_api.nim index 3cc4f1c33..e6a404c12 100644 --- a/waku/v2/node/jsonrpc/relay_api.nim +++ b/waku/v2/node/jsonrpc/relay_api.nim @@ -15,7 +15,7 @@ logScope: topics = "relay api" const futTimeout* = 5.seconds # Max time to wait for futures -const maxCache* = 100 # Max number of messages cached per topic @TODO make this configurable +const maxCache* = 30 # Max number of messages cached per topic @TODO make this configurable proc installRelayApiHandlers*(node: WakuNode, rpcsrv: RpcServer, topicCache: TopicCache) = diff --git a/waku/v2/protocol/waku_store/waku_store.nim b/waku/v2/protocol/waku_store/waku_store.nim index ad0bead4f..30c0432c4 100644 --- a/waku/v2/protocol/waku_store/waku_store.nim +++ b/waku/v2/protocol/waku_store/waku_store.nim @@ -242,9 +242,9 @@ proc paginateWithIndex*(list: seq[IndexedWakuMessage], pinfo: PagingInfo): (seq[ initQuery = true # an empty cursor means it is an initial query case dir of PagingDirection.FORWARD: - cursor = list[0].index # perform paging from the begining of the list + cursor = msgList[0].index # perform paging from the begining of the list of PagingDirection.BACKWARD: - cursor = list[list.len - 1].index # perform paging from the end of the list + cursor = msgList[list.len - 1].index # perform paging from the end of the list var foundIndexOption = msgList.findIndex(cursor) # echo "foundIndexOption", foundIndexOption.get() if foundIndexOption.isNone: # the cursor is not valid