Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Enable flow-based test scenarios #339

Merged
merged 53 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
563bbff
initial testable flows
kdmukai Feb 27, 2023
3824fd3
run_before View injection; full basic MainMenuView test flow
kdmukai Feb 28, 2023
5a1c4b7
Simplification - require Screen class as first arg in View.run_screen()
kdmukai Feb 28, 2023
1aeef3f
Updating to latest approach
kdmukai Feb 28, 2023
cd0f98b
Update view.py
kdmukai Feb 28, 2023
eed34a6
Merge branch 'dev' into test_flows
kdmukai Mar 3, 2023
d9b4db2
Merge branch 'dev' into test_flows
kdmukai Mar 3, 2023
c61de85
New BaseTest structure; new FlowStep sequence testing
kdmukai Mar 4, 2023
b03222c
Update test_flows_tools.py
kdmukai Mar 5, 2023
2d9bf13
More extensive tools_view testing; BaseTest fixes
kdmukai Mar 5, 2023
4f1df7a
Slight BaseTest reorg; more comments
kdmukai Mar 5, 2023
25cb92a
Improved integration w/View.button_data options
kdmukai Mar 6, 2023
1ff8440
Cleanup, beginning to split requirements.txt
kdmukai Mar 12, 2023
3670e7e
Merge branch 'psbt_screens_import_fix' into test_flows
kdmukai Mar 12, 2023
47bf2c3
Merge branch 'python3_10_update' into test_flows
kdmukai Mar 12, 2023
320a799
Documentation update for splitting dependencies
kdmukai Mar 12, 2023
6f2f683
Removing Pillow 9.x change
kdmukai Mar 12, 2023
c82d6a1
Merge branch 'python3_10_update' into test_flows
kdmukai Mar 12, 2023
b46a0be
Flow-based tests now incorporate the Controller's main loop
kdmukai Mar 31, 2023
37d3231
Merge branch 'dev' into test_flows
kdmukai Mar 31, 2023
eee5b5e
Indentation level bugfix
kdmukai Mar 31, 2023
c2f3c94
Adds test flows for view.py; cleanup
kdmukai Mar 31, 2023
9c18e97
Light cleanup; additional core FlowTest tests
kdmukai Apr 13, 2023
d111962
Updates after PR Review Club
kdmukai Apr 14, 2023
8e56803
added comment
kdmukai Apr 14, 2023
698273e
Update test_flows_seed.py
kdmukai Apr 14, 2023
696f599
Interim commit; refactoring View.run_screen patch
kdmukai Apr 18, 2023
57ece3c
removing now-unnecessary `button_data` edits
kdmukai Apr 24, 2023
81ea078
More `button_data` cleanup
kdmukai Apr 24, 2023
50e3a36
Update settings_views.py
kdmukai Apr 24, 2023
63ff9c0
Update settings_views.py
kdmukai Apr 24, 2023
78904fd
Update settings_views.py
kdmukai Apr 24, 2023
2e91267
Update tools_views.py
kdmukai Apr 24, 2023
2aa851d
Update view.py
kdmukai Apr 24, 2023
6a77636
Merge branch 'dev' into test_flows
kdmukai Jun 17, 2023
3748a4a
add psbt scan to sign flow happy path
newtonick Apr 14, 2023
91400bc
remove extra StopControllerCommand in test and fix PSBTFinalizeView
newtonick Apr 14, 2023
69ab92d
update test_flows_psbt.py to work with base.py breaking changes
newtonick Jun 29, 2023
1353747
Merge branch 'dev' into test_flows
kdmukai Jul 2, 2023
9b39590
Additional flow-specific test exceptions, reorg
kdmukai Jul 7, 2023
bf920be
Merge pull request #4 from newtonick/nick_test_flows
kdmukai Jul 7, 2023
3c4c91a
baby steps for jdlcdl (post hard reset)
Jun 17, 2023
7edc14f
exhaustive flow test for exporting standard xpubs
Jun 20, 2023
ac2d92c
settings constants instead of lazy hardcoding
Jun 20, 2023
1509df7
flow test: export xpub for custom derivation
Jun 20, 2023
b842f1f
local import of LoadScreenThread to avoid flow-test warnings
Jun 20, 2023
39962b9
more consistent with existing convention
Jun 22, 2023
e25de29
Export xpub flow test for disabled sig/script/coord settings
Jun 22, 2023
35b3dc6
code cleanup
Jul 4, 2023
01c4f51
more precise flow-test exceptions
Jul 7, 2023
b843b6b
pr_339 post-review comments implemented
Jul 8, 2023
4ce3fba
Merge pull request #5 from jdlcdl/pr_339
kdmukai Jul 15, 2023
94abdd3
Merge branch 'dev' into test_flows
newtonick Jul 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/manual_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ cd seedsigner
```bash
# Takes 1hr 45min on a Pi Zero 1.3
pip install -r requirements.txt
pip install -r requirements-raspi.txt
```

#### `pyzbar`
Expand Down
3 changes: 3 additions & 0 deletions requirements-raspi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
picamera==1.13
RPi.GPIO==0.7.0
spidev==3.5
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
embit==0.7.0
numpy==1.21.1
picamera==1.13
Pillow==8.2.0
-e git+https://github.com/seedsigner/pyzbar.git@c3c237821c6a20b17953efe59b90df0b514a1c03#egg=pyzbar
qrcode==7.3.1
RPi.GPIO==0.7.0
six==1.16.0
spidev==3.5
urtypes @ git+https://github.com/selfcustody/urtypes.git@7fb280eab3b3563dfc57d2733b0bf5cbc0a96a6a
44 changes: 42 additions & 2 deletions src/seedsigner/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ def __repr__(self):



class StopFlowBasedTest(Exception):
"""
This is a special exception that is only raised by the test suite to stop the
Controller's main loop. It should not be raised by any other code.
"""
pass


class FlowBasedTestException(Exception):
"""
This is a special exception that is only raised by the test suite.
It should not be raised by any other code.
"""
pass



class Controller(Singleton):
"""
The Controller is a globally available singleton that maintains SeedSigner state.
Expand Down Expand Up @@ -185,7 +202,13 @@ def clear_back_stack(self):
self.back_stack = BackStack()


def start(self) -> None:
def start(self, initial_destination: Destination = None) -> None:
"""
The main loop of the application.

* initial_destination: The first View to run. If None, the MainMenuView is
used. Only used by the test suite.
"""
from .views import MainMenuView, BackStackView
from .views.screensaver import OpeningSplashScreen

Expand Down Expand Up @@ -218,7 +241,10 @@ def run(self):
View_cls(**init_args).run()
"""
try:
next_destination = Destination(MainMenuView)
if initial_destination:
next_destination = initial_destination
else:
next_destination = Destination(MainMenuView)
while True:
# Destination(None) is a special case; render the Home screen
if next_destination.View_cls is None:
Expand All @@ -240,10 +266,24 @@ def run(self):
print(f"back_stack: {self.back_stack}")

try:
# Instantiate the View class and run it
print(f"Executing {next_destination}")
next_destination = next_destination.run()

except StopFlowBasedTest:
# This is a special exception that is only raised by the test suite
# to stop the Controller loop and exit the test.
return

except FlowBasedTestException as e:
# This is a special exception that is only raised by the test suite.
# Re-raise so the test suite can handle it.
raise e

except Exception as e:
# Display user-friendly error screen w/debugging info
import traceback
traceback.print_exc()
next_destination = self.handle_exception(e)

if not next_destination:
Expand Down
2 changes: 1 addition & 1 deletion src/seedsigner/models/settings_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class SettingsEntry:
visibility: str = SettingsConstants.VISIBILITY__GENERAL
type: str = SettingsConstants.TYPE__ENABLED_DISABLED
help_text: str = None
selection_options: List[str] = None
selection_options: list[tuple[str | int], str] = None
default_value: Any = None

def __post_init__(self):
Expand Down
Loading