-
Notifications
You must be signed in to change notification settings - Fork 79
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
Test coverage for cryptomath #281
Conversation
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.
Apart from the comments inline, the change looks good.
@@ -194,6 +194,16 @@ def test_numBits(self, number): | |||
def test_numBytes(self, number): | |||
self.assertEqual(numBytes(number), self.num_bytes(number)) | |||
|
|||
|
|||
class TestPowMod(unittest.TestCase): | |||
def test_with_small_numerts(self): |
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.
The numerts
looks like a typo.
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.
indeed it is, fixed
tlslite/utils/cryptomath.py
Outdated
@@ -253,8 +253,7 @@ def numBytes(n): | |||
# ************************************************************************** | |||
|
|||
def getRandomNumber(low, high): | |||
if low >= high: | |||
raise AssertionError() | |||
assert low <= high |
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 should say low < high
to preserve the same semantics. Does it make sense to generate random, where low == high? If so, the change in semantics should be reflected in the commit message.
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.
good catch, fixed
don't rise the assert directly, makes the exception more readable and code coverage happy
the negative power is not used anywhere in the code and gmpy does not actually support it either so remove this code
4123c3c
to
eb5c1fa
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.
Looks good now
@Jakuje thanks for the review! |
Increase test coverage for cryptomath.py module, remove dead code
This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)