Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(5805): cover the wallet gate — diff coverage 67% -> 100%\n\nThe coverage gate failed at 67% on changed lines. Two real gaps, both\nmine:\n\n`useWalletConfigured.ts` was 35.7% — the React binding had no caller and\nno test, which is untested surface however small. Rather than delete it\nand leave the file misnamed, it is now tested: the hook (initial\n`resolving`, each settled state, and the unmount-mid-flight path the\n`cancelled` flag exists for) and `resolveWalletConfigured` directly.\nTwo of those cases pin the load-bearing property — a failed status fetch\nmust resolve `unknown` and never `no`, and the function must never\nreject, since callers await it inline before the call it protects.\n\n`TinyPlaceOrchestrationTab.tsx` was 88.9% — the skip branch itself was\nuncovered. The new case asserts the distinction the gate is for:\nselfIdentity was NOT attempted, as opposed to attempted and failed, with\nthe relay badge still rendering.\n\nThe tab suite's walletApi mock is hoisted so a case can drive it, with\n`beforeEach` defaulting it to a configured wallet so every pre-existing\ncase keeps the path it was written for.\n\nVerified locally: 36 tests pass, and diff-cover against upstream/main\nreports 100% on changed lines (0 of 31 missing).\n\nRefs tinyhumansai/openhuman#5805\n

M3gA-Mind442bdb4e4015
diff --git a/app/src/components/intelligence/TinyPlaceOrchestrationTab.test.tsx b/app/src/components/intelligence/TinyPlaceOrchestrationTab.test.tsx
index c89ed13dd2..06d934d27a 100644
--- a/app/src/components/intelligence/TinyPlaceOrchestrationTab.test.tsx
+++ b/app/src/components/intelligence/TinyPlaceOrchestrationTab.test.tsx
@@ -40,9 +40,8 @@ vi.mock('../../lib/orchestration/orchestrationClient', async importOriginal => {
// The #5805 wallet gate runs before the identity fetch; mock it to a configured
// wallet so these cases exercise the same path they always did.
-vi.mock('../../services/walletApi', () => ({
- fetchWalletStatus: vi.fn().mockResolvedValue({ configured: true }),
-}));
+const fetchWalletStatusMock = vi.hoisted(() => vi.fn());
+vi.mock('../../services/walletApi', () => ({ fetchWalletStatus: fetchWalletStatusMock }));
vi.mock('../../services/socketService', () => {
return { socketService: { on: vi.fn(), off: vi.fn(), getSocket: vi.fn(() => null) } };
@@ -96,6 +95,9 @@ const PINNED_SESSIONS = [
describe('TinyPlaceOrchestrationTab', () => {
beforeEach(() => {
vi.clearAllMocks();
+ // Default to a configured wallet so every pre-existing case exercises the
+ // same path it always did; the #5805 case overrides it.
+ fetchWalletStatusMock.mockResolvedValue({ configured: true });
sessionsListMock.mockResolvedValue({ sessions: [...PINNED_SESSIONS] });
sessionsCreateMock.mockResolvedValue({
session: {
@@ -206,6 +208,22 @@ describe('TinyPlaceOrchestrationTab', () => {
expect(screen.queryByTestId('tinyplace-self-identity')).not.toBeInTheDocument();
});
+ // #5805 — with no wallet the identity read is skipped rather than attempted:
+ // selfIdentity() could only reject, and that rejection was reaching Sentry.
+ // The relay badge must still render, which is the property the wallet-less
+ // path shares with the locked-wallet path above.
+ it('skips the identity read entirely when no wallet is configured', async () => {
+ fetchWalletStatusMock.mockResolvedValue({ configured: false });
+
+ render(<TinyPlaceOrchestrationTab />);
+
+ const badge = await screen.findByTestId('tinyplace-relay-badge');
+ expect(badge).toHaveAttribute('data-network', 'staging');
+ expect(screen.queryByTestId('tinyplace-self-identity')).not.toBeInTheDocument();
+ // The point of the gate: not attempted, as opposed to attempted and failed.
+ expect(selfIdentityMock).not.toHaveBeenCalled();
+ });
+
it('loads and renders messages for the opened chat', async () => {
sessionsListMock.mockResolvedValue({
sessions: [
diff --git a/app/src/hooks/useWalletConfigured.test.ts b/app/src/hooks/useWalletConfigured.test.ts
new file mode 100644
index 0000000000..885921362d
--- /dev/null
+++ b/app/src/hooks/useWalletConfigured.test.ts
@@ -0,0 +1,89 @@
+import { renderHook, waitFor } from '@testing-library/react';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { resolveWalletConfigured, useWalletConfigured } from './useWalletConfigured';
+
+const fetchWalletStatus = vi.fn();
+vi.mock('../services/walletApi', () => ({ fetchWalletStatus: () => fetchWalletStatus() }));
+
+describe('wallet-configured gate (#5805)', () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ describe('resolveWalletConfigured', () => {
+ it('reports `yes` when a wallet is configured', async () => {
+ fetchWalletStatus.mockResolvedValue({ configured: true });
+ await expect(resolveWalletConfigured()).resolves.toBe('yes');
+ });
+
+ it('reports `no` when wallet_status resolves with no wallet', async () => {
+ fetchWalletStatus.mockResolvedValue({ configured: false });
+ await expect(resolveWalletConfigured()).resolves.toBe('no');
+ });
+
+ // The load-bearing case: a failed status fetch must NOT be reported as
+ // `no`. Callers skip their wallet-gated call only on a positive `no`, so
+ // collapsing this into `no` would let a transport blip hide a wallet that
+ // actually exists.
+ it('reports `unknown` — never `no` — when the status fetch itself fails', async () => {
+ fetchWalletStatus.mockRejectedValue(new Error('rpc transport failed'));
+ await expect(resolveWalletConfigured()).resolves.toBe('unknown');
+ });
+
+ // It is awaited inline before a gated call, so a rejection here would
+ // propagate into the caller it was meant to protect.
+ it('never rejects', async () => {
+ fetchWalletStatus.mockRejectedValue(new Error('boom'));
+ await expect(resolveWalletConfigured()).resolves.toBeDefined();
+ });
+ });
+
+ describe('useWalletConfigured', () => {
+ it('starts at `resolving` so callers fire nothing before the answer', async () => {
+ fetchWalletStatus.mockResolvedValue({ configured: true });
+ const { result } = renderHook(() => useWalletConfigured());
+
+ // Synchronously after mount, before the promise settles.
+ expect(result.current).toBe('resolving');
+ await waitFor(() => expect(result.current).toBe('yes'));
+ });
+
+ it('settles to `no` when no wallet is configured', async () => {
+ fetchWalletStatus.mockResolvedValue({ configured: false });
+ const { result } = renderHook(() => useWalletConfigured());
+
+ await waitFor(() => expect(result.current).toBe('no'));
+ });
+
+ it('settles to `unknown` when the status fetch fails', async () => {
+ fetchWalletStatus.mockRejectedValue(new Error('rpc transport failed'));
+ const { result } = renderHook(() => useWalletConfigured());
+
+ await waitFor(() => expect(result.current).toBe('unknown'));
+ });
+
+ // Unmounting before the probe settles must not set state on a dead
+ // component — that is what the `cancelled` flag in the effect cleanup is
+ // for, and it is only exercised if a test unmounts mid-flight.
+ it('does not set state after unmount', async () => {
+ let settle: (value: { configured: boolean }) => void = () => {};
+ fetchWalletStatus.mockReturnValue(
+ new Promise<{ configured: boolean }>(resolve => {
+ settle = resolve;
+ })
+ );
+ const errors: unknown[] = [];
+ const spy = vi.spyOn(console, 'error').mockImplementation((...args) => errors.push(args));
+
+ const { result, unmount } = renderHook(() => useWalletConfigured());
+ expect(result.current).toBe('resolving');
+ unmount();
+ settle({ configured: true });
+ await Promise.resolve();
+
+ expect(errors).toHaveLength(0);
+ spy.mockRestore();
+ });
+ });
+});