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

Check terminal encoding #101

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

yorickdowne
Copy link

@yorickdowne yorickdowne commented Aug 26, 2024

Resolves #34

Changes

Checks for utf-8 terminal encoding on password strength check. If not utf-8 and the password isn't ASCII, ask the user to retype.

If the platform is not Windows, suggest to switch to a utf-8 terminal instead.

utf-8 terminal is not a standard on Windows, it uses "a zoo of code pages"

utf-8 console on Windows in Python is alas also not a thing. PEP528 has been around since 2016, don't hold your breath.

Types of changes

What types of changes does your code introduce?

  • New feature (a non-breaking change that adds functionality)

Testing

Notes on testing

The reason this failed in the Windows runner for staking-deposit-cli was that they checked only for utf-8, and Windows does not do utf-8.

@yorickdowne yorickdowne force-pushed the term-encoding branch 2 times, most recently from a516686 to c2688e7 Compare August 26, 2024 20:49
@yorickdowne yorickdowne marked this pull request as draft August 26, 2024 20:53
@yorickdowne yorickdowne force-pushed the term-encoding branch 5 times, most recently from c2eeae2 to b77986f Compare August 27, 2024 00:49
@yorickdowne yorickdowne marked this pull request as ready for review August 27, 2024 00:49
@yorickdowne yorickdowne force-pushed the term-encoding branch 2 times, most recently from 291efc3 to 1dfa326 Compare August 27, 2024 00:59
@yorickdowne
Copy link
Author

yorickdowne commented Aug 27, 2024

So the question is - are we doing more harm than good. How much do we care about the zoo of code pages on Windows?

Windows Terminal can now do utf-8. That's always an option, just additional steps that will likely not be intuitive to the user.

We could also decide to not exit on Windows at all. And instead if it's not utf-8 and it's Windows, output a message that says "please stick to ASCII characters". WDYT?

@yorickdowne yorickdowne marked this pull request as draft August 27, 2024 13:21
@yorickdowne yorickdowne marked this pull request as ready for review August 31, 2024 06:12
@yorickdowne yorickdowne added the run-tests Request tests to run on the CI label Aug 31, 2024
Copy link

Test Coverage: Download HTML Report

Name                                                        Stmts   Miss  Cover
-------------------------------------------------------------------------------
ethstaker_deposit/__init__.py                                   0      0   100%
ethstaker_deposit/cli/__init__.py                               0      0   100%
ethstaker_deposit/cli/existing_mnemonic.py                     28      0   100%
ethstaker_deposit/cli/exit_transaction_keystore.py             39      2    95%
ethstaker_deposit/cli/exit_transaction_mnemonic.py             62      8    87%
ethstaker_deposit/cli/generate_bls_to_execution_change.py      66     15    77%
ethstaker_deposit/cli/generate_keys.py                         43      3    93%
ethstaker_deposit/cli/new_mnemonic.py                          26      0   100%
ethstaker_deposit/cli/partial_deposit.py                       61      5    92%
ethstaker_deposit/credentials.py                              197     68    65%
ethstaker_deposit/deposit.py                                   62     16    74%
ethstaker_deposit/exceptions.py                                 2      0   100%
ethstaker_deposit/key_handling/__init__.py                      0      0   100%
ethstaker_deposit/key_handling/key_derivation/__init__.py       0      0   100%
ethstaker_deposit/key_handling/key_derivation/mnemonic.py      90      7    92%
ethstaker_deposit/key_handling/key_derivation/path.py          18      1    94%
ethstaker_deposit/key_handling/key_derivation/tree.py          37      0   100%
ethstaker_deposit/key_handling/keystore.py                    100      0   100%
ethstaker_deposit/settings.py                                  22      1    95%
ethstaker_deposit/utils/__init__.py                             0      0   100%
ethstaker_deposit/utils/ascii_art.py                            2      0   100%
ethstaker_deposit/utils/click.py                               56      3    95%
ethstaker_deposit/utils/config.py                               3      0   100%
ethstaker_deposit/utils/constants.py                           27      0   100%
ethstaker_deposit/utils/crypto.py                              29      1    97%
ethstaker_deposit/utils/deposit.py                              9      0   100%
ethstaker_deposit/utils/exit_transaction.py                    24      0   100%
ethstaker_deposit/utils/file_handling.py                        8      0   100%
ethstaker_deposit/utils/intl.py                                54      3    94%
ethstaker_deposit/utils/ssz.py                                 50      6    88%
ethstaker_deposit/utils/validation.py                         198     51    74%
-------------------------------------------------------------------------------
TOTAL                                                        1313    190    86%

@yorickdowne yorickdowne force-pushed the term-encoding branch 2 times, most recently from 831e5b0 to 5ac6fa9 Compare September 1, 2024 02:07
Copy link

github-actions bot commented Sep 1, 2024

Test Coverage: Download HTML Report

Name                                                        Stmts   Miss  Cover
-------------------------------------------------------------------------------
ethstaker_deposit/__init__.py                                   0      0   100%
ethstaker_deposit/cli/__init__.py                               0      0   100%
ethstaker_deposit/cli/existing_mnemonic.py                     28      0   100%
ethstaker_deposit/cli/exit_transaction_keystore.py             39      2    95%
ethstaker_deposit/cli/exit_transaction_mnemonic.py             62      8    87%
ethstaker_deposit/cli/generate_bls_to_execution_change.py      66     15    77%
ethstaker_deposit/cli/generate_keys.py                         43      3    93%
ethstaker_deposit/cli/new_mnemonic.py                          26      0   100%
ethstaker_deposit/cli/partial_deposit.py                       61      5    92%
ethstaker_deposit/credentials.py                              197     68    65%
ethstaker_deposit/deposit.py                                   54     10    81%
ethstaker_deposit/exceptions.py                                 2      0   100%
ethstaker_deposit/key_handling/__init__.py                      0      0   100%
ethstaker_deposit/key_handling/key_derivation/__init__.py       0      0   100%
ethstaker_deposit/key_handling/key_derivation/mnemonic.py      90      7    92%
ethstaker_deposit/key_handling/key_derivation/path.py          17      1    94%
ethstaker_deposit/key_handling/key_derivation/tree.py          36      0   100%
ethstaker_deposit/key_handling/keystore.py                    100      0   100%
ethstaker_deposit/settings.py                                  22      1    95%
ethstaker_deposit/utils/__init__.py                             0      0   100%
ethstaker_deposit/utils/ascii_art.py                            2      0   100%
ethstaker_deposit/utils/click.py                               56      3    95%
ethstaker_deposit/utils/config.py                               3      0   100%
ethstaker_deposit/utils/constants.py                           27      0   100%
ethstaker_deposit/utils/crypto.py                              29      1    97%
ethstaker_deposit/utils/deposit.py                              9      0   100%
ethstaker_deposit/utils/exit_transaction.py                    24      0   100%
ethstaker_deposit/utils/file_handling.py                        8      0   100%
ethstaker_deposit/utils/intl.py                                54      3    94%
ethstaker_deposit/utils/ssz.py                                 50      6    88%
ethstaker_deposit/utils/validation.py                         204     54    74%
-------------------------------------------------------------------------------
TOTAL                                                        1309    187    86%

Copy link

github-actions bot commented Sep 1, 2024

Test Coverage: Download HTML Report

Name                                                        Stmts   Miss  Cover
-------------------------------------------------------------------------------
ethstaker_deposit/__init__.py                                   0      0   100%
ethstaker_deposit/cli/__init__.py                               0      0   100%
ethstaker_deposit/cli/existing_mnemonic.py                     28      0   100%
ethstaker_deposit/cli/exit_transaction_keystore.py             39      2    95%
ethstaker_deposit/cli/exit_transaction_mnemonic.py             62      8    87%
ethstaker_deposit/cli/generate_bls_to_execution_change.py      66     15    77%
ethstaker_deposit/cli/generate_keys.py                         43      3    93%
ethstaker_deposit/cli/new_mnemonic.py                          26      0   100%
ethstaker_deposit/cli/partial_deposit.py                       61      5    92%
ethstaker_deposit/credentials.py                              197     68    65%
ethstaker_deposit/deposit.py                                   54     10    81%
ethstaker_deposit/exceptions.py                                 2      0   100%
ethstaker_deposit/key_handling/__init__.py                      0      0   100%
ethstaker_deposit/key_handling/key_derivation/__init__.py       0      0   100%
ethstaker_deposit/key_handling/key_derivation/mnemonic.py      90      7    92%
ethstaker_deposit/key_handling/key_derivation/path.py          17      1    94%
ethstaker_deposit/key_handling/key_derivation/tree.py          36      0   100%
ethstaker_deposit/key_handling/keystore.py                    100      0   100%
ethstaker_deposit/settings.py                                  22      1    95%
ethstaker_deposit/utils/__init__.py                             0      0   100%
ethstaker_deposit/utils/ascii_art.py                            2      0   100%
ethstaker_deposit/utils/click.py                               56      3    95%
ethstaker_deposit/utils/config.py                               3      0   100%
ethstaker_deposit/utils/constants.py                           27      0   100%
ethstaker_deposit/utils/crypto.py                              29      1    97%
ethstaker_deposit/utils/deposit.py                              9      0   100%
ethstaker_deposit/utils/exit_transaction.py                    24      0   100%
ethstaker_deposit/utils/file_handling.py                        8      0   100%
ethstaker_deposit/utils/intl.py                                54      3    94%
ethstaker_deposit/utils/ssz.py                                 50      6    88%
ethstaker_deposit/utils/validation.py                         204     54    74%
-------------------------------------------------------------------------------
TOTAL                                                        1309    187    86%

@yorickdowne yorickdowne force-pushed the term-encoding branch 3 times, most recently from 0f4e831 to bb102bf Compare September 1, 2024 23:37
Copy link

github-actions bot commented Sep 1, 2024

Test Coverage: Download HTML Report

Name                                                        Stmts   Miss  Cover
-------------------------------------------------------------------------------
ethstaker_deposit/__init__.py                                   0      0   100%
ethstaker_deposit/cli/__init__.py                               0      0   100%
ethstaker_deposit/cli/existing_mnemonic.py                     28      0   100%
ethstaker_deposit/cli/exit_transaction_keystore.py             39      2    95%
ethstaker_deposit/cli/exit_transaction_mnemonic.py             62      8    87%
ethstaker_deposit/cli/generate_bls_to_execution_change.py      66     15    77%
ethstaker_deposit/cli/generate_keys.py                         43      3    93%
ethstaker_deposit/cli/new_mnemonic.py                          26      0   100%
ethstaker_deposit/cli/partial_deposit.py                       61      5    92%
ethstaker_deposit/credentials.py                              197     68    65%
ethstaker_deposit/deposit.py                                   54     10    81%
ethstaker_deposit/exceptions.py                                 2      0   100%
ethstaker_deposit/key_handling/__init__.py                      0      0   100%
ethstaker_deposit/key_handling/key_derivation/__init__.py       0      0   100%
ethstaker_deposit/key_handling/key_derivation/mnemonic.py      90      7    92%
ethstaker_deposit/key_handling/key_derivation/path.py          17      1    94%
ethstaker_deposit/key_handling/key_derivation/tree.py          36      0   100%
ethstaker_deposit/key_handling/keystore.py                    100      0   100%
ethstaker_deposit/settings.py                                  22      1    95%
ethstaker_deposit/utils/__init__.py                             0      0   100%
ethstaker_deposit/utils/ascii_art.py                            2      0   100%
ethstaker_deposit/utils/click.py                               70      3    96%
ethstaker_deposit/utils/config.py                               3      0   100%
ethstaker_deposit/utils/constants.py                           27      0   100%
ethstaker_deposit/utils/crypto.py                              29      1    97%
ethstaker_deposit/utils/deposit.py                              9      0   100%
ethstaker_deposit/utils/exit_transaction.py                    24      0   100%
ethstaker_deposit/utils/file_handling.py                        8      0   100%
ethstaker_deposit/utils/intl.py                                54      3    94%
ethstaker_deposit/utils/ssz.py                                 50      6    88%
ethstaker_deposit/utils/validation.py                         204     51    75%
-------------------------------------------------------------------------------
TOTAL                                                        1323    184    86%

Copy link

github-actions bot commented Sep 2, 2024

Test Coverage: Download HTML Report

Name                                                        Stmts   Miss  Cover
-------------------------------------------------------------------------------
ethstaker_deposit/__init__.py                                   0      0   100%
ethstaker_deposit/cli/__init__.py                               0      0   100%
ethstaker_deposit/cli/existing_mnemonic.py                     28      0   100%
ethstaker_deposit/cli/exit_transaction_keystore.py             39      2    95%
ethstaker_deposit/cli/exit_transaction_mnemonic.py             62      8    87%
ethstaker_deposit/cli/generate_bls_to_execution_change.py      66     15    77%
ethstaker_deposit/cli/generate_keys.py                         43      3    93%
ethstaker_deposit/cli/new_mnemonic.py                          26      0   100%
ethstaker_deposit/cli/partial_deposit.py                       61      5    92%
ethstaker_deposit/credentials.py                              197     68    65%
ethstaker_deposit/deposit.py                                   54     10    81%
ethstaker_deposit/exceptions.py                                 2      0   100%
ethstaker_deposit/key_handling/__init__.py                      0      0   100%
ethstaker_deposit/key_handling/key_derivation/__init__.py       0      0   100%
ethstaker_deposit/key_handling/key_derivation/mnemonic.py      90      7    92%
ethstaker_deposit/key_handling/key_derivation/path.py          17      1    94%
ethstaker_deposit/key_handling/key_derivation/tree.py          36      0   100%
ethstaker_deposit/key_handling/keystore.py                    100      0   100%
ethstaker_deposit/settings.py                                  22      1    95%
ethstaker_deposit/utils/__init__.py                             0      0   100%
ethstaker_deposit/utils/ascii_art.py                            2      0   100%
ethstaker_deposit/utils/click.py                               70      3    96%
ethstaker_deposit/utils/config.py                               3      0   100%
ethstaker_deposit/utils/constants.py                           27      0   100%
ethstaker_deposit/utils/crypto.py                              29      1    97%
ethstaker_deposit/utils/deposit.py                              9      0   100%
ethstaker_deposit/utils/exit_transaction.py                    24      0   100%
ethstaker_deposit/utils/file_handling.py                        8      0   100%
ethstaker_deposit/utils/intl.py                                54      3    94%
ethstaker_deposit/utils/ssz.py                                 50      6    88%
ethstaker_deposit/utils/validation.py                         204     51    75%
-------------------------------------------------------------------------------
TOTAL                                                        1323    184    86%

Copy link

github-actions bot commented Sep 2, 2024

Test Coverage: Download HTML Report

Name                                                        Stmts   Miss  Cover
-------------------------------------------------------------------------------
ethstaker_deposit/__init__.py                                   0      0   100%
ethstaker_deposit/cli/__init__.py                               0      0   100%
ethstaker_deposit/cli/existing_mnemonic.py                     28      0   100%
ethstaker_deposit/cli/exit_transaction_keystore.py             39      2    95%
ethstaker_deposit/cli/exit_transaction_mnemonic.py             62      8    87%
ethstaker_deposit/cli/generate_bls_to_execution_change.py      66     15    77%
ethstaker_deposit/cli/generate_keys.py                         43      3    93%
ethstaker_deposit/cli/new_mnemonic.py                          26      0   100%
ethstaker_deposit/cli/partial_deposit.py                       61      5    92%
ethstaker_deposit/credentials.py                              197     68    65%
ethstaker_deposit/deposit.py                                   54     10    81%
ethstaker_deposit/exceptions.py                                 2      0   100%
ethstaker_deposit/key_handling/__init__.py                      0      0   100%
ethstaker_deposit/key_handling/key_derivation/__init__.py       0      0   100%
ethstaker_deposit/key_handling/key_derivation/mnemonic.py      90      7    92%
ethstaker_deposit/key_handling/key_derivation/path.py          17      1    94%
ethstaker_deposit/key_handling/key_derivation/tree.py          36      0   100%
ethstaker_deposit/key_handling/keystore.py                    100      0   100%
ethstaker_deposit/settings.py                                  22      1    95%
ethstaker_deposit/utils/__init__.py                             0      0   100%
ethstaker_deposit/utils/ascii_art.py                            2      0   100%
ethstaker_deposit/utils/click.py                               70      3    96%
ethstaker_deposit/utils/config.py                               3      0   100%
ethstaker_deposit/utils/constants.py                           27      0   100%
ethstaker_deposit/utils/crypto.py                              29      1    97%
ethstaker_deposit/utils/deposit.py                              9      0   100%
ethstaker_deposit/utils/exit_transaction.py                    24      0   100%
ethstaker_deposit/utils/file_handling.py                        8      0   100%
ethstaker_deposit/utils/intl.py                                54      3    94%
ethstaker_deposit/utils/ssz.py                                 50      6    88%
ethstaker_deposit/utils/validation.py                         204     51    75%
-------------------------------------------------------------------------------
TOTAL                                                        1323    184    86%

Copy link

github-actions bot commented Sep 2, 2024

Test Coverage: Download HTML Report

Name                                                        Stmts   Miss  Cover
-------------------------------------------------------------------------------
ethstaker_deposit/__init__.py                                   0      0   100%
ethstaker_deposit/cli/__init__.py                               0      0   100%
ethstaker_deposit/cli/existing_mnemonic.py                     28      0   100%
ethstaker_deposit/cli/exit_transaction_keystore.py             39      2    95%
ethstaker_deposit/cli/exit_transaction_mnemonic.py             62      8    87%
ethstaker_deposit/cli/generate_bls_to_execution_change.py      66     15    77%
ethstaker_deposit/cli/generate_keys.py                         43      3    93%
ethstaker_deposit/cli/new_mnemonic.py                          26      0   100%
ethstaker_deposit/cli/partial_deposit.py                       61      5    92%
ethstaker_deposit/credentials.py                              197     68    65%
ethstaker_deposit/deposit.py                                   54     10    81%
ethstaker_deposit/exceptions.py                                 2      0   100%
ethstaker_deposit/key_handling/__init__.py                      0      0   100%
ethstaker_deposit/key_handling/key_derivation/__init__.py       0      0   100%
ethstaker_deposit/key_handling/key_derivation/mnemonic.py      90      7    92%
ethstaker_deposit/key_handling/key_derivation/path.py          17      1    94%
ethstaker_deposit/key_handling/key_derivation/tree.py          36      0   100%
ethstaker_deposit/key_handling/keystore.py                    100      0   100%
ethstaker_deposit/settings.py                                  22      1    95%
ethstaker_deposit/utils/__init__.py                             0      0   100%
ethstaker_deposit/utils/ascii_art.py                            2      0   100%
ethstaker_deposit/utils/click.py                               70      3    96%
ethstaker_deposit/utils/config.py                               3      0   100%
ethstaker_deposit/utils/constants.py                           27      0   100%
ethstaker_deposit/utils/crypto.py                              29      1    97%
ethstaker_deposit/utils/deposit.py                              9      0   100%
ethstaker_deposit/utils/exit_transaction.py                    24      0   100%
ethstaker_deposit/utils/file_handling.py                        8      0   100%
ethstaker_deposit/utils/intl.py                                54      3    94%
ethstaker_deposit/utils/ssz.py                                 50      6    88%
ethstaker_deposit/utils/validation.py                         204     51    75%
-------------------------------------------------------------------------------
TOTAL                                                        1323    184    86%

@valefar-on-discord valefar-on-discord merged commit 537127e into eth-educators:main Sep 2, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-tests Request tests to run on the CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Certain encodings can make passwords invalid
2 participants