Docs Guides

Testing and health checks

Check your integration with the bridge health diagnostics before you submit an app.

Test the app in a real iframe against the HydraOne web client. The SDK ships a health check to verify the bridge.

Diagnostics

checkBridgeHealth(clientOrTransport, options) from @hydraone-sdk/core runs three checks and returns a BridgeHealthReport:

Check idVerifies
iframe-sandboxThe page is in an iframe with the sandbox permissions it needs.
postmessage-latencyA ping round trip works and is fast enough (warns above warningThresholdMs, default 150 ms; fails after timeoutMs, default 3000 ms).
storage-local and storage-relaylocalStorage and the host relay are readable and writable.

Each check has a status of PASS, WARN or FAIL, a message, and a hint when something needs fixing. report.status is FAIL if any check failed, WARN if any warned, otherwise PASS. Skip checks with skipSandboxCheck, skipLatencyCheck, skipStorageCheck. The storage checks write a temporary key and restore it afterwards; set testKey to choose the key and storage to test a specific IStorage adapter. Without storage, the relay check builds a HostStorageRelayAdapter on the client's transport. Outside an iframe the iframe and latency checks report WARN, not FAIL. client.checkHealth(options) runs the same report.

import { WalletBridgeClient, checkBridgeHealth } from '@hydraone-sdk/core';

const client = new WalletBridgeClient({
  hostOrigin: 'https://alpha.hydraone.app',
});
await client.init(); // the latency check fails with ERR_BRIDGE_NOT_CONNECTED before the handshake

const report = await checkBridgeHealth(client, { warningThresholdMs: 200, skipStorageCheck: true });
console.log(report.status, report.summary);

Before you submit an app

  • Run the app in a real iframe inside the HydraOne web client.
  • Open it in Safari and confirm a reload keeps the user's saved data (see Safari ITP and host storage).
  • Reject a signature in the wallet and confirm the UI recovers from the cancelled request.
  • Run checkBridgeHealth against the real host and fix every FAIL.

Next steps