Skip to content

test: consolidate and enrich v2 calldata conversion tests - #321

Merged
fsamier merged 1 commit into
mainfrom
feat/v2-calldata-conversion-tests
Aug 6, 2026
Merged

test: consolidate and enrich v2 calldata conversion tests#321
fsamier merged 1 commit into
mainfrom
feat/v2-calldata-conversion-tests

Conversation

@fsamier

@fsamier fsamier commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Enriches the v2 calldata conversion test suite to cover all currently implemented display field formats, and consolidates the previously per-format test files into a single parametrized module to reduce boilerplate.

Previously only chainId and tokenTicker had dedicated tests. This adds coverage for every implemented format and folds everything into one file with a small inline descriptor helper, so each case is expressed as just its minimal, format-specific part.

What changed

  • New tests/v2/convert/calldata/test_convert_fields.py:
    • Inline helpers (convert_field, assert_serializes_param_type) that build a minimal v2 descriptor from a single display field + signature, run the conversion, and assert the serialized PARAM_TYPE TLV tag.
    • One parametrized test_convert_field covering the homogeneous cases: raw, amount, duration, chainId, tokenTicker, addressName, tokenAmount, nftName, calldata, enum (one test id per format).
    • Small dedicated tests for the genuinely distinct cases: date (timestamp vs blockheight encodings), unit params, tokenTicker native_currencies is None, and tokenAmount token-path resolution.
  • Removed test_convert_chain_id.py and test_convert_token_ticker.py (superseded by the consolidated module).

Notes

  • v2 input models only coerce string enums (e.g. format) in JSON mode, so the helper validates via model_validate_json.
  • addressName requires params to resolve, so its case includes {"types": ["contract"]}.

Validation

  • All 15 tests pass.
  • ruff and mypy pre-commit hooks pass.

Enrich the v2 calldata conversion suite to cover all implemented field formats (raw, amount, duration, chainId, tokenTicker, addressName, tokenAmount, nftName, calldata, enum, date, unit) and consolidate the per-format files into a single parametrized module with an inline descriptor helper.
@fsamier
fsamier requested a review from a team as a code owner August 6, 2026 12:19
@fsamier fsamier added the sources label Aug 6, 2026
@fsamier
fsamier merged commit 93b444e into main Aug 6, 2026
13 of 14 checks passed
@fsamier
fsamier deleted the feat/v2-calldata-conversion-tests branch August 6, 2026 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant