Holochain Forum

Diorama tests fail sometimes. Probably due to "await"

In Diorama tests I have a js call to a function which internally calls the update_entity function:

  let res1 = await alice.call("app1", "update_entity", {status: "st1"});

Then I check a result:

  let res2 = await alice.call("app1", "get_entity", {addr: res1.Ok});
  t.deepEqual(res2.Ok, "st1", "status is st1 - good");

The thing is that sometimes(!) it fails, and it shows the status that’s the one it was before an update. I suppose that it’s due to the fact that there’s “await” in the 1st call.
await itself has to be used with updating operations.

  1. Is this correct?

  2. How to fix it? Wait for “await” for finish first before checking the status? How?

Hi @alx there as a recent release of Try-o-rama. Try out the latest review and let us know if this is still an issue.

cc: @maackle

@aix

In the new try-o-rama, this is fixed with s.consistency().

let res = await alice.call("instanceId", "zomeName", "functionName", {params})
await s.consistency()
t.deepEqual(res.Ok, "expected");

(In Diorama it was implemented with callSync)

Aaaahh I was also running into this. Good to know!