deploy: b5f1becace723bdb3783bafaa6e352db8f1b78b7

This commit is contained in:
oskarth 2021-04-09 03:31:17 +00:00
parent 5c6fa7fcaf
commit e81223a97c
4 changed files with 8 additions and 39 deletions

View File

@ -1 +1 @@
1617875719
1617937760

View File

@ -298,22 +298,10 @@ procSuite "Waku Store":
decodedEmptyIndex.isErr == false
decodedEmptyIndex.value == emptyIndex
test "PagingDirection Protobuf encod/init test":
let
pagingDirection = PagingDirection.BACKWARD
pb = pagingDirection.encode()
decodedPagingDirection = PagingDirection.init(pb.buffer)
check:
# the decodedPagingDirection must be the same as the original pagingDirection
decodedPagingDirection.isErr == false
decodedPagingDirection.value == pagingDirection
test "PagingInfo Protobuf encod/init test":
let
index = computeIndex(WakuMessage(payload: @[byte 1], contentTopic: defaultContentTopic))
pagingInfo = PagingInfo(pageSize: 1, cursor: index, direction: PagingDirection.BACKWARD)
pagingInfo = PagingInfo(pageSize: 1, cursor: index, direction: PagingDirection.FORWARD)
pb = pagingInfo.encode()
decodedPagingInfo = PagingInfo.init(pb.buffer)
@ -321,6 +309,7 @@ procSuite "Waku Store":
# the fields of decodedPagingInfo must be the same as the original pagingInfo
decodedPagingInfo.isErr == false
decodedPagingInfo.value == pagingInfo
decodedPagingInfo.value.direction == pagingInfo.direction
let
emptyPagingInfo = PagingInfo()

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-az278-724:
# 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

@ -59,16 +59,6 @@ proc encode*(index: Index): ProtoBuffer =
result.write(1, index.digest.data)
result.write(2, index.receivedTime)
proc encode*(pd: PagingDirection): ProtoBuffer =
## encodes a PagingDirection into a ProtoBuffer
## returns the resultant ProtoBuffer
# intiate a ProtoBuffer
result = initProtoBuffer()
# encodes pd
result.write(1, uint32(ord(pd)))
proc encode*(pinfo: PagingInfo): ProtoBuffer =
## encodes a PagingInfo object into a ProtoBuffer
## returns the resultant ProtoBuffer
@ -79,7 +69,7 @@ proc encode*(pinfo: PagingInfo): ProtoBuffer =
# encodes pinfo
result.write(1, pinfo.pageSize)
result.write(2, pinfo.cursor.encode())
result.write(3, pinfo.direction.encode())
result.write(3, uint32(ord(pinfo.direction)))
proc init*(T: type Index, buffer: seq[byte]): ProtoResult[T] =
## creates and returns an Index object out of buffer
@ -101,16 +91,6 @@ proc init*(T: type Index, buffer: seq[byte]): ProtoResult[T] =
ok(index)
proc init*(T: type PagingDirection, buffer: seq[byte]): ProtoResult[T] =
## creates and returns a PagingDirection object out of buffer
let pb = initProtoBuffer(buffer)
var dir: uint32
discard ? pb.getField(1, dir)
var direction = PagingDirection(dir)
ok(direction)
proc init*(T: type PagingInfo, buffer: seq[byte]): ProtoResult[T] =
## creates and returns a PagingInfo object out of buffer
var pagingInfo = PagingInfo()
@ -125,9 +105,9 @@ proc init*(T: type PagingInfo, buffer: seq[byte]): ProtoResult[T] =
discard ? pb.getField(2, cursorBuffer)
pagingInfo.cursor = ? Index.init(cursorBuffer)
var directionBuffer: seq[byte]
discard ? pb.getField(3, directionBuffer)
pagingInfo.direction = ? PagingDirection.init(directionBuffer)
var direction: uint32
discard ? pb.getField(3, direction)
pagingInfo.direction = PagingDirection(direction)
ok(pagingInfo)