krux icon indicating copy to clipboard operation
krux copied to clipboard

Cover 100% src/krux/key.py

Open qlrd opened this issue 8 months ago • 4 comments

What is this PR for?

  • Add a verbose message when an invalid policy type is used to create a bip39 key in get_default_descriptor static method;

  • add a fallback import case from urandom to random on tests/test_key.py/

  • add a raise exception case of an invalid policy type on tests/test_key.py.

Changes made to:

  • [ ] Code
  • [x] Tests
  • [ ] Docs
  • [ ] CHANGELOG

What is the purpose of this pull request?

  • [ ] Bug fix
  • [ ] New feature
  • [ ] Docs update
  • [x] Other: cover 100% src/krux/key.py.

qlrd avatar Apr 18 '25 18:04 qlrd

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.38%. Comparing base (d14a2ac) to head (a2e30d1). Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #573      +/-   ##
===========================================
+ Coverage    95.37%   95.38%   +0.01%     
===========================================
  Files           76       76              
  Lines         8607     8607              
===========================================
+ Hits          8209     8210       +1     
+ Misses         398      397       -1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Apr 18 '25 18:04 codecov[bot]

I've been thinking, for the sake of simplicity and standardization, we could remove the try/except with random, just use urandom, and remove the specific test too. This align with other cases like uhashlib, were we use the standard micropython lib, and mock it with respective complete implementations on tests, simulator and Android.

odudex avatar Apr 25 '25 19:04 odudex

I've been thinking, for the sake of simplicity and standardization, we could remove the try/except with random, just use urandom, and remove the specific test too. This align with other cases like uhashlib, were we use the standard micropython lib, and mock it with respective complete implementations on tests, simulator and Android.

Agreed, this resolves an unecessary test, some lint and less code to maintain

qlrd avatar Apr 29 '25 17:04 qlrd

I've been thinking, for the sake of simplicity and standardization, we could remove the try/except with random, just use urandom, and remove the specific test too. This align with other cases like uhashlib, were we use the standard micropython lib, and mock it with respective complete implementations on tests, simulator and Android.

fixed

qlrd avatar Apr 29 '25 18:04 qlrd

fixed

Did you test the simulator? I believe a mock for urandom which loads random will be needed

odudex avatar May 05 '25 11:05 odudex

Just noticed @tadeubas did the needed changes in #588.

odudex avatar May 05 '25 11:05 odudex

Thank you!

odudex avatar May 05 '25 11:05 odudex

fixed

Did you test the simulator? I believe a mock for urandom which loads random will be needed

Yes, made in simulator before #588

qlrd avatar May 05 '25 12:05 qlrd