mirror of
https://github.com/status-im/status-lib.git
synced 2025-01-26 04:09:28 +00:00
test: access status-go functions directly instead of using callprivaterpc
This commit is contained in:
parent
72a32ee725
commit
2963e48366
@ -4,6 +4,9 @@ import ../types/[chat, message, community, activity_center_notification,
|
|||||||
status_update, rpc_response, setting, sticker]
|
status_update, rpc_response, setting, sticker]
|
||||||
import ./settings as status_settings
|
import ./settings as status_settings
|
||||||
|
|
||||||
|
|
||||||
|
from status_go/chat as status_go_chat import nil
|
||||||
|
|
||||||
proc loadFilters*(filters: seq[JsonNode]): string =
|
proc loadFilters*(filters: seq[JsonNode]): string =
|
||||||
result = callPrivateRPC("loadFilters".prefix, %* [filter(filters, proc(x:JsonNode):bool = x.kind != JNull)])
|
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 }])
|
callPrivateRPC("createProfileChat".prefix, %* [{ "ID": pubKey }])
|
||||||
|
|
||||||
proc loadChats*(): seq[Chat] =
|
proc loadChats*(): seq[Chat] =
|
||||||
|
echo "ACCESING CHATS VIA CALLRPC ==============="
|
||||||
result = @[]
|
result = @[]
|
||||||
|
let time2 = cpuTime()
|
||||||
let jsonResponse = parseJson($callPrivateRPC("chats".prefix))
|
let jsonResponse = parseJson($callPrivateRPC("chats".prefix))
|
||||||
if jsonResponse["result"].kind != JNull:
|
if jsonResponse["result"].kind != JNull:
|
||||||
for jsonChat in jsonResponse{"result"}:
|
for jsonChat in jsonResponse{"result"}:
|
||||||
let chat = jsonChat.toChat
|
let chat = jsonChat.toChat
|
||||||
if chat.isActive and chat.chatType != ChatType.Unknown:
|
if chat.isActive and chat.chatType != ChatType.Unknown:
|
||||||
result.add(chat)
|
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] =
|
proc statusUpdates*(): seq[StatusUpdate] =
|
||||||
let rpcResult = callPrivateRPC("statusUpdates".prefix, %* []).parseJson()["result"]
|
let rpcResult = callPrivateRPC("statusUpdates".prefix, %* []).parseJson()["result"]
|
||||||
|
2
vendor/nim-status-go
vendored
2
vendor/nim-status-go
vendored
@ -1 +1 @@
|
|||||||
Subproject commit b60faf96449cb9ba9c6494abf7a3fcbaa7849c17
|
Subproject commit b82f8b35e302f7759346145c00b0836f5168ef32
|
2
vendor/status-go
vendored
2
vendor/status-go
vendored
@ -1 +1 @@
|
|||||||
Subproject commit c3ced098390f3d4e8d4850d9c0bf6e7dbd627c20
|
Subproject commit 008afcd854675c58617328a3cca68cb45126481e
|
Loading…
x
Reference in New Issue
Block a user