From 58edbf574d240fa053920d8c53bb09f747f67ff2 Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Mon, 17 Nov 2025 21:58:16 +0100 Subject: [PATCH] Add test --- tests/manual_test_nwcwallet.py | 2 +- tests/manual_test_nwcwallet_start_stop.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/manual_test_nwcwallet_start_stop.py diff --git a/tests/manual_test_nwcwallet.py b/tests/manual_test_nwcwallet.py index 1932074c..9d76cf6c 100644 --- a/tests/manual_test_nwcwallet.py +++ b/tests/manual_test_nwcwallet.py @@ -34,7 +34,6 @@ class TestNWCWallet(unittest.TestCase): print(f"error_callback called, error: {error}") self.error_callback_called += 1 - def update_balance(self, sats): """ Updates the user balance by 'sats' amount using the local API. @@ -193,3 +192,4 @@ class TestNWCWalletMultiRelay(unittest.TestCase): print("test finished") + diff --git a/tests/manual_test_nwcwallet_start_stop.py b/tests/manual_test_nwcwallet_start_stop.py new file mode 100644 index 00000000..9f3becc2 --- /dev/null +++ b/tests/manual_test_nwcwallet_start_stop.py @@ -0,0 +1,20 @@ +import time +import unittest + +import sys +sys.path.append("apps/com.lightningpiggy.displaywallet/assets/") +from wallet import NWCWallet + +class TestNWCWalletMultiRelayStartStop(unittest.TestCase): + + def unused_callback(self, arg1=None, arg2=None): + pass + + def test_quick_start_stop(self): + self.wallet = NWCWallet("nostr+walletconnect://e46762afab282c324278351165122345f9983ea447b47943b052100321227571?relay=ws://192.168.1.16:5000/nostrclient/api/v1/relay&relay=ws://127.0.0.1:5000/nostrrelay/test&secret=fab0a9a11d4cf4b1d92e901a0b2c56634275e2fa1a7eb396ff1b942f95d59fd3&lud16=test@example.com") + for iteration in range(20): + print(f"\n\nITERATION {iteration}\n\n") + self.wallet.start(self.unused_callback, self.unused_callback, self.unused_callback, self.unused_callback) + time.sleep(max(15-iteration,1)) # not giving any time to connect causes a bad state + self.wallet.stop() + time.sleep(0.2) # 0.1 seems to be okay most of the time, 0.2 is super stable