Have all your scenario tests stopped working? Here's why!

Holochain v0.0.51-alpha1 was released last week. Per the release announcement, Tryorama, the scenario testing framework, no longer waits properly when await s.consistency() is called. This is the result of a bugfix that fixed consistency discrepancies on links hanging off an agent ID.

Now, in your multi-party scenario tests, you’ll see tests failing if they’re supposed to wait for Alice’s published entries to arrive at Bob’s node. Essentially s.consistency() returns before the data has actually propagated, so when Bob tries to retrieve the data it returns an empty result.

We don’t intend to fix this error; instead, we intend to deprecate s.consistency and introduce better tools for determining whether Bob can see the data he’s supposed to see.

In the meantime, we recommend you just sleep for a few moments before calling any functions on Bob’s node. Here’s a snippet you can use (protip: this works browser-side too):

// At the top of the test script, or better yet in another module
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

// ...
// ...
// In a test, where you'd normally go `await s.consistency()`
await sleep(5000);
// ...

Play around with sleep intervals – it depends on the speed of your machine, the complexity of the zome function that publishes the data, the amount of data being published, and the networking backend you’re using. I’d recommend starting with 1000ms, and if that seems to work 100% of the time, reduce it until you start getting errors :wink: