Skip to content

Add invalid-input rejection tests for every encoding - #59

Open
acul71 wants to merge 1 commit into
masterfrom
test/issue-41-invalid-input
Open

Add invalid-input rejection tests for every encoding#59
acul71 wants to merge 1 commit into
masterfrom
test/issue-41-invalid-input

Conversation

@acul71

@acul71 acul71 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Demo / evidence

$ pytest tests/test_roundtrip.py -q
88 passed, 8 skipped in 0.11s

$ python -c "from multibase import decode, DecodingError; ..."
decode('f!'): DecodingError: Failed to decode multibase data: substring not found

Explanation: 22 encodings × 4 invalid suffixes = 88 assertions; 2 encodings × 4 = 8 skips. The smoke snippet shows alphabet garbage after a valid prefix raises DecodingError instead of succeeding.

Test plan

  • pytest tests/test_roundtrip.py -q
  • make lint
  • make typecheck
  • make test
  • make docs-ci

Made with Cursor

Cover decode() with invalid suffixes across supported encodings so
malformed payloads raise DecodingError instead of being silently accepted.

Co-authored-by: Cursor <cursoragent@cursor.com>
@acul71

acul71 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

Demo logs (invalid-input tests)

$ pytest tests/test_roundtrip.py -q
88 passed, 8 skipped in 0.11s

$ python - <<'PY'
from multibase import decode, DecodingError
try:
    decode("f!")
except DecodingError as e:
    print(f"{type(e).__name__}: {e}")
PY
DecodingError: Failed to decode multibase data: substring not found

88 cases = 22 encodings × 4 invalid suffixes; 8 skips = identity + base256emoji.

@acul71

acul71 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@sumanjeet0012 Could you please review this PR when you have a chance? Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No test verifying invalid input is rejected for every encoding

1 participant