Bugs in DiffieHellman > key exchange test suite

test_key_exchange and test_private_key_is_random will pass without any functions being implemented. They will also pass by returning arbitrary values.

As it currently stands I do not think this is a problem. Will you argue that it is?

Updating tests has a cost: tests will be re-run, previous submissions are invalidated, …

(Next time please include the names of the tests. Test numbers are ambiguous: they differ between the file, the web editor, and the local tests report.)

I have edited to include the names of the tests. Yes I think this is a problem. If a test always passes regardless of the result, then what is the point of the test? Presumably a test tests for some edge case so that a learner can know they have implemented properly. If it always passes, then it is not able to check for this condition.

They do not always pass. They just happen to pass when all functions return None.

(Though it is unclear to me why the first test passes in this case. I’m guessing exception handling inside the testing lib.)

I tried with arbitrary values and they still passed.

key exchange will pass for any constant function secret. This is not a bug.

private key is greater than 1 and less than p is faulty though: assertTrue is dumb and checks only bool(arg), and generators are truthy. This is a bug.

Correction: actually I cannot reproduce the second false positive. My previous comment was based on outdated tests.

However, the web editor does report a passing private key is greater than 1 and less than p, but that seems to be not really a test: it is not about any particular p. Also, it prints 'u's.

@jsertel Did you really mean test_private_key_is_random?