Open tegefaulkes opened 1 year ago
Some uses of sleep is to simulate time passing. However generally anything that relies on time should parameterise it so that the caller can pass in what it wants the time to be. This is a good practice not only for testing, but also for ensuring a bunch of operations is recorded with the same time.
That parameter can default to the now though for convenience. Removed a bunch of sleeps from NodeGraph.test.ts
would reduce testing time by a significant amount. 80%
Specification
We need to remove any non-deterministic use of
sleep()
in tests. Most if not all of these will be sleeps waiting for key change propagation to happen.To address this we need some way of knowing that the keys have finished changing. https://github.com/MatrixAI/Polykey/issues/594 addresses this in
Polykey
, but we need a change here.The keys renew and reset commands need to wait for key changes to fully propagate before ending. This will be updated in the client handlers on
Polykey
.Additional context
Tasks
sleep()
waiting for keys changes and replace it with waiting for an event.