diff --git a/.github/workflows/faucet_test.yml b/.github/workflows/faucet_test.yml new file mode 100644 index 0000000000..512274278d --- /dev/null +++ b/.github/workflows/faucet_test.yml @@ -0,0 +1,50 @@ +name: Faucet Tests + +on: + push: + branches: [main] + workflow_dispatch: + +jobs: + faucet-test: + runs-on: ubuntu-latest + timeout-minutes: 15 + + strategy: + max-parallel: 1 + matrix: + node-version: [18.x] + + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Setup npm version 10 + run: | + npm i -g npm@10 --registry=https://registry.npmjs.org + + - name: Cache node modules + id: cache-nodemodules + uses: actions/cache@v4 + env: + cache-name: cache-node-modules + with: + path: | + node_modules + */*/node_modules + key: ${{ runner.os }}-deps-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-deps-${{ matrix.node-version }}- + + - name: Install Dependencies + if: steps.cache-nodemodules.outputs.cache-hit != 'true' + run: npm ci + + - name: Build + run: npm run build + + - name: Run Faucet Tests + run: npm run test:faucet diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 137765c33d..9ffb6f95ee 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -79,6 +79,20 @@ Breaking down the command: * `--entrypoint bash rippleci/rippled:develop` manually overrides the entrypoint (for the latest version of rippled on the `develop` branch) * `-c 'rippled -a'` provides the bash command to start `rippled` in standalone mode from the manual entrypoint +### Faucet Tests + +Faucet tests are designed to ensure the functionality of account funding and other interactions that require a funded wallet, typically by interacting with a Faucet service. These tests are crucial for verifying real-world scenarios where new accounts need to be activated on the XRP Ledger. + +To run Faucet tests locally, you'll first need to ensure your development environment is set up and the project is built. Faucet tests do not require a locally running `rippled` instance to execute. + +From the root directory of xrpl.js, run the following commands: + +```bash +npm install +npm run build +npm run test:faucet +``` + ### Browser Tests There are two ways to run browser tests. diff --git a/package.json b/package.json index 5e38cf551f..fc9b816b96 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "test": "lerna run test --stream", "test:browser": "lerna run test:browser --stream", "test:integration": "lerna run test:integration --stream", + "test:faucet": "lerna run test:faucet --stream", "lint": "lerna run lint --stream", "clean": "lerna run clean --stream", "build": "lerna run build --stream", diff --git a/packages/xrpl/jest.config.faucet.js b/packages/xrpl/jest.config.faucet.js new file mode 100644 index 0000000000..10988560f3 --- /dev/null +++ b/packages/xrpl/jest.config.faucet.js @@ -0,0 +1,13 @@ +// Jest configuration for faucet tests +const base = require('../../jest.config.base.js') + +module.exports = { + ...base, + roots: [...base.roots, '/test'], + testTimeout: 60000, // Longer timeout for faucet tests + testMatch: [ + '/test/faucet/**/*.test.ts', + '/test/faucet/*.test.ts', + ], + displayName: 'xrpl.js-faucet', +} diff --git a/packages/xrpl/jest.config.integration.js b/packages/xrpl/jest.config.integration.js index 030137aa0c..c2ca6ca420 100644 --- a/packages/xrpl/jest.config.integration.js +++ b/packages/xrpl/jest.config.integration.js @@ -1,4 +1,4 @@ -// Jest configuration for api +// Jest configuration for integration tests (local rippled only) const base = require('../../jest.config.base.js') module.exports = { @@ -9,5 +9,6 @@ module.exports = { '/test/integration/**/*.test.ts', '/test/integration/*.test.ts', ], + testPathIgnorePatterns: ['/test/faucet/'], displayName: 'xrpl.js', } diff --git a/packages/xrpl/package.json b/packages/xrpl/package.json index 10f86b144f..39efd05fac 100644 --- a/packages/xrpl/package.json +++ b/packages/xrpl/package.json @@ -60,6 +60,7 @@ "prepublish": "run-s clean build", "test": "jest --config=jest.config.unit.js --verbose false --silent=false", "test:integration": "TS_NODE_PROJECT=tsconfig.build.json jest --config=jest.config.integration.js --verbose false --silent=false --runInBand", + "test:faucet": "jest --config jest.config.faucet.js", "test:browser": "npm run build && npm run build:browserTests && karma start ./karma.config.js", "test:watch": "jest --watch --config=jest.config.unit.js --verbose false --silent=false", "format": "prettier --write '{src,test}/**/*.ts'", diff --git a/packages/xrpl/test/integration/fundWallet.test.ts b/packages/xrpl/test/faucet/fundWallet.test.ts similarity index 100% rename from packages/xrpl/test/integration/fundWallet.test.ts rename to packages/xrpl/test/faucet/fundWallet.test.ts