refactor: make wasm-sdk contract version test config dynamic
Issue being fixed or feature implemented
The WASM SDK data contract test suite used hard-coded version arrays that required manual updates across multiple locations when adding new contract format versions or platform versions. This made the codebase harder to maintain and error-prone.
Fixes #2803 comment.
What was done?
Refactored the data contract test configuration to be fully data-driven and self-expanding:
- Introduced
CONTRACT_FORMAT_VERSIONSconfig object mapping format versions to their introduction platform version and fixtures - Created
FORMATSobject that auto-generates compatibility arrays, incompatibility arrays, and platform version constants for all defined formats - Updated test suite to dynamically iterate over all contract formats instead of hard-coded test blocks
- Removed redundant backward compatibility constants in favor of direct
FORMATSreferences
Adding a new contract format (e.g., V2) now requires:
- Updating
PLATFORM_VERSIONS.MAXto the new version - Adding
V2: { introduced: X, fixture: contractFixtureV2 }toCONTRACT_FORMAT_VERSIONS - Importing a V2 contract fixture
All compatibility arrays, test suites, and constants are automatically generated.
How Has This Been Tested?
- Ran existing WASM SDK test suite: all 84 tests passing
- Verified V0 and V1 contract compatibility tests work correctly across all platform versions
- Confirmed dynamic test iteration generates proper test suites for both formats
- Validated that generated arrays match previous hard-coded values
Breaking Changes
None. This is a pure refactoring with no API or behavior changes.
Checklist:
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have added or updated relevant unit/integration/functional/e2e tests
- [ ] I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
- [ ] I have made corresponding changes to the documentation if needed
For repository code-owners and collaborators only
- [ ] I have assigned this pull request to a milestone
Summary by CodeRabbit
- Tests
- Replaced hard-coded version constants with dynamic configuration so tests derive per-format compatibility automatically.
- Introduced an auto-generated compatibility matrix and per-format platform version values used across tests.
- Test suite now iterates all defined contract formats, using a shared test helper and a generalized "latest known" version, covering creation, validation, round-trip, and memory checks.
[!IMPORTANT]
Review skipped
Auto reviews are disabled on base/target branches other than the default branch.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Walkthrough
Replaces hard-coded platform-version constants in the data-contract unit tests with dynamic PLATFORM_VERSIONS and CONTRACT_FORMAT_VERSIONS, auto-generates a per-format FORMATS compatibility matrix, and updates tests to iterate over formats and use PLATFORM_VERSIONS.MAX for latest-version checks.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Test Configuration Refactor packages/wasm-sdk/tests/unit/data-contract.spec.mjs |
Replaced static PLATFORM_VERSION_CONTRACT_V0/V1 with dynamic PLATFORM_VERSIONS and CONTRACT_FORMAT_VERSIONS. Introduced auto-generated FORMATS (per-format platformVersion, compatibleVersions, incompatibleVersions), updated tests to iterate over FORMATS, generalized compatibility and round‑trip checks, and set LATEST_KNOWN_VERSION to PLATFORM_VERSIONS.MAX. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
- Verify correctness of the
FORMATSgeneration logic and compatibility matrices. - Confirm tests still cover previous V0/V1 scenarios and boundary/version-edge cases.
- Ensure
PLATFORM_VERSIONS.MAXusage aligns with other test assumptions.
Possibly related PRs
- dashpay/platform#2803 — Overlapping changes to wasm-sdk data-contract tests and platform-format version compatibility logic.
Suggested reviewers
- shumkov
Poem
🐰
I hopped through constants, loose and fleet,
Turned hard‑coded stones to a matrix neat,
Formats numbered, versions set free,
Tests now loop with gentle glee,
A rabbit's cheer for tidy harmony.
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title Check | ✅ Passed | The PR title "refactor: make wasm-sdk contract version test config dynamic" directly and clearly summarizes the primary change in the pull request. The title accurately reflects the core refactoring objective of converting hard-coded platform version constants and test configurations into a dynamic, data-driven system. It is concise, specific, and avoids vague terminology, making it immediately clear to reviewers what the changeset addresses without excessive detail. |
| Linked Issues Check | ✅ Passed | The pull request successfully fulfills the coding requirements from linked issue #2803. It establishes a dynamic, self-expanding configuration system via PLATFORM_VERSIONS, CONTRACT_FORMAT_VERSIONS, and an auto-generated FORMATS object, enabling comprehensive V0/V1 contract compatibility testing across platform versions. The refactoring makes it straightforward to test V0 contracts across all versions, ensure V1 contracts succeed on v9+ and fail on v1–8, implement LATEST_KNOWN_VERSION-based edge-case testing, and maintain comprehensive fixture coverage. The PR summary confirms that existing tests pass (84 tests) and compatibility verification was validated, demonstrating that the implementation meets the issue's objectives of expanding data contract test coverage with platform-version compatibility matrix support. |
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
@coderabbitai review
✅ Actions performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
@coderabbitai review
✅ Actions performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
Conflicting with https://github.com/dashpay/platform/pull/2800
Conflicting with #2800
I'll mark this as draft for now to possibly revisit later.