test: improve token state transition tests with SDK 3.0 validation#37
Conversation
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>
📝 WalkthroughWalkthroughThe 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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 |
- 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>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
* 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>
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
identityIdtobuyerIdandtotalAgreedPricetomaxTotalCostto match SDK 3.0 interfacetest.step()patternvalidateTokenDirectPurchaseResultandvalidateTokenEmergencyActionResultnow properly validate SDK 3.0 response formatSummary by CodeRabbit