Skip to content

test: improve token state transition tests with SDK 3.0 validation#37

Merged
thephez merged 6 commits intochore/update-to-2.2from
v3-update-adjustments-sts-token
Feb 3, 2026
Merged

test: improve token state transition tests with SDK 3.0 validation#37
thephez merged 6 commits intochore/update-to-2.2from
v3-update-adjustments-sts-token

Conversation

@thephez
Copy link
Collaborator

@thephez thephez commented Feb 3, 2026

Token State Transition Test Improvements

Updates token state transition tests to work properly with SDK 3.0, fixing field name mismatches and adding proper response validation. Also expands emergency actions test and adds token config updates back in.

Changes

  • Fix token direct purchase SDK field mapping - Changed identityId to buyerId and totalAgreedPrice to maxTotalCost to match SDK 3.0 interface
  • Expand token emergency action test - New test with pause/resume steps using test.step() pattern
  • Add token config update test - Added test (currently skipped pending SDK support) with validation
  • Update token claim test - Gracefully skip when no rewards are available instead of failing
  • Relocate and re-enable destroy frozen tokens test - Fixed test ordering for proper execution
  • Add response validation - validateTokenDirectPurchaseResult and validateTokenEmergencyActionResult now properly validate SDK 3.0 response format

Summary by CodeRabbit

  • API Changes
    • Updated token direct purchase parameter names: identityId → buyerId and totalAgreedPrice → maxTotalCost for enhanced consistency and clarity

thephez and others added 2 commits February 3, 2026 12:19
The test works fine if run between freeze and unfreeze
- Enable token claim test with dynamic skip when rewards recently claimed
- Add tokenConfigUpdate test (skipped, SDK 3.0 removed it temporarily)
- Add tokenConfigUpdate test data parameters

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

The changes update SDK field names in the direct purchase operation, add test data for token configuration updates, and significantly expand the test suite with new validation helpers, state transition variants, and error retry mechanisms.

Changes

Cohort / File(s) Summary
SDK API Updates
public/app.js
Renamed tokenDirectPurchase payload fields: identityIdbuyerId and totalAgreedPricemaxTotalCost in the callEvo function.
Test Data
tests/e2e/fixtures/test-data.js
Added tokenConfigUpdate test data entry with configuration parameters (identityId, contractId, tokenPosition, configItemType, configValue, publicNote, description).
Test Suite Enhancements
tests/e2e/transitions/state-transitions.spec.js
Introduced validation helpers (validateTokenConfigUpdateResult, validateTokenEmergencyActionResult), executeStateTransitionWithCustomParams helper, retry mechanism for transient errors, renamed test flows (tokenUnfreeze → tokenDestroyFrozen), activated previously skipped tests, and expanded state transition coverage with new paths for emergency actions and config updates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "test: update token tests" is vague and overly generic, using non-descriptive language that doesn't convey the specific nature of the changes. Consider a more specific title that highlights the main changes, such as "test: update token test flows and fix SDK field mappings" or "test: add token emergency action tests and fix direct purchase mapping".
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch v3-update-adjustments-sts-token

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 and usage tips.

thephez and others added 4 commits February 3, 2026 12:50
- Add validateTokenEmergencyActionResult validation function
- Enable emergency action test with test.step for pause and resume
- Validates response status and message contain action type

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix app.js to use buyerId instead of identityId for directPurchase
- Enable token direct purchase test (was skipped due to SDK field mismatch)
- Update validateTokenDirectPurchaseResult to assert status and message

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@thephez thephez marked this pull request as ready for review February 3, 2026 18:12
@thephez
Copy link
Collaborator Author

thephez commented Feb 3, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

✅ 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.

@thephez thephez changed the title test: update token tests test: improve token state transition tests with SDK 3.0 validation Feb 3, 2026
@thephez thephez merged commit 7f8199f into chore/update-to-2.2 Feb 3, 2026
2 checks passed
@thephez thephez deleted the v3-update-adjustments-sts-token branch February 3, 2026 18:31
shumkov added a commit that referenced this pull request Feb 5, 2026
* chore: update to 2.2

* test: update fixtures

* docs: document

* chore: update tests and UI

* feat: upgrade to evo sdk 2.2

* refactor: remove unused code

* test: skip tests if envs not passed

* chore: update to 3.0.0-rc.1

* fix: broken query tests

* chore: remove cpython cache

* test: fix tests

* feat: added missing queries

* fix: broken state transition tests (pt.1)

* fix: state transition methods

* test: fix data contract tests

* test: add missing tests

* test: fix more e2e tests

* chore: update to 3.0.0

* chore: remove 2

* test: update tests

* test: fix WASM serialization and restore validations for query tests (#35)

* chore: revert to original gettokencontractinfo validation

Test failure was due to an upstream issue. The updated logic hid the issue and produced a false positive on the test.

Related to dashpay/platform#3027

* fix: move comment to correct location

* test: re-enable check for totalsupply property

With the test params used, this will be present

* fix: add workaround for WASM types missing toJSON serialization

Adds fallback in extractWasmData() to extract known getter properties from WASM objects that lack toJSON/toObject methods (platform#3027).

* fix(tests): use baseElement directly for array inputs without dynamic container

The handleArrayInput method was ignoring the passed baseElement and
searching globally for inputs, causing it to fill the wrong field
(e.g., identityId instead of tokenIds in getIdentityTokenBalances).

Now correctly uses baseElement when no .array-input-container exists.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(tests): remove allowNullData bandaid to surface upstream issue

Remove null-allowing workarounds from getPrefundedSpecializedBalance test so it properly fails when null data is returned instead of silently passing.

Related to dashpay/platform#3029

* test: add todo in smoke test for token config

* chore: update workaround to only use on token contract info

Not effective on others

* chore: add comment about why test fails

* fix: serialize IdentityTokenInfo frozen property and validate in tests

The IdentityTokenInfo WASM object's frozen getter wasn't being extracted
during serialization, causing empty objects in query results. Added to
knownGetters workaround and strengthened test validation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(queries): restore robust document validation with field checks

Validate $id, $ownerId, $revision, $type on each document. Handles
arrays, single documents, and Map-like objects keyed by document ID.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore: add note about failing test

* test(queries): skip tests failing due to upstream platform bugs

Skip getPrefundedSpecializedBalance proof test and getIdentitiesContractKeys
tests until upstream issues are resolved.

Refs: dashpay/platform#2986, dashpay/platform#3028

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* test: simplify state transition tests and update test data descriptions (#36)

* test: simplify state transition tests and update test data descriptions

- Add helper function executeStateTransition for cleaner test code
- Simplify data contract create/update tests by using fixed test data
- Add authentication input visibility tests for identity and data contract transitions
- Update test data descriptions to reference "Evo SDK" instead of "WASM-SDK"

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(documents): reintroduce removed tests for nft operations and full create/replace/update process

Also adds comprehensive document workflow tests and validation helpers for marketplace operations (set price, purchase, transfer).

* fix(documents): increment revision before SDK update operations

Platform expects transition_revision = current_revision + 1 for document updates. Fixed documentTransfer, documentPurchase, and documentSetPrice handlers to increment revision before SDK calls.

* fix(contracts): apply config settings during data contract creation

The DataContract constructor uses default config values. This fix explicitly calls setConfig() to apply user-specified settings like keepsHistory, canBeDeleted, readonly, and document defaults.

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* test: improve token state transition tests with SDK 3.0 validation (#37)

* test: relocate destroy frozen tokens and re-enable

The test works fine if run between freeze and unfreeze

* test: update token claim test and add token config update test

- Enable token claim test with dynamic skip when rewards recently claimed
- Add tokenConfigUpdate test (skipped, SDK 3.0 removed it temporarily)
- Add tokenConfigUpdate test data parameters

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test: add token emergency action test with pause and resume steps

- Add validateTokenEmergencyActionResult validation function
- Enable emergency action test with test.step for pause and resume
- Validates response status and message contain action type

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: use correct SDK field names for token direct purchase

- Fix app.js to use buyerId instead of identityId for directPurchase
- Enable token direct purchase test (was skipped due to SDK field mismatch)
- Update validateTokenDirectPurchaseResult to assert status and message

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test: add token config validation back for when test re-enabled

* fix: correct field mapping for token direct purchase

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* fix: add input validation to hexToBytes function

Validate hex string input to prevent silent failures when processing
invalid data. Checks for string type, even length, and valid hex
characters before conversion.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore: remove duplicate documentTypeName mapping

* docs: add sdk_params to Platform Address transitions (#39)

* docs: add sdk_params to Platform Address transitions

Document actual SDK parameter names for address operations to match
example code in AI_REFERENCE.md. Parameters now correctly show inputs,
outputs, signer objects instead of UI form field names.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: add credits unit to amount fields in Platform Address params

Consistently label amount fields with "(credits)" unit in all Platform
Address transition sdk_params descriptions.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: thephez <thephez@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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.

1 participant