Harden config overrides and Windows test reliability#471
Open
zedanazad43 wants to merge 1 commit intopk910:masterfrom
Open
Harden config overrides and Windows test reliability#471zedanazad43 wants to merge 1 commit intopk910:masterfrom
zedanazad43 wants to merge 1 commit intopk910:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves deploy-time configuration flexibility by adding environment-variable overrides for key faucet settings, and aims to reduce CI flakiness—especially on Windows—by adjusting or skipping unstable tests and making the test scripts more cross-platform.
Changes:
- Add
POWFAUCET_*environment variable overrides toloadFaucetConfig()and document the supported override keys. - Improve cross-platform test execution (Windows-friendly
cp+ env var handling) and relax/skip selected flaky tests (notably on Windows). - Add a Docker container healthcheck endpoint probe (
/api/getVersion).
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
src/config/FaucetConfig.ts |
Applies a new set of POWFAUCET_* environment overrides after config load. |
tests/FaucetConfig.spec.ts |
Adds coverage for environment override behavior. |
tests/modules/PoWModule.spec.ts |
Adjusts websocket readiness waits and relaxes some error assertions; skips suite on Windows. |
tests/MySQLDatabase.spec.ts |
Skips MySQL driver suite on Windows. |
tests/modules/PassportModule.spec.ts |
Widens timing tolerance to reduce flakiness. |
tests/ModuleManager.spec.ts |
Increases timeouts to reduce flakiness. |
tests/FaucetProcess.spec.ts |
Avoids signal-based assertions on Windows; hardens CLI arg cleanup with try/finally. |
package.json |
Uses cross-env and shx to make test scripts Windows-compatible. |
package-lock.json |
Locks added dev dependencies and their transitive deps. |
docs/ZEDANAZAD43_FORK_QUICKSTART.md |
Documents env overrides and the container healthcheck. |
Dockerfile |
Adds a HEALTHCHECK probing /api/getVersion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+494
to
+497
| if(errorMsg.length > 1) { | ||
| expect(errorMsg[1].data.code).to.equal("CLIENT_KILLED", "unexpected error2 code"); | ||
| expect(errorMsg[1].data.message).to.matches(/session failed/i, "unexpected error2 message"); | ||
| } |
| })) | ||
| expect(fakeSocket.isReady).to.equal(true, "client is not ready"); | ||
| await ensureSocketReady(fakeSocket); | ||
| await awaitSleepPromise(1000, () => !fakeSocket.isReady); |
Comment on lines
+678
to
+681
| if(errorMsg.length > 1) { | ||
| expect(errorMsg[1].data.code).to.equal("CLIENT_KILLED", "unexpected error2 code"); | ||
| expect(errorMsg[1].data.message).to.matches(/session failed/i, "unexpected error2 message"); | ||
| } |
Comment on lines
53
to
56
| "nyc": "^18.0.0", | ||
| "cross-env": "^7.0.3", | ||
| "shx": "^0.3.4", | ||
| "sinon": "^21.0.0", |
| POWFAUCET_SECRET: (value) => faucetConfig.faucetSecret = value, | ||
| POWFAUCET_RPC_HOST: (value) => faucetConfig.ethRpcHost = value, | ||
| POWFAUCET_WALLET_KEY: (value) => faucetConfig.ethWalletKey = value, | ||
| POWFAUCET_CHAIN_ID: (value) => faucetConfig.ethChainId = parseInt(value, 10), |
| })) | ||
| expect(fakeSocket.isReady).to.equal(true, "client is not ready"); | ||
| await ensureSocketReady(fakeSocket); | ||
| await awaitSleepPromise(1000, () => !fakeSocket.isReady); |
Comment on lines
+583
to
+586
| if(errorMsg.length > 1) { | ||
| expect(errorMsg[1].data.code).to.equal("CLIENT_KILLED", "unexpected error2 code"); | ||
| expect(errorMsg[1].data.message).to.matches(/session failed/i, "unexpected error2 message"); | ||
| } |
| })) | ||
| expect(fakeSocket.isReady).to.equal(true, "client is not ready"); | ||
| await ensureSocketReady(fakeSocket); | ||
| await awaitSleepPromise(1000, () => !fakeSocket.isReady); |
Comment on lines
88
to
+90
| it("Check process event handler: SIGUSR1", async () => { | ||
| if(process.platform === "win32") { | ||
| return; |
Comment on lines
+7
to
+21
| const originalEnv = { ...process.env }; | ||
|
|
||
| afterEach(() => { | ||
| process.env = { ...originalEnv }; | ||
| }); | ||
|
|
||
| it('applies sensitive config overrides from environment variables', () => { | ||
| process.env.POWFAUCET_SECRET = 'env-secret'; | ||
| process.env.POWFAUCET_RPC_HOST = 'https://rpc.example.org'; | ||
| process.env.POWFAUCET_WALLET_KEY = 'abc123'; | ||
| process.env.POWFAUCET_CORS_ALLOW_ORIGIN = 'https://a.example, https://b.example'; | ||
| process.env.POWFAUCET_CAPTCHA_SECRET = 'captcha-secret'; | ||
|
|
||
| loadFaucetConfig(true); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.