ssbc / ssb-ebt

secure scuttlebutt replication with epidemic-broadcast-trees
MIT License
18 stars 10 forks source link

replace continuables with async-await in tests #43

Closed staltz closed 3 years ago

staltz commented 3 years ago

The new async-await control flow makes tests easier to read, since they are sequential (but still allow parallelism via Promise.all), a developer reading code doesn't have to jump their eyes up and down trying to follow the flow, and there's no callback pyramid.

In some cases I rewrote the tests, because they either didn't assert anything, or were using inconsistent patterns (it seems like some test files used one way of connecting, while other files used another method, seems to be that one method was an old style).

A big PR, but I feel confident about these tests are now readable and deterministic (don't rely on console.logs to do "human assertion").

arj03 commented 3 years ago

Wow, quite a PR. Overall from first look, this is a very nice cleanup.

arj03 commented 3 years ago

I ended up reading all the tests in the new version. They are actually quite readable now. Great job cleaning this up!

staltz commented 3 years ago

@arj03 Check my latest commit, I think it should fully clarify test/block.js

arj03 commented 3 years ago

Yep. This is really great. I now want to start using ssb-ebt again in browser-core after reading these tests :)

staltz commented 3 years ago

Can I green?