Fix all 34 failing unit tests without modifying source files#458
Draft
Fix all 34 failing unit tests without modifying source files#458
Conversation
Co-authored-by: alexjavabraz <14118998+alexjavabraz@users.noreply.github.com>
Co-authored-by: alexjavabraz <14118998+alexjavabraz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix tests without changing any other file
Fix all 34 failing unit tests without modifying source files
Feb 19, 2026
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.
Unit tests were failing due to missing environment variables, real network calls without mocks, and test logic issues. All fixes are confined to test files only.
Root Causes & Fixes
Missing env vars at test runtime
dotenvis only loaded byindex.tsat app startup — never duringmocharuns. Affected tests:btc-last-block.service.unit.ts: SetBLOCKBOOK_URLandSYNC_INITIAL_BLOCK_HEIGHTinbeforeEachbtc-utils.unit.ts: SetNETWORK=testnetsogetAddress()uses the correct testnet prefix (default falls back to typo'tesnet')pegout-status.service.unit.ts,pegin-status.service.unit.ts,flyover-service.service.unit.ts,rsk-node.services.unit.ts: SetRSK_NODE_HOSTto preventnew Web3('undefined')/new RskNodeService()constructor failuresReal network calls in unit tests
bridge.handler.unit.ts: Addedsinonstubs for allBridgeServicemethods andBridgeTransactionParser.getBridgeTransactionByTxHashviabeforeEach/afterEachrsk-node.services.unit.ts: Rewrote to use stubs onweb3.eth.*andbridgeTransactionParserafter construction, replacing direct RSK node I/Opegin-status.service.unit.ts:PeginStatusServiceinternally callsisAFedAddress()which hits the bridge contract. Stubbedfederation-addresses.isAFedAddressandRskNodeService.prototype.getBlockNumbervia prototype to avoid the module-levelBridgeServiceinstance:pegout-data.processor.unit.ts:processBatchPegoutsandprocessIndividualPegoutcallgetTxFromRskTransaction(creates a freshWeb3internally for a trace log). Stubbed as private methodTest logic bugs
api-information.controller.unit.ts:process.env.npm_package_versionis only set when running undernpm— switched to readingpackage.jsondirectly, matching the controller implementationpegout-data.processor.unit.ts:afterEachusedsandbox.stub(process.env, 'NETWORK')to restore the env var, which throws when the property doesn't exist. Replaced with a conditional direct assignment and addedsandbox.restore()flyover-service.service.unit.ts:beforeEachinstantiated an unusedRskNodeServicethat was never injected intoFlyoverService. Removed the dead variable; remaining stubs updated to referenceflyoverService.rskNodeServicedirectlyWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
public-node.testnet.rsk.co/home/REDACTED/work/_temp/ghcca-node/node/bin/node node ./node_modules/.bin/mocha --recursive dist/__tests__/**/*.unit.js --timeout 10000 /home/REDACTED/.cache/node-gyp/24.13.0/deps/v8/include -I /home/REDACTED/work/2wp-api/2wp-api/node_modules/secp256k1/node_modules/node-addon-api -I ../src --64(dns block)/usr/bin/curl curl -s -o /dev/null -w %{http_code} --max-time 5 REDACTED(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node node ./node_modules/.bin/mocha --recursive dist/__tests__/**/*.unit.js --timeout 10000 --global odules/.bin/as user.email(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Created from VS Code.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.