While working on https://github.com/Agoric/agoric-sdk/pull/9539 , which changes fakeVatAdmin and the timing of exactly when the createVat() promise resolves, we discovered that packages/inter-protocol/test/provisionPool.test.js started to fail. In particular, provisionPool publishes metricsOverride promptly got the wrong metrics.
I think the test is inspecting the contract's metrics without really synchronizing on anything, and is vulnerable to checking them too early, before the contract has had a chance to update them. My best guess is that this was working before only because the old fakeVatAdmin was taking an extra turn to get running, or it was allowing the contract to start a turn early. The new fakeVatAdmin changed the timing, revealing the bug.
I got the test working again by inserting an artificial stall, with await null.
That's not a satisfying fix. A better one would be to identify what exactly the test needs to wait upon, make sure there's a way for it to get a Promise that won't fire until those conditions are met, and change the test to use it (and remove the stall).
To Reproduce
get a tree with the #9539 PR landed
cd packages/inter-protocol
comment out the await null in provisionPool.test.js
yarn test test/provisionPool.test.js -m "provisionPool publishes metricsOverride promptly"
While working on https://github.com/Agoric/agoric-sdk/pull/9539 , which changes fakeVatAdmin and the timing of exactly when the
createVat()
promise resolves, we discovered thatpackages/inter-protocol/test/provisionPool.test.js
started to fail. In particular,provisionPool publishes metricsOverride promptly
got the wrong metrics.I think the test is inspecting the contract's metrics without really synchronizing on anything, and is vulnerable to checking them too early, before the contract has had a chance to update them. My best guess is that this was working before only because the old fakeVatAdmin was taking an extra turn to get running, or it was allowing the contract to start a turn early. The new fakeVatAdmin changed the timing, revealing the bug.
I got the test working again by inserting an artificial stall, with
await null
.That's not a satisfying fix. A better one would be to identify what exactly the test needs to wait upon, make sure there's a way for it to get a Promise that won't fire until those conditions are met, and change the test to use it (and remove the stall).
To Reproduce
cd packages/inter-protocol
await null
inprovisionPool.test.js
yarn test test/provisionPool.test.js -m "provisionPool publishes metricsOverride promptly"