Repository navigation
fix(scripts): exit non-zero when Friendbot funding fails - #111
Merged
Busiii-adetiba merged 1 commit intoOct 18, 2026
Merged
Conversation
02-fund-accounts.js called res.json() unconditionally, so Friendbot's HTML/text error bodies crashed the step with a SyntaxError, and the script always exited 0 even when no account was funded. - read the body as text first and parse JSON from it, so non-JSON error bodies are reported instead of crashing - validate every key with StrKey.isValidEd25519PublicKey before contacting Friendbot - treat an "already funded" response as success - exit non-zero when any account could not be funded, so the step can be chained with && - cover the exit-code contract with node:test, stubbing fetch Fixes SynapsVault#31
4 tasks
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.
Problem
scripts/02-fund-accounts.js(#31):fund()calledres.json()unconditionally. Friendbot answers some failures with HTML or plain text, so the step crashed with aSyntaxErrorinstead of reporting the failure.0, even when no account was funded, so a failed step 2 looked successful to anything chained after it.Change
readBody), so a non-JSON error body is reported instead of crashing the step.StrKey.isValidEd25519PublicKeybefore contacting Friendbot; invalid keys abort with exit 1 and Friendbot is never called.already fundedresponse as success — the account already holds testnet XLM.test/fund-accounts.test.cjscovers the exit-code contract end-to-end (the script is spawned withfetchstubbed bytest/friendbot-fetch-stub.mjs): success, already-funded, non-JSON error body, network failure, partial failure, invalid keys and missing arguments.Verification
test/fund-accounts.test.cjspass (node --test, same command asnpm test); they assert exit codes and captured output, and that Friendbot is never contacted for invalid keys.node --checkpasses for every script.Fixes #31