Skip to content

Add unit tests for QR access-check payload validation edge cases #232

Description

@Lakes41

Difficulty: Intermediate
Type: test

Background
The README documents a strict QR access-check payload schema (type, version, guildId, resourceId required; walletAddress, expiresAt optional) and states that unsupported types/versions, malformed JSON, missing required fields, invalid wallet addresses, and expired payloads are all rejected before submission — this logic lives in src/features/access/.

Problem
It's not clear this validation matrix has full unit test coverage; without it, a future refactor of the QR parsing/validation code could silently regress one of the documented rejection cases (e.g., accepting an expired payload).

Expected outcome
The QR payload validator has a unit test for every documented rejection case (bad type, unsupported version, malformed JSON, missing guildId/resourceId, invalid walletAddress, expired expiresAt) plus the happy path (valid payload with and without optional fields).

Suggested implementation

  • Locate the QR payload validation function in src/features/access/ and add a dedicated test file under tests/ if one doesn't fully cover this matrix.
  • Write one test case per documented rejection reason, asserting a specific, distinguishable error/result (not just a generic false).
  • Add a test confirming a valid payload without the optional walletAddress/expiresAt fields still passes.
  • Run pnpm test:run to confirm all pass.

Acceptance criteria

  • Every rejection case listed in the README has a corresponding test
  • Valid payloads with and without optional fields both pass
  • Each rejection case produces a distinguishable, specific result (not one generic failure)
  • pnpm test:run and pnpm typecheck pass

Likely affected files/directories

  • src/features/access/
  • tests/

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox Open Source Sponsorship program tagMaybe RewardedIssue may qualify for a reward upon successful completion per campaign rulesOfficial Campaign | FWC26Official FWC26 campaign issue — eligible for campaign scoring and rewardsintermediateIntermediate difficulty tasks requiring solid experience and some contexttestTest coverage additions, test fixes, or test infrastructure work

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions