/ contract / src / tools / eventLoopIteration.js
eventLoopIteration.js
 1  /** @file note this cannot be called test-utils.js due to https://github.com/Agoric/agoric-sdk/issues/7503 */
 2  /* global setImmediate */
 3  
 4  /**
 5   * A workaround for some issues with fake time in tests.
 6   *
 7   * Lines of test code can depend on async promises outside the test
 8   * resolving before they run. Awaiting this function result ensures
 9   * that all promises that can do resolve.
10   * Note that this doesn't mean all outstanding promises.
11   */
12  const eventLoopIteration = async (string = 'resolved!') =>
13    new Promise(resolve => setImmediate(resolve(string)));
14  harden(eventLoopIteration);
15  
16  export { eventLoopIteration };