Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fix test-vaultfactory.js for new timer behavior
The test-vaultFactory.js "price falls precipitously" test exercises the asset price changing in four steps: * initial conditions: t=0, price=2200 * tick(): t=1, price=19180 * tick(): t=2, price=1650 * tick(): t=3, price=150 A loan is taken out at t=0. The drop to price=1650 is not quite enough to trigger liquidation. The drop to price=150 does cause liquidation, moreover the price is so low that it falls underwater entirely, so all of the collateral is sold, the client gets nothing back, and the vault manager must tap the reserves to avoid insolvency. Previously, this test used *four* calls to `tick()`, asserting that liquidation did not happen after any of the first three. It appears that this only passed because the `await tick()` was unable to completely wait for all triggered activity to complete (it merely waited on the `wake()` result promise, and did not do a full `setImmediate` / `eventLoopIteration`). When I inserted `await eventLoopIteration()` calls after `tick()` in the original version, the test failed, as liquidation was happening (and completing) after the *third* `tick()`. Now that our `manualTimer.tick()` can be configured to completely flush the promise queue, I'm removing the extra `tick()` call, and the "liquidation has not happened" assertion that was being made too early.
- Loading branch information