All files / kernel-test/src/vats peer-rejection-bootstrap.ts

0% Statements 0/5
0% Branches 0/2
0% Functions 0/4
0% Lines 0/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29                                                         
import { E } from '@endo/eventual-send';
import { makeDefaultExo } from '@metamask/kernel-utils/exo';
 
/**
 * Bootstrap vat for testing peer-rejection propagation.
 * Receives a `peer` root reference that may be a rejected kernel promise
 * (e.g. if the peer vat failed to launch), and logs whether calls resolve
 * or reject so integration tests can inspect the outcome.
 *
 * @returns The root object for this vat.
 */
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export function buildRootObject() {
  return makeDefaultExo('root', {
    async bootstrap({ peer }: { peer: unknown }) {
      await E(peer as object)
        .ping()
        // eslint-disable-next-line no-console
        .then(() => console.log('peer resolved'))
        .catch((error: unknown) => {
          const message =
            error instanceof Error ? error.message : String(error);
          // eslint-disable-next-line no-console
          console.log(`peer rejected: ${message}`);
        });
    },
  });
}