Skip to content

test: Separate faucet tests from local integration tests #2985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 19, 2025

Conversation

achaljhawar
Copy link
Contributor

@achaljhawar achaljhawar commented May 18, 2025

High Level Overview of Change

This PR separates faucet-specific tests (which connect to external networks) from local integration tests in the xrpl.js library.

fixes #2615

Changes include:

  • Created a new /test/faucet/ directory structure for tests that depend on external faucet services
  • Moved fundWallet.test.ts from integration to faucet directory
  • Added separate Jest configuration for faucet tests (jest.config.faucet.js)
  • Updated integration test config to exclude faucet tests
  • Added new npm scripts for running different test types

Context of Change

Our integration test suite previously combined tests that run against a local rippled server with tests that connect to public testnet/devnet networks and use faucet services. This combination caused several issues:

  1. Slower CI/PR build times: Tests dependent on external networks are inherently slower and less reliable
  2. Increased load on public services: Frequent test runs against public faucets create unnecessary load
  3. Flaky test results: Failures in tests connecting to external services could block PRs when those services were unavailable or experiencing issues
  4. Difficult local development: Developers needed to wait for external service responses even when only working on local functionality

This refactoring creates a clear separation between local integration tests and faucet tests, allowing them to be run independently while maintaining the ability to run all tests when needed.

Type of Change

  • Refactor (non-breaking change that only restructures code)
  • Tests (You added tests for code that already exists, or your new feature included in this PR)
  • Documentation Updates

Did you update HISTORY.md?

  • Yes
  • No, this change does not impact library users

Test Plan

  1. Verified local integration tests still run successfully:
npm run test:integration
  1. Verified faucet tests run successfully with new configuration:
npm run test:faucet
  1. Verified all tests can be run together:
npm run test:all
  1. Checked that moved tests maintain the same functionality and assertions, just in a different location

Future Tasks

  • Consider implementing conditional faucet test execution in CI workflows
  • Evaluate adding more documentation about when to use each test type in CONTRIBUTING.md
  • Look for other tests that might be candidates for moving to the faucet directory

Copy link

coderabbitai bot commented May 18, 2025

Walkthrough

A new Jest configuration for faucet tests was introduced in the xrpl package, extending the base configuration with custom settings and test targeting. The integration test configuration was updated to exclude faucet tests. New npm scripts were added for running faucet tests and running all tests sequentially. A GitHub Actions workflow was added to run faucet tests on push and manual triggers. Documentation was updated to include faucet test instructions.

Changes

File(s) Change Summary
packages/xrpl/jest.config.faucet.js Added a new Jest config for faucet tests, extending the base config, specifying roots, timeout, testMatch, and displayName.
packages/xrpl/jest.config.integration.js Updated comment and added testPathIgnorePatterns to exclude faucet tests from integration runs.
packages/xrpl/package.json Added test:faucet npm script for running faucet tests.
package.json Added test:faucet npm script to run faucet tests via lerna.
.github/workflows/faucet_test.yml Added a new GitHub Actions workflow to run faucet tests with Node.js setup, caching, and build steps.
CONTRIBUTING.md Added a new "Faucet Tests" section describing faucet test purpose, setup, and run instructions.

Assessment against linked issues

Objective Addressed Explanation
Separate faucet tests from test:integration run script (#2615)
Ability to target only integration tests running against local rippled (#2615)
Allow rerunning just faucet tests from GitHub Actions (#2615)
Identify faucet test failures separately (#2615)
Reduce faucet test executions within integration runs to speed up PR builds (#2615)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Addition of detailed Faucet Tests section in CONTRIBUTING.md Documentation update not explicitly requested in linked issue but supports faucet test usage.
Addition of GitHub Actions workflow for faucet tests CI workflow addition not explicitly requested but aligns with facilitating faucet test runs.

Suggested reviewers

  • mvadari
  • pdp2121
  • Patel-Raj11

Poem

In the warren of code, a new test suite appears,
Faucet flows steady, dispelling old fears.
Integration hops past, ignoring the stream,
While scripts run together—a developer’s dream!
🐇✨
With configs aligned and scripts in a row,
The tests all assemble—ready, set, go!


📜 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 5ac3f70 and 13b51d8.

📒 Files selected for processing (1)
  • packages/xrpl/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/xrpl/package.json
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: browser (22.x)
  • GitHub Check: generate-documentation (22.x)
  • GitHub Check: build-and-lint (22.x)
  • GitHub Check: unit (22.x)
  • GitHub Check: unit (20.x)
  • GitHub Check: integration (20.x)
  • GitHub Check: integration (22.x)
  • GitHub Check: Socket Security: Pull Request Alerts

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
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/xrpl/jest.config.integration.js (1)

12-12: Verify the ignore pattern for faucet tests
testPathIgnorePatterns uses regexp strings to skip test paths. Your pattern '<rootDir>/test/faucet/' may not match nested test files. Consider appending .* (e.g., '<rootDir>/test/faucet/.*') or using a regex like '/test\/faucet\//' to ensure all faucet tests are excluded from integration runs.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between f3f4e44 and 0827a1f.

📒 Files selected for processing (3)
  • packages/xrpl/jest.config.faucet.js (1 hunks)
  • packages/xrpl/jest.config.integration.js (2 hunks)
  • packages/xrpl/package.json (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/xrpl/jest.config.faucet.js (1)
packages/xrpl/jest.config.integration.js (1)
  • base (2-2)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (5)
packages/xrpl/package.json (1)

63-64: Added dedicated faucet and composite test scripts
The new test:faucet and test:all scripts correctly integrate the faucet-specific Jest config and orchestrate sequential execution of all test suites, aligning with the PR’s goal to decouple external-service tests from local integration tests.

packages/xrpl/jest.config.faucet.js (4)

2-2: Import shared base Jest configuration
Reusing jest.config.base.js maintains consistency across all test suites and reduces duplication.


5-7: Extend test roots and set longer timeout for faucet tests
Including <rootDir>/test in roots ensures Jest discovers faucet tests, and increasing testTimeout to 60000 ms accommodates potential delays when interacting with public faucet endpoints.


8-11: Restrict test matching to faucet directory
The testMatch patterns target only .test.ts files under test/faucet/, effectively isolating faucet tests from unit and integration suites.


12-12: Distinct display name for the faucet suite
Naming this suite xrpl.js-faucet will make it easy to identify in CI logs and local outputs.

@mvadari
Copy link
Collaborator

mvadari commented Jun 5, 2025

I think this setup would still work even if you don't move the faucet tests to their own folder.

@pdp2121
Copy link
Collaborator

pdp2121 commented Jun 5, 2025

Thanks for contributing @achaljhawar! It would be great if you can update the CI setup as well so faucet test will run on PR merge to the main branch

@Patel-Raj11
Copy link
Collaborator

@achaljhawar Thanks for the PR! In continuation of #2985 (comment) it would be useful to do the following:

  1. Have a separate Github action workflow for Faucet tests that are executed only on merge to main branch and can be manually triggered. Ref: https://github.com/XRPLF/xrpl-py/blob/main/.github/workflows/faucet_test.yml
    GitHub Local Actions is a good Visual Studio Code extension to test the separated Faucet workflow locally.

  2. Update CONTRIBUTING.md with details on how to execute Faucet tests.

@achaljhawar achaljhawar requested a review from Patel-Raj11 June 15, 2025 13:47
@Patel-Raj11
Copy link
Collaborator

@achaljhawar There are conflicts in packages/xrpl/test/integration/fundWallet.test.ts. Please merge in the latest main branch to fix them. I'll have a look once those are resolved.

@achaljhawar
Copy link
Contributor Author

@Patel-Raj11 can you check now?

Copy link
Collaborator

@Patel-Raj11 Patel-Raj11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Nice work!

@achowdhry-ripple
Copy link
Collaborator

nice job with this!

@Patel-Raj11
Copy link
Collaborator

@achaljhawar Commits must be signed before we can merge the PR. Can you enable signing at your end and sign the commits and force push?

@achaljhawar
Copy link
Contributor Author

@Patel-Raj11 I have signed the commits and force-pushed to this branch

@Patel-Raj11 Patel-Raj11 merged commit 0eb77a9 into XRPLF:main Jun 19, 2025
14 checks passed
khancode pushed a commit that referenced this pull request Jun 21, 2025
* refactor(tests): separate faucet tests from local integration tests

* feat: add Faucet test workflow and documentation

* fix: Add missing test:faucet script

* fix: execute tests one time

Co-authored-by: Raj Patel <rajp@ripple.com>

* fix: remove docker steps from faucet test workflow

* docs: update faucet tests section in CONTRIBUTING.md

* fix: remove comment from contributing.md

Co-authored-by: Raj Patel <rajp@ripple.com>

* fix: remove test:all from root package

Co-authored-by: Raj Patel <rajp@ripple.com>

* Update CONTRIBUTING.md

---------

Co-authored-by: Raj Patel <rajp@ripple.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.

Separate faucet tests from test:integration run script
5 participants