Fixes to test client - #60
Conversation
…hutdown, and dynamic import resolution - sendTransaction: pass body as-is instead of double-JSON-encoding - getMappingValue: preserve literal brackets in array-type mapping keys - devnode: shut down any existing instance before starting a new one - devnode: set CONSENSUS_VERSION_HEIGHTS env for correct consensus versioning - devnode: add createDevnodeTestClient helper - provable: resolve call.dynamic imports recursively before building execution tx - vitest: narrow example glob to *.test.ts; suppress SDK deployment noise logs
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…des percent-encoded path segments
iamalwaysuncomfortable
left a comment
There was a problem hiding this comment.
Some minor nits
There was a problem hiding this comment.
Pull request overview
This PR consolidates test-client fixes accumulated while building the AMM v3 and private mint wrapper examples (see linked PRs #58, #59). It addresses devnode lifecycle issues, an HTTP transport double-encoding bug, dynamic import resolution for call.dynamic, and adds an install script for the aleo-devnode binary.
Changes:
- Fix double JSON encoding in HTTP transport's
sendTransaction, and add direct REST-based recursive import fetching in@veil/provablethat avoids the broken/latest_editionendpoint on devnode. - Make
startDevnodeasync with auto-shutdown of any existing devnode on the same socket, setCONSENSUS_VERSION_HEIGHTSenv, and add optional verbose log-to-file mode. - Narrow vitest test glob, add
@veil/leo/@veil/devnodealiases, suppress noisy SDK console output, and add a newinstall.shscript for installing thealeo-devnodebinary.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/core/src/transports/http.ts |
Pass the already-serialized transaction string as the request body instead of re-stringifying. |
packages/provable/src/index.ts |
Recursively resolve call.dynamic import sources via direct REST instead of the SDK network client. |
packages/devnode/src/index.ts |
Add tryShutdownExisting, set CONSENSUS_VERSION_HEIGHTS, and add optional verbose log file. |
packages/devnode/install.sh |
New install script that downloads and installs aleo-devnode from GitHub releases. |
vitest.config.ts |
Narrow examples glob, add new package aliases, and filter noisy SDK console output. |
.gitignore |
Ignore devnode*.log files emitted by the new verbose mode. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
iamalwaysuncomfortable
left a comment
There was a problem hiding this comment.
Thanks for all this work! This is extremely dope.
Summary
This PR collates all of the modifications from the AMM and private mint wrapper examples. The Leo code and corresponding test files are not part of this PR (the DEX is not fully open-source), but the PRs for both of those examples are linked below:
#58
#59
packages/core/src/transports/http.ts
sendTransaction double-encoding bug — the body was wrapped in JSON.stringify() even though the caller already passes a serialized JSON string, resulting in a double-encoded payload that the node rejected. Fixed to pass the string as-is.
packages/devnode/src/index.ts
Auto-shutdown of existing devnode — added tryShutdownExisting() which sends a shutdown request to the devnode address before starting a new instance. Without this, if a test run crashed before afterAll could clean up, the next run would fail immediately with Program X already exists on the network errors.
CONSENSUS_VERSION_HEIGHTS environment variable
Set when spawning the devnode process to ensure all 14 consensus versions are correctly mapped. Without this the devnode defaults to an incorrect version schedule.
Removed
createDevnodeTestClientwrapperThis was a thin convenience wrapper around createTestClient from @veil/core that unnecessarily coupled @veil/devnode to @veil/core. Call sites now construct the test client directly, which is more explicit and removes the dependency.
packages/provable/src/index.ts
Dynamic import resolution for call.dynamic — when building an execution transaction for a program that uses call.dynamic, the SDK needs the source of any dynamically-called programs pre-fetched. The previous implementation used programManager.networkClient.getProgramImports() which internally hits /latest_edition — an endpoint that returns 500 on the devnode. Replaced with direct REST fetches and regex parsing of import statements to resolve the full transitive dependency tree without touching that endpoint.
vitest.config.ts
Narrowed test glob — changed examples//*.ts to examples//*.test.ts so vitest doesn't try to execute utility and client source files as test suites.
SDK log suppression
Added an onConsoleLog filter to discard noisy SDK output during deployments (program-existence retries, snarkVM loading messages, fee authorization logs). These were obscuring actual test output without adding diagnostic value.
packages/devnode/install.sh
New install script that queries the GitHub API for the latest release, detects the host OS and architecture, downloads the appropriate zip, extracts the binary, and installs it to a configurable path (default /usr/local/bin). Supports pinning a specific version via the VERSION environment variable.