-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
fix: emulator.get_debug_state response #271
Conversation
src/emulator.py
Outdated
@@ -917,8 +917,7 @@ def get_debug_state() -> Dict[str, Any]: | |||
val = val.decode("utf-8") | |||
except UnicodeDecodeError: | |||
val = val.hex() | |||
|
|||
debug_state_dict[key] = val | |||
debug_state_dict[key] = val |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem right, it means we will only save byte values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, as i mentioned in the description and also discussed on slack, im aware that this isnt right but user-env crasches without it (tries to serialize complex field)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a fixup commit into this branch/PR, can you please confirm it works fine for you? I can merge it in a positive case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works for me, thanks
76c6add
to
dce4122
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready to merge
fixing problem 1:
get_debug_state
tries to serialize non buffer fields/keys (1 indent missing)edit: after further testing this change can be tricky.
DebugLinkState may contain some other filed types not only bytes (like int for example) but in the same time they might be complex and not serializable.
see thp state:
<DebugLinkState: {'mnemonic_secret': b'all all all all all all all all all all all all', 'passphrase_protection': False, 'reset_entropy': b'', 'mnemonic_type': <BackupType.Bip39: 0>, 'tokens': ['{', '"component"', ': ', '"SimplePage"', ', ', '"active_page"', ': ', '0', ', ', '"page_count"', ': ', '2', ', ', '"content"', ': ', '{', '"component"', ': ', '"AddressDetails"', ', ', '"qr_code"', ': ', '{', '"component"', ': ', '"Frame"', ', ', '"title"', ': ', '{', '"component"', ': ', '"Label"', ', ', '"text"', ': ', '"Scan QR code to pair"', '}', ', ', '"content"', ': ', '{', '"component"', ': ', '"Qr"', ', ', '"text"', ': ', '""', '}', ', ', '"button"', ': ', '{', '"component"', ': ', '"Button"', ', ', '"icon"', ': ', 'true', '}', '}', '}', '}'], 'thp_pairing_code_entry_code': 417041}>
fixing problem 2:
UI client assumes that
dataObject.response
is a string but in case of debug state it is an objectexample: send JSON to server