activitypub-express icon indicating copy to clipboard operation
activitypub-express copied to clipboard

Federation background delivery process test fail

Open gregid opened this issue 4 years ago • 4 comments

Hi, going through your code as ActivityPub learning exercise as this is the nicest ActivityPub code I could find on the web!

Back to the point: I got 2 tests failing. Going through documentation you've warned about possible http-signature issue, but I didn't get the InvalidHeaderError, so I am raising this as an issue.

The tests were run on Windows 10, Node: v14.5.0, NPM: 6.14.5.

1) federation background delivery process backs off repeated attempts
  - Expected spy deliver to have been called 4 times. It was called 3 times.

2) federation background delivery process can restart delivery while retries are pending
  - Expected spy deliver to have been called 4 times. It was called 2 times.
  - Expected spy deliver to have been called 6 times. It was called 5 times.
  - Expected $[2] = 'https://mocked.com/bob/inbox' to equal 'https://ignore.com/sally/inbox'.

gregid avatar Mar 27 '21 18:03 gregid

I updated my node to v14.16.0 but the problem persists

gregid avatar Mar 28 '21 13:03 gregid

Thanks for the kind words. These two tests use timeouts, so they are prone to false positives. They may pass if you re-run the tests. The tests could be improved by replacing the timeouts with a combination of clock mocking (to run out delivery delay timers) and process.nextTick (to allow promises to resolve)

wmurphyrd avatar Mar 28 '21 20:03 wmurphyrd

Thanks for the reply - I suspected it must be timeout related and tried different timeout values but haven't been successful in finding the right ones to pass the test - but I am happy to hear it is more of an imprecise test issue rather then a code issue.

gregid avatar Mar 28 '21 21:03 gregid

I decided to give it a try few more times and I think I've found a sweet spot (for my machine at least). Giving 20ms per each call makes all the tests pass (4 calls: 80, 5 calls: 100, 6 calls: 120). It still passes the tests in 50% of time but at least I have seen all green.

Still seeing that deliveryDequeue().waitUntil.getTime() - Date.now() is different per each call I don't see how it could be tested to be universally correct (unless the clock mocking somehow makes it work).

gregid avatar Mar 28 '21 21:03 gregid