From 96e0be239fdd5e279f3d7ad3fb1a9f66856078ba Mon Sep 17 00:00:00 2001 From: Believethehype <1097224+believethehype@users.noreply.github.com> Date: Sun, 9 Jun 2024 12:46:44 +0200 Subject: [PATCH] adapting more functions to async --- tests/gui/nicegui/nostrAI_search_client.py | 12 ++++++------ tests/test_dvm_client.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/gui/nicegui/nostrAI_search_client.py b/tests/gui/nicegui/nostrAI_search_client.py index d8e52c2..246bcc0 100644 --- a/tests/gui/nicegui/nostrAI_search_client.py +++ b/tests/gui/nicegui/nostrAI_search_client.py @@ -13,7 +13,7 @@ from nostr_dvm.utils.definitions import EventDefinitions @ui.page('/', dark=True) -def init(): +async def init(): keys = Keys.parse(check_and_set_private_key("test_client")) opts = (Options().wait_for_send(False).send_timeout(timedelta(seconds=2)) .skip_disconnected_relays(True)) @@ -23,11 +23,11 @@ def init(): relay_list = dvmconfig.DVMConfig.RELAY_LIST for relay in relay_list: - client.add_relay(relay) - client.connect() + await client.add_relay(relay) + await client.connect() data = [] - def nostr_client_test_search(prompt, users=None, since="", until=""): + async def nostr_client_test_search(prompt, users=None, since="", until=""): if users is None: users = [] @@ -53,7 +53,7 @@ def init(): config = DVMConfig config.RELAY_LIST = relay_list - send_event(event, client=client, dvm_config=config) + await send_event(event, client=client, dvm_config=config) return event def handledvm(now, eventid): @@ -135,7 +135,7 @@ def init(): tags.append(pTag.as_vec()) search = str(search).replace("from:", "").replace("to:", "").replace("@", "").lstrip().rstrip() print(search) - ev = nostr_client_test_search(search, tags) + ev = await nostr_client_test_search(search, tags) ui.notify('Request sent to DVM, awaiting results..') print("Sent: " + ev.as_json()) diff --git a/tests/test_dvm_client.py b/tests/test_dvm_client.py index 86cfc31..c2737fe 100644 --- a/tests/test_dvm_client.py +++ b/tests/test_dvm_client.py @@ -148,7 +148,7 @@ async def nostr_client_test_inactive_filter(user): await client.add_relay_with_opts("wss://nostr.band", ropts) await client.connect() config = DVMConfig - send_event(event, client=client, dvm_config=config) + await send_event(event, client=client, dvm_config=config) return event.as_json() async def nostr_client_test_tts(prompt):