test: access status-go functions directly instead of using callprivaterpc

This commit is contained in:
Richard Ramos 2021-10-08 08:49:37 -04:00
parent 72a32ee725
commit 2963e48366
No known key found for this signature in database
GPG Key ID: 80D4B01265FDFE8F
3 changed files with 26 additions and 2 deletions

View File

@ -4,6 +4,9 @@ import ../types/[chat, message, community, activity_center_notification,
status_update, rpc_response, setting, sticker]
import ./settings as status_settings
from status_go/chat as status_go_chat import nil
proc loadFilters*(filters: seq[JsonNode]): string =
result = callPrivateRPC("loadFilters".prefix, %* [filter(filters, proc(x:JsonNode):bool = x.kind != JNull)])
@ -45,13 +48,34 @@ proc createProfileChat*(pubKey: string):string =
callPrivateRPC("createProfileChat".prefix, %* [{ "ID": pubKey }])
proc loadChats*(): seq[Chat] =
echo "ACCESING CHATS VIA CALLRPC ==============="
result = @[]
let time2 = cpuTime()
let jsonResponse = parseJson($callPrivateRPC("chats".prefix))
if jsonResponse["result"].kind != JNull:
for jsonChat in jsonResponse{"result"}:
let chat = jsonChat.toChat
if chat.isActive and chat.chatType != ChatType.Unknown:
result.add(chat)
let resTime2 = cpuTime() - time2
echo "Time taken: ", resTime2
echo "ACCESSING CHATS DIRECTLY ==============="
let time = cpuTime()
let chats = status_go_chat.chats()
let resTime1 = cpuTime() - time
echo "Time taken: ", resTime1
# for c in chats:
# echo "Chat: ......"
# echo "- id: ", c.id
# echo "- timestamp: ", c.timestamp
# echo "- active: ", c.active
# echo "- name: ", c.name
# echo "- type: ", c.chatType
echo "Speedup improvement: ", resTime2 / resTime1 * 100, "%"
proc statusUpdates*(): seq[StatusUpdate] =
let rpcResult = callPrivateRPC("statusUpdates".prefix, %* []).parseJson()["result"]

@ -1 +1 @@
Subproject commit b60faf96449cb9ba9c6494abf7a3fcbaa7849c17
Subproject commit b82f8b35e302f7759346145c00b0836f5168ef32

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit c3ced098390f3d4e8d4850d9c0bf6e7dbd627c20
Subproject commit 008afcd854675c58617328a3cca68cb45126481e