-
Notifications
You must be signed in to change notification settings - Fork 4
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
Investigate and fix random NodeGraph
test failures
#274
Comments
Multiple suggestions to fix this:
Mock documentation is on jest, but because we are using TS, we need to ensure that TS doesn't complain about types. So you would want to mock the nodeid/rootkey that is being provided by the KeyManager. But you should probably need to fix the node id operations, since char code increment is not correct anyway. |
Consider changing the timeouts in the code when doing these tests too. Jest also supports timeout mocking that can help too: https://jestjs.io/blog/2020/05/05/jest-26#new-fake-timers |
I've added a note that this would be blocked by #261. This is because the current |
Regarding mocking from this earlier comment #274 (comment), can look into the following for mocking only a single function: https://stackoverflow.com/questions/59312671/mock-only-one-function-from-module-but-leave-rest-with-original-functionality (originally brought up in #283 (comment)) |
There's some discussion of function mocking in #283: |
Seems that mocking with a static keypair has also created problems for the nodes tests, as per #283 (comment). Off the top of my head, not too sure what could be causing this - I thought I was mutating node IDs directly, as opposed to creating new keypairs. But will investigate this when looking into this issue too. |
I should also add an exception thrown for when we attempt to calculate the bucket index with a target node ID that matches the current node ID. This currently (albeit, incorrectly) returns -1 for the bucket index, which causes some hard-to-trace problems when debugging (most recently here #278 (comment)). Alternatively, find the calls to this function, and prevent this calculation from occurring at all. |
What was the resolution to this issue? @joshuakarp @tegefaulkes can you describe how #310 solved this? |
The problems was caused by |
Describe the bug
The tests in
NodeGraph
can intermittently fail across runs. We'd experienced some similar failures in the past, and I thought I'd resolved them. The past failures were to do with some test utility functions that generate node IDs for a specific bucket index, such that they can be used for dynamic testing. They were previously causing failures by generating node IDs that overflowed into a different bucket index.If this is still the cause of failure, now that we can use the 32 byte array as a node ID, I can potentially make these test utilities a bit more robust. Previously, they were just incrementing a character in the node ID to force an expected XOR value.
To Reproduce
The test failures only occur randomly. It took me 5 runs of
NodeGraph.test.ts
to experience a failure in the tests. Some instances of these:I've found it useful to use the
!#
in the terminal to repeat the command (repeats everything prior). e.g.npm test -- tests/nodes/NodeGraph.test.ts; !# !#
to run the tests 4 times.Additional context
vaultsrefactoring
MR aboutNodeGraph
test failures: https://gitlab.com/MatrixAI/Engineering/Polykey/js-polykey/-/merge_requests/205#note_695753874The text was updated successfully, but these errors were encountered: