Skip to content

chore: cover SDK base64 helpers - #409

Merged
AnkanMisra merged 2 commits into
AnkanMisra:mainfrom
mittalsonal:260-sdk-base64-helper-tests
Aug 11, 2026
Merged

chore: cover SDK base64 helpers#409
AnkanMisra merged 2 commits into
AnkanMisra:mainfrom
mittalsonal:260-sdk-base64-helper-tests

Conversation

@mittalsonal

@mittalsonal mittalsonal commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Added direct Bun unit tests for the TypeScript SDK UTF-8 base64 helpers.
  • Covered known ASCII fixtures, accented text, non-Latin text, emoji, empty-text encoding, strict invalid input rejection, and missing atob / btoa runtime errors.
  • Restored modified global capabilities after each test to keep the SDK test suite isolated.

Closes #260

Type Of Change

  • Bug fix
  • Feature
  • Documentation
  • Tests
  • Refactor
  • Deployment/config

Affected Areas

  • Gateway (gateway/)
  • Verifier (verifier/)
  • Web (web/)
  • E2E/tests (tests/, run_e2e.sh)
  • Benchmarks (bench/)
  • Deployment/config (deploy/, Docker, env, workflows)
  • Documentation/community files
  • TypeScript SDK (sdk/typescript/)

Contributor Checklist

  • I kept the change focused and avoided unrelated refactors.
  • I updated README/service docs/OpenAPI/env examples when behavior, config, headers, status codes, or public APIs changed. Not applicable; test-only change.
  • I did not commit secrets, private keys, funded wallets, API keys, or real production URLs.
  • I checked x402/EIP-712 field parity when touching payment context, signatures, timestamps, nonces, chain IDs, receipts, or wallet flow. Not applicable; no protocol behavior changed.
  • I checked Docker/Compose/Fly/Vercel docs when touching ports, service names, health checks, or environment variables. Not applicable.

Verification

List the exact commands you ran and their result.

cd sdk/typescript && npx --yes bun@1.3.14 run test
Result: passed - 31 pass, 1 skip, 0 fail, 85 expect() calls

cd sdk/typescript && npx --yes bun@1.3.14 run typecheck
Result: passed - tsc --noEmit

git diff --cached --check
Result: passed

Screenshots

Not applicable - SDK unit test coverage only, no visible UI changes.

Notes For Reviewers

Production code is intentionally unchanged. The new tests import the helper module directly and avoid Node Buffer for the behavior under test.

Summary by CodeRabbit

  • Tests
    • Added comprehensive coverage for UTF-8 Base64 encoding and decoding.
    • Added validation for Unicode, empty input, invalid data, and environments without native Base64 support.

Note

Add test coverage for SDK base64 UTF-8 helpers

Adds a Bun test suite in base64.test.ts covering encodeUtf8ToBase64 and decodeBase64ToUtf8. Tests include round-trips for ASCII, accented Latin, Devanagari, and emoji strings, known-good decode fixtures, empty string handling, invalid input error cases, and errors when atob/btoa are unavailable (simulated via Object.defineProperty/Reflect.deleteProperty).

Macroscope summarized 5061ffe.

@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

@mittalsonal is attempting to deploy a commit to the ankanmisra's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added TypeScript TypeScript code type:testing Tests, coverage, fixtures, or validation-only work. labels Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Added direct TypeScript tests for UTF-8 Base64 encoding and decoding. The tests cover Unicode round-trips, strict invalid-input handling, missing atob and btoa capabilities, and restoration of mocked globals.

Changes

Base64 helper test coverage

Layer / File(s) Summary
Capability isolation setup
sdk/typescript/src/__tests__/base64.test.ts
The tests override and restore global atob and btoa descriptors.
Encoding, decoding, and error cases
sdk/typescript/src/__tests__/base64.test.ts
The suite covers known encodings, ASCII and Unicode round-trips, valid UTF-8 fixtures, empty input, invalid Base64 input, and unavailable runtime capabilities.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR does not meet #260 because it enables empty-string decoding instead of testing rejection as required by the issue acceptance criteria. Align the implementation and tests with #260 by rejecting empty decoded input, or update the issue acceptance criteria before merging this behavior change.
Out of Scope Changes check ⚠️ Warning The production behavior change for empty-string decoding is outside the test-only objective and conflicts with #260's stated out-of-scope guidance. Remove the production behavior change and keep this PR test-only, unless the behavior change receives separate approval and updated issue scope.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely describes the added SDK base64 helper test coverage.
Description check ✅ Passed The description includes all required template sections, detailed scope, verification commands, and notes for reviewers.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@sdk/typescript/src/__tests__/base64.test.ts`:
- Around line 4-17: Update the global capability setup around
setGlobalCapability and the afterEach cleanup to preserve each original atob and
btoa property state, including whether the property was absent. Restore the
saved descriptor or remove the global when it was originally missing, rather
than always assigning the captured value, so subsequent tests regain the
original capability state.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ba2bd6f-3836-45ef-83fe-fe5fa630636d

📥 Commits

Reviewing files that changed from the base of the PR and between e8481a3 and 878f570.

📒 Files selected for processing (1)
  • sdk/typescript/src/__tests__/base64.test.ts

Comment thread sdk/typescript/src/__tests__/base64.test.ts Outdated
@mittalsonal

Copy link
Copy Markdown
Contributor Author

Maintainer note: the CodeRabbit finding about preserving/restoring the original global atob/btoa property state has been addressed in the latest commit. The branch is mergeable and the code-owned checks are green (sdk-tests, typecheck via the workflow, dependency review, and CodeQL). Happy to make any further adjustments if you spot anything during review.

@AnkanMisra

Copy link
Copy Markdown
Owner

@codex review

@vercel

vercel Bot commented Aug 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
microai-paygate Ready Ready Preview Aug 11, 2026 6:06am

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c82a24e8ff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sdk/typescript/src/__tests__/base64.test.ts
Comment thread sdk/typescript/src/__tests__/base64.test.ts
Comment thread sdk/typescript/src/__tests__/base64.test.ts

@AnkanMisra AnkanMisra left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mittalsonal and others added 2 commits August 11, 2026 11:28
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
@AnkanMisra
AnkanMisra force-pushed the 260-sdk-base64-helper-tests branch from d48440d to 5061ffe Compare August 11, 2026 05:59
@AnkanMisra AnkanMisra added the enhancement New feature or request label Aug 11, 2026
@AnkanMisra AnkanMisra changed the title test: cover SDK base64 helpers chore: cover SDK base64 helpers Aug 11, 2026
@AnkanMisra AnkanMisra added good first issue Good for newcomers level:beginner Small, well-scoped work suitable for newer contributors. gssoc:approved Approved for GSSoC contribution labels Aug 11, 2026

@AnkanMisra AnkanMisra left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked at 5061ffe. The PR is test-only again, matches issue #260, and the SDK tests and typecheck pass. The remaining Vercel status is fork authorization rather than an SDK code failure.

@AnkanMisra
AnkanMisra merged commit 7df55a9 into AnkanMisra:main Aug 11, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request good first issue Good for newcomers gssoc:approved Approved for GSSoC contribution level:beginner Small, well-scoped work suitable for newer contributors. type:testing Tests, coverage, fixtures, or validation-only work. TypeScript TypeScript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add SDK unit tests for UTF-8 base64 helpers and runtime guards

2 participants