Removed calls to deprecated utils function in tests
High Level Overview of Change
See #2698 . Removed multiple calls to deprecated functions in the tests (convertStringToHex and convertHexToString) and replaced them with the new version (@xrplf/isomorphic/util's stringToHex and hexToString). The deprecated functions where already just pointing to the new one.
Also updated the models/transactions/NFTokenMint.ts comments to point at the correct functions.
Context of Change
Simple refactor to follow best practices. The tests could be referenced by a user and he should always have the correct function used by default.
Type of Change
- [x] Refactor (non-breaking change that only restructures code)
Did you update HISTORY.md?
- [x] No, this change does not impact library users
Walkthrough
The pull request introduces changes across multiple files to replace the convertStringToHex function with stringToHex from the @xrplf/isomorphic/utils package. This update affects the conversion of string representations to hexadecimal format in various contexts, including transaction fields and test cases. The overall logic and structure of the affected functions and tests remain unchanged, ensuring that the transition to the new utility function is seamless.
Changes
| File Path | Change Summary |
|---|---|
| packages/xrpl/snippets/src/multisigning.ts | Updated Domain field to use stringToHex('example.com') instead of convertStringToHex. |
| packages/xrpl/src/models/transactions/NFTokenMint.ts | Updated documentation for URI field to reference stringToHex instead of convertStringToHex. |
| packages/xrpl/test/integration/integration.test.ts | Replaced convertStringToHex with stringToHex in the submit multisigned transaction test case. |
| packages/xrpl/test/integration/regularKey.test.ts | Updated multiple test cases to use stringToHex for the Domain field. |
| packages/xrpl/test/integration/requests/submit.test.ts | Updated Domain property to use stringToHex instead of convertStringToHex. |
| packages/xrpl/test/integration/requests/submitMultisigned.test.ts | Changed the Domain field to use stringToHex in two test cases. |
| packages/xrpl/test/integration/requests/tx.test.ts | Updated test cases to use stringToHex for Domain property. |
| packages/xrpl/test/integration/submitAndWait.test.ts | Replaced convertStringToHex with stringToHex in multiple test cases. |
| packages/xrpl/test/integration/transactions/nftokenMint.test.ts | Updated URI property to use stringToHex in the NFTokenMint test case. |
| packages/xrpl/test/models/NFTokenMint.test.ts | Replaced convertStringToHex with stringToHex for URI field in multiple test cases. |
| packages/xrpl/test/utils/hexConversion.test.ts | Updated function names from convertStringToHex to stringToHex and convertHexToString to hexToString. |
Poem
🐰 In the land of code where rabbits play,
We swapped our hex in a brand new way.
FromconvertStringToHextostringToHexwe cheer,
A hop in the logic, the path is now clear!
With every change, our code will sing,
A brighter future, let the hex strings ring! 🌟
📜 Recent review details
Configuration used: .coderabbit.yaml Review profile: CHILL Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between b36383033820ffd48780b13ea5c1aedcd6cc392e and 5184148f381e051f8147b89ed49182adb75dfcd4.
📒 Files selected for processing (1)
packages/xrpl/test/utils/hexConversion.test.ts(0 hunks)
💤 Files with no reviewable changes (1)
- packages/xrpl/test/utils/hexConversion.test.ts
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR. (Beta)@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Would be great if we can change the call in this snippet as well: https://github.com/XRPLF/xrpl.js/blob/main/packages/xrpl/snippets/src/multisigning.ts#L53
Would be great if we can change the call in this snippet as well: https://github.com/XRPLF/xrpl.js/blob/main/packages/xrpl/snippets/src/multisigning.ts#L53
It is included on the first commit of this pull request ! @pdp2121
IMO deprecated functions shouldn't be removed from tests until the functions are fully removed - just because they're deprecated doesn't mean they should fail.
I simply replaced them with the up-to-date functions. The deprecated functions themselves pointed to the new ones that I used, so nothing is failing !
I will update my pull request text, because I realise I was not specific enough.
IMO deprecated functions shouldn't be removed from tests until the functions are fully removed - just because they're deprecated doesn't mean they should fail.
I agree with @mvadari on this one. Maybe at least have one or two of the tests for the deprecated ones. It wouldn't hurt.
I simply replaced them with the up-to-date functions. The deprecated functions themselves pointed to the new ones that I used, so nothing is failing !
If you roll back the changes to hexConversion.test.ts (and update the PR title), the remaining changes would be fine. Then you're only removing the places where convertHexToString are used incidentally, rather than the tests where they're actually being tested.
Done ! Thanks for the feedback @mvadari , very appreciated
What is the expected notice period before a deprecated method can be removed from the codebase? Is it one major-version release cycle ?
It has been approximately 11 months since the convertStringToHex function has been marked as deprecated. Here is the commit: https://github.com/XRPLF/xrpl.js/commit/38b385969b89b5651c8e3c1420f841829ed9b451
Isn't that sufficient notice to completely remove the function? What are the expectations across the industry ?
It has been approximately 11 months since the
convertStringToHexfunction has been marked as deprecated. Here is the commit: 38b3859Isn't that sufficient notice to completely remove the function? What are the expectations across the industry ?
It still needs to happen in major version.
@etienneoh Regarding the linter errors: Are you using Cursor.ai editor? I have come across such errors with that editor. However, VSCode (with default configuration) works well with the linter.
Perhaps, updating the linter-configuration will fix these errors.
@etienneoh Regarding the linter errors: Are you using Cursor.ai editor? I have come across such errors with that editor. However, VSCode (with default configuration) works well with the linter.
Perhaps, updating the linter-configuration will fix these errors.
I just use the regular linter from VSCode !