test(sdk/node): add unit tests for the Node SDK#15
Merged
Conversation
The Python SDK is covered by sdk/python/tests/test_sdk.py, but the Node
SDK had no tests despite index.js holding the release-critical logic that
decides which bundle a user downloads and whether it is trusted. A
regression there ships a broken installer silently.
Add sdk/node/test/sdk.test.js using the built-in node:test runner (no new
dependencies), mirroring the Python suite:
- resolvePlatform(): the four supported platform/arch pairs plus a range
of unsupported combos returning null.
- personaArgs(): known keys map to the correct --uxr-* flags, unknown
keys still fall back to a --uxr- prefix (never a bare or branded flag),
and null/undefined/{} yield [].
- expectedSha(): parses SHA256SUMS, handles the sha256sum "*asset" binary
marker, returns null for a missing asset, a non-ok response, or a
network error (fetch is mocked, so no network is required).
- sha256(): matches Node's crypto for a known buffer.
- ASSETS: stays consistent with resolvePlatform() and every launcher
lives under tilion-fortress/.
To make the pure functions reachable from the test, export ASSETS,
personaArgs, sha256, and expectedSha from index.js. This is an additive
change with no effect on runtime behaviour.
Wire node --test sdk/node/test/ into the node-sdk CI job.
Closes tiliondev#10
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.
Summary
The Python SDK is covered by
sdk/python/tests/test_sdk.py, but the Node SDK had no tests — even thoughsdk/node/index.jsholds the release-critical logic that decides which bundle a user downloads and whether it is trusted. A regression there ships a broken installer silently.This PR adds a unit suite for that logic, mirroring the Python side, and gates it in CI.
Changes
sdk/node/test/sdk.test.js— new suite using the built-innode:testrunner (no new dependencies). No network or browser is required;fetchis mocked.sdk/node/index.js— exportASSETS,personaArgs,sha256, andexpectedShaso the pure functions are reachable from the test. Additive only; no runtime behaviour changes..github/workflows/ci.yml— runnode --test sdk/node/test/in the existingnode-sdkjob (renamed node sdk syntax → node sdk tests).Coverage
resolvePlatform()nullpersonaArgs()--uxr-*flags; unknown keys fall back to a--uxr-prefix (never a bare/branded flag);null/undefined/{}→[]expectedSha()SHA256SUMS; handles thesha256sum*assetbinary marker; returnsnullfor a missing asset, a non-ok response, or a network errorsha256()cryptofor a known bufferASSETSresolvePlatform(); every launcher lives undertilion-fortress/Verification
node --checkon the CLI and library still passes, and the patch-integrity linter is unaffected.Closes #10