Skip to content

Add maximum repo string and title length validation - #1137

Open
Silver36-ship-it wants to merge 2 commits into
ritik4ever:mainfrom
Silver36-ship-it:AddMaximumRepoStringAndTitleLengthValidation
Open

Add maximum repo string and title length validation#1137
Silver36-ship-it wants to merge 2 commits into
ritik4ever:mainfrom
Silver36-ship-it:AddMaximumRepoStringAndTitleLengthValidation

Conversation

@Silver36-ship-it

Copy link
Copy Markdown

Closes #759

Description

Type of change

  • Bug fix
  • New feature
  • Breaking change

Security Checklist

Please review the SECURITY_CHECKLIST.md and check off any items that apply. Reviewers must sign off on these items before merge.

  • Input validation changed
  • Auth modified
  • New external fetch
  • Dependency added
  • Secret handling

Title: Add maximum repo/title length tests for create_bounty

Summary:
Adds unit tests that validate repo and title length handling in the contracts package. Tests cover at-limit acceptance, over-limit rejection (returns StringTooLong), and empty-string acceptance.

Branch: AddMaximumRepoStringAndTitleLengthValidation

Files Changed:

  • Tests: test.rs

What I changed:

  • Added three tests to validate string length behavior for create_bounty:
    • At-limit: repo and title exactly at MAX_REPO_LEN / MAX_TITLE_LEN are accepted.
    • Over-limit: repo one char longer than MAX_REPO_LEN fails with StringTooLong.
    • Empty: empty repo/title strings are accepted.

Rationale:
Protects on-chain storage from unbounded growth by ensuring length limits are enforced and prevents regressions by asserting expected contract behavior.

Testing:

  • Run the contracts test suite:
    • cargo test -p contracts
  • To run only the new tests (example):
    • cargo test -p contracts test_create_bounty_repo_title_at_limit_succeeds
    • cargo test -p contracts test_create_bounty_repo_over_limit_fails
    • cargo test -p contracts test_create_bounty_empty_repo_title_succeeds

Expected Results:

  • Tests pass if create_bounty enforces MAX_REPO_LEN / MAX_TITLE_LEN and returns StringTooLong on over-limit inputs.
  • Behavior for valid-length bounties is unchanged.

Notes / Caveats:

  • These are unit tests only and do not modify contract runtime logic — they assert existing behavior implemented in lib.rs.
  • The over-limit test expects the contract to surface the StringTooLong error (the test uses #[should_panic(expected = "StringTooLong")]).

Checklist for PR:

  • Behavior: Tests added and passing locally.
  • CI: Ensure cargo test -p contracts runs in CI.
  • Reviewers: Contracts maintainers / reviewers familiar with Soroban SDK and on-chain storage constraints.

Suggested PR description (copy-paste):

Adds unit tests to validate repo/title string length handling in the Soroban contract.

  • Adds tests for:
    • repo/title at exact allowed length (should succeed)
    • repo over the limit (should fail with StringTooLong)
    • empty repo/title (should succeed)

This prevents regressions around string-length validation that protects on-chain storage. Tests live in test.rs on branch AddMaximumRepoStringAndTitleLengthValidation. Run cargo test -p contracts to verify.

@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@Silver36-ship-it is attempting to deploy a commit to the ritik4ever's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@Silver36-ship-it Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add maximum repo-string and title-length validation

1 participant