Agoric / agoric-sdk

monorepo for the Agoric Javascript smart contract platform
Apache License 2.0
326 stars 205 forks source link

provisionPool test requires extra stall, figure out how to remove it #9598

Open warner opened 3 months ago

warner commented 3 months ago

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