deploy: 286482ea32401952ff01b80ad7cc183cb9336c06

This commit is contained in:
staheri14 2021-04-12 17:51:42 +00:00
parent 8ab5f84585
commit c54608a419
4 changed files with 68 additions and 5 deletions

View File

@ -1 +1 @@
1618011634
1618248549

View File

@ -102,6 +102,16 @@ procSuite "pagination":
newPagingInfo.cursor == msgList[1].index
newPagingInfo.direction == pagingInfo.direction
newPagingInfo.pageSize == 2
# test for an initial pagination request with an empty cursor to fetch the entire history
pagingInfo = PagingInfo(pageSize: 13, direction: PagingDirection.FORWARD)
(data, newPagingInfo) = paginateWithIndex(msgList, pagingInfo)
check:
data.len == 10
data == msgList[0..9]
newPagingInfo.cursor == msgList[9].index
newPagingInfo.direction == pagingInfo.direction
newPagingInfo.pageSize == 10
# test for an empty msgList
pagingInfo = PagingInfo(pageSize: 2, direction: PagingDirection.FORWARD)
@ -147,7 +157,27 @@ procSuite "pagination":
newPagingInfo.cursor == pagingInfo.cursor
newPagingInfo.direction == pagingInfo.direction
newPagingInfo.pageSize == 0
# test initial paging query over a message list with one message
var singleItemMsgList = msgList[0..0]
pagingInfo = PagingInfo(pageSize: 10, direction: PagingDirection.FORWARD)
(data, newPagingInfo) = paginateWithIndex(singleItemMsgList, pagingInfo)
check:
data.len == 1
newPagingInfo.cursor == msgList[0].index
newPagingInfo.direction == pagingInfo.direction
newPagingInfo.pageSize == 1
# test pagination over a message list with one message
singleItemMsgList = msgList[0..0]
pagingInfo = PagingInfo(pageSize: 10, cursor: msgList[0].index, direction: PagingDirection.FORWARD)
(data, newPagingInfo) = paginateWithIndex(singleItemMsgList, pagingInfo)
check:
data.len == 0
newPagingInfo.cursor == msgList[0].index
newPagingInfo.direction == pagingInfo.direction
newPagingInfo.pageSize == 0
test "Backward pagination test":
var
msgList = createSampleList(10)
@ -179,6 +209,16 @@ procSuite "pagination":
newPagingInfo.cursor == msgList[8].index
newPagingInfo.direction == pagingInfo.direction
newPagingInfo.pageSize == 2
# test for an initial pagination request with an empty cursor to fetch the entire history
pagingInfo = PagingInfo(pageSize: 13, direction: PagingDirection.BACKWARD)
(data, newPagingInfo) = paginateWithIndex(msgList, pagingInfo)
check:
data.len == 10
data == msgList[0..9]
newPagingInfo.cursor == msgList[0].index
newPagingInfo.direction == pagingInfo.direction
newPagingInfo.pageSize == 10
# test for a page size larger than the remaining messages
@ -216,6 +256,26 @@ procSuite "pagination":
newPagingInfo.cursor == pagingInfo.cursor
newPagingInfo.direction == pagingInfo.direction
newPagingInfo.pageSize == 0
# test initial paging query over a message list with one message
var singleItemMsgList = msgList[0..0]
pagingInfo = PagingInfo(pageSize: 10, direction: PagingDirection.BACKWARD)
(data, newPagingInfo) = paginateWithIndex(singleItemMsgList, pagingInfo)
check:
data.len == 1
newPagingInfo.cursor == msgList[0].index
newPagingInfo.direction == pagingInfo.direction
newPagingInfo.pageSize == 1
# test paging query over a message list with one message
singleItemMsgList = msgList[0..0]
pagingInfo = PagingInfo(pageSize: 10, cursor: msgList[0].index, direction: PagingDirection.BACKWARD)
(data, newPagingInfo) = paginateWithIndex(singleItemMsgList, pagingInfo)
check:
data.len == 0
newPagingInfo.cursor == msgList[0].index
newPagingInfo.direction == pagingInfo.direction
newPagingInfo.pageSize == 0
suite "time-window history query":
test "Encode/Decode waku message with timestamp":

View File

@ -2,7 +2,7 @@
# libtool - Provide generalized library-building support services.
# Generated automatically by config.status (libbacktrace) version-unused
# Libtool was configured on host fv-az193-129:
# Libtool was configured on host fv-az129-662:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
#
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,

View File

@ -254,7 +254,9 @@ proc paginateWithIndex*(list: seq[IndexedWakuMessage], pinfo: PagingInfo): (seq[
var newCursor: Index # to be returned as part of the new paging info
case dir
of PagingDirection.FORWARD: # forward pagination
let remainingMessages= uint64(msgList.len) - uint64(foundIndex) - 1
# the message that is pointed by the cursor is excluded for the retrieved list, this is because this message has already been retrieved by the querier in its prior request
var remainingMessages= uint64(msgList.len) - uint64(foundIndex) - 1
if initQuery: remainingMessages = remainingMessages + 1
# the number of queried messages cannot exceed the MaxPageSize and the total remaining messages i.e., msgList.len-foundIndex
retrievedPageSize = min(uint64(pageSize), MaxPageSize).min(remainingMessages)
if initQuery : foundIndex = foundIndex - 1
@ -262,7 +264,8 @@ proc paginateWithIndex*(list: seq[IndexedWakuMessage], pinfo: PagingInfo): (seq[
e = foundIndex + retrievedPageSize
newCursor = msgList[e].index # the new cursor points to the end of the page
of PagingDirection.BACKWARD: # backward pagination
let remainingMessages = foundIndex
var remainingMessages = foundIndex
if initQuery: remainingMessages = remainingMessages + 1
# the number of queried messages cannot exceed the MaxPageSize and the total remaining messages i.e., foundIndex-0
retrievedPageSize = min(uint64(pageSize), MaxPageSize).min(remainingMessages)
if initQuery : foundIndex = foundIndex + 1