when tests are run multiple times eventually they stall, usually because of a listen callback or listener event is missed. There appears to be a complex relationship causing a race condition between the microtask queue (as we're using promises/await in test) and the retry logic (in @hyperswarm/network and it's underlying stack). We still need to get to the bottom of that, however we can mitigate the chances of that occurring by ensuring that every test closes out any socket connections before ending, which is mostly what this PR does. There are also a few cases where using timeouts in tests proved brittle (e.g. the deup test) so I've found a different approach in these cases
when tests are run multiple times eventually they stall, usually because of a
listen
callback or listener event is missed. There appears to be a complex relationship causing a race condition between the microtask queue (as we're using promises/await in test) and the retry logic (in @hyperswarm/network and it's underlying stack). We still need to get to the bottom of that, however we can mitigate the chances of that occurring by ensuring that every test closes out any socket connections before ending, which is mostly what this PR does. There are also a few cases where using timeouts in tests proved brittle (e.g. the deup test) so I've found a different approach in these cases