Skip to content

test(core): cover LruCache eviction behavior #83

Description

@1amKhush

Problem

src/core/utils/lru-cache.ts is shared by transport, gateway, and payment code but has no focused unit test suite. Small changes to eviction or access ordering can therefore affect several unrelated paths without a direct regression failure.

Scope

Add a co-located src/core/utils/lru-cache.test.ts covering the existing behavior:

  • inserting and retrieving entries;
  • evicting the least-recently-used entry at capacity;
  • refreshing recency after get() and after updating an existing key;
  • invoking onEvict with the evicted key and value;
  • supporting an empty-string key without exceeding capacity;
  • has, delete, clear, size, and entry iteration where useful.

Non-goals

  • Do not redesign the cache or make it part of the public SDK API.
  • Do not change entry-order semantics without first documenting the intended contract in the PR.
  • Keep production changes out of scope unless a test exposes a confirmed defect.

Acceptance criteria

  • Tests are deterministic and require no timers, relay, or network.
  • Tests are co-located and follow the repository's Bun test conventions.
  • Existing tests, lint, and type checking continue to pass.

Verification

bun test src/core/utils/lru-cache.test.ts
bun lint
bun typecheck

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions