xrpl.js icon indicating copy to clipboard operation
xrpl.js copied to clipboard

Removed calls to deprecated utils function in tests

Open etienneoh opened this issue 1 year ago • 13 comments

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

etienneoh avatar Dec 09 '24 21:12 etienneoh

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.
From convertStringToHex to stringToHex we 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?

❤️ Share
🪧 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 @coderabbitai in 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 @coderabbitai in 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 pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere 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.

coderabbitai[bot] avatar Dec 09 '24 21:12 coderabbitai[bot]

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

pdp2121 avatar Dec 11 '24 22:12 pdp2121

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

etienneoh avatar Dec 12 '24 00:12 etienneoh

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.

mvadari avatar Dec 12 '24 00:12 mvadari

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.

etienneoh avatar Dec 12 '24 00:12 etienneoh

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.

ckniffen avatar Dec 12 '24 00:12 ckniffen

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.

mvadari avatar Dec 12 '24 00:12 mvadari

Done ! Thanks for the feedback @mvadari , very appreciated

etienneoh avatar Dec 12 '24 00:12 etienneoh

What is the expected notice period before a deprecated method can be removed from the codebase? Is it one major-version release cycle ?

ckeshava avatar Jan 02 '25 20:01 ckeshava

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 ?

ckeshava avatar Jan 13 '25 21:01 ckeshava

It has been approximately 11 months since the convertStringToHex function has been marked as deprecated. Here is the commit: 38b3859

Isn't that sufficient notice to completely remove the function? What are the expectations across the industry ?

It still needs to happen in major version.

ckniffen avatar Jan 13 '25 22:01 ckniffen

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

ckeshava avatar Jan 13 '25 22:01 ckeshava

@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 !

etienneoh avatar Jan 15 '25 00:01 etienneoh