From 3a0080281f1f3ac0e8ebf3eca7a6cf9692eaff19 Mon Sep 17 00:00:00 2001 From: Igor Sirotin Date: Fri, 6 Dec 2024 20:45:28 +0000 Subject: [PATCH] fix_: create/restore account error signal (#6174) * fix_: publish node.login signal with error * test_: use node.login signal instead of node.ready --- mobile/status.go | 4 ++-- tests-functional/clients/signals.py | 6 ++++++ tests-functional/clients/status_backend.py | 7 +++++-- tests-functional/tests/test_cases.py | 4 ++-- tests-functional/tests/test_init_status_app.py | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/mobile/status.go b/mobile/status.go index cde0f6d05..b0c5c792e 100644 --- a/mobile/status.go +++ b/mobile/status.go @@ -531,7 +531,7 @@ func createAccountAndLogin(requestJSON string) string { _, err := statusBackend.CreateAccountAndLogin(&request) if err != nil { logutils.ZapLogger().Error("failed to create account", zap.Error(err)) - return err + return statusBackend.LoggedIn("", err) } logutils.ZapLogger().Debug("started a node, and created account") return nil @@ -603,7 +603,7 @@ func restoreAccountAndLogin(requestJSON string) string { if err != nil { logutils.ZapLogger().Error("failed to restore account", zap.Error(err)) - return err + return statusBackend.LoggedIn("", err) } logutils.ZapLogger().Debug("started a node, and restored account") return nil diff --git a/tests-functional/clients/signals.py b/tests-functional/clients/signals.py index 0b7682da1..127d0f23e 100644 --- a/tests-functional/clients/signals.py +++ b/tests-functional/clients/signals.py @@ -87,6 +87,12 @@ class SignalClient: return self.received_signals[signal_type]["received"][-1] return self.received_signals[signal_type]["received"][-delta_count:] + def wait_for_login(self): + signal = self.wait_for_signal(SignalType.NODE_LOGIN.value) + if "error" in signal["event"]: + assert not signal["event"]["error"] + return signal + def find_signal_containing_pattern(self, signal_type, event_pattern, timeout=20): start_time = time.time() while True: diff --git a/tests-functional/clients/status_backend.py b/tests-functional/clients/status_backend.py index 989a0f875..16cb0c3f4 100644 --- a/tests-functional/clients/status_backend.py +++ b/tests-functional/clients/status_backend.py @@ -64,6 +64,9 @@ class StatusBackend(RpcClient, SignalClient): method = "InitializeApplication" data = { "dataDir": data_dir, + "logEnabled": True, + "logLevel": "DEBUG", + "apiLogging": True, } return self.api_valid_request(method, data) @@ -76,7 +79,7 @@ class StatusBackend(RpcClient, SignalClient): "password": password, "customizationColor": "primary", "logEnabled": True, - "logLevel": "INFO", + "logLevel": "DEBUG", } return self.api_valid_request(method, data) @@ -90,7 +93,7 @@ class StatusBackend(RpcClient, SignalClient): "mnemonic": user.passphrase, "customizationColor": "blue", "logEnabled": True, - "logLevel": "INFO", + "logLevel": "DEBUG", "testNetworksEnabled": True, "networkId": 31337, "networksOverride": [ diff --git a/tests-functional/tests/test_cases.py b/tests-functional/tests/test_cases.py index 3fdb67420..9bce878db 100644 --- a/tests-functional/tests/test_cases.py +++ b/tests-functional/tests/test_cases.py @@ -25,7 +25,7 @@ class StatusDTestCase: class StatusBackendTestCase: await_signals = [ - SignalType.NODE_READY.value + SignalType.NODE_LOGIN.value ] def setup_class(self): @@ -33,7 +33,7 @@ class StatusBackendTestCase: self.rpc_client.init_status_backend() self.rpc_client.restore_account_and_login() - self.rpc_client.wait_for_signal(SignalType.NODE_READY.value) + self.rpc_client.wait_for_login() self.network_id = 31337 diff --git a/tests-functional/tests/test_init_status_app.py b/tests-functional/tests/test_init_status_app.py index 3fb35fc90..aa69f8dfc 100644 --- a/tests-functional/tests/test_init_status_app.py +++ b/tests-functional/tests/test_init_status_app.py @@ -30,7 +30,7 @@ class TestInitialiseApp: backend_client.verify_json_schema( backend_client.wait_for_signal(SignalType.NODE_READY.value), "signal_node_ready") backend_client.verify_json_schema( - backend_client.wait_for_signal(SignalType.NODE_LOGIN.value), "signal_node_login") + backend_client.wait_for_login(), "signal_node_login") @pytest.mark.rpc