Skip to content

chore(agent): claim PR review follow-ups — tsconfig tests inclusion + normalizeKey extraction + test isolation #287

@rz1989s

Description

@rz1989s

Background

Code review of #281 (Claim Phase 2 Path A) surfaced three polish items that were out of scope for the initial PR but worth tracking.

Items

1. Add `tests/**` to `packages/agent/tsconfig.json` include glob

`packages/agent/tsconfig.json` currently has `"include": ["src"]` — tests are excluded from `tsc --noEmit`. This means assertion-drift in test files (e.g., when an interface field is removed or renamed) doesn't surface at typecheck time. The Path A plan's Task 3 noted this: `pnpm typecheck` passed green even though `tests/claim.test.ts` referenced removed members; only `vitest run` caught the broken assertions.

Fix: Add `tests/**/*.ts` to the include glob (or add a separate `tsconfig.test.json` with broader scope that runs in CI). Verify no false positives from vitest-internal types.

2. Extract `normalizeKey` to shared utility

`packages/agent/src/tools/claim.ts:155-162` defines `normalizeKey(key: string): \`0x${string}\`` as a private helper. Other tools (`send`, `swap`, `viewing-key`, future ECDH-using tools) need the same hex normalization for the SDK's `HexString` brand.

Fix: Move to `packages/agent/src/utils/key-normalize.ts` (or co-locate with claim-helpers if claim-adjacent). Update all consumers.

3. Add `beforeEach` mock reset in claim.test.ts error-paths describe

`packages/agent/tests/claim.test.ts:176-228` (the `executeClaim — error paths` describe block added in Task 5) has no `beforeEach` reset. Each test currently re-stubs both `resolveStealthContext` and `claimStealthPayment` explicitly, and works because the 3rd test (non-hex key) never reaches `claimStealthPayment` — leftover `mockRejectedValue` from test 2 is inert.

Fix: Add `beforeEach(() => vi.clearAllMocks())` (or hoist common happy-path defaults to `beforeEach`). Future-proofs the test against new additions that might forget to re-stub.

Why

These don't block any feature work. Filed as one issue rather than three to keep the tracker tidy. Pick up when there's spare cycles or when the underlying code is being touched for other reasons.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:lowLow impact / nice-to-havetech-debtTechnical debt to address post-hackathon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions