feat(txe): add oracle roundtrip test framework#23537
Draft
nchamo wants to merge 2 commits into
Draft
Conversation
nchamo
commented
May 24, 2026
| @@ -383,16 +384,16 @@ export async function callTxeHandler<K extends keyof typeof TXE_ORACLE_REGISTRY> | |||
| }): Promise<ForeignCallResult> { | |||
| const entry = TXE_ORACLE_REGISTRY[oracle] as OracleRegistryEntry; | |||
| // TXE foreign calls use bare hex strings, but Fr.fromString requires a 0x prefix to parse as hex. | |||
| const prefixHex = (s: string) => (s.startsWith('0x') ? s : `0x${s}`); | |||
Contributor
Author
There was a problem hiding this comment.
Figured out there was already a function for this
Collaborator
Flakey Tests🤖 says: This CI run detected 1 tests that failed, but were tolerated due to a .test_patterns.yml entry. |
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.
Why we are doing this
Oracle calls between Noir and TypeScript cross a serialization boundary — values are serialized in Noir, sent over JSON-RPC as hex strings, and deserialized back in TS. There was no automated way to verify that the TS oracle registry's type definitions (params and return types) correctly round-trip through this boundary. A mismatch silently produces wrong values at runtime. Some oracles had tests named "serialization should match typescript", but those were hard to maintain and impossible to actually verify across the Noir/TS boundary.
Our fix
Introduces an
#[oracle_test]Noir macro and a lightweight TS test resolver that together verify serialization correctness for each oracle in the registry.Noir side:
#[oracle_test]generates__oracle_test__-prefixed test functions that call the real oracle with known inputs and assert on the output. For oracles with multiple scenarios (e.g. Option returning some/none),#[oracle_test("scenario_name")]selects a named fixture via a meta-oracle call before invoking the real oracle.TS side:
OracleTestResolverreceives the oracle call, selects the matching fixture scenario, deserializes the incoming hex inputs using the registry's param definitions, and verifies they match the expected values from the fixture. It then serializes the fixture output through the registry's return type and sends it back. Noir asserts the received values match the expected output, closing the loop.Notes
bootstrap.shstarts the resolver server on a separate port, runs all__oracle_test__tests against it, and filters them out of the regular TXE test runavm_storage_read,get_sender_for_tagswithsome/nonescenarios) and 9 unit tests for the resolvertxe_oracle_registry.tsandtxe_oracle_version.tsintooracle/subdirectory and replaces hand-rolled hex prefix helpers withwithHexPrefix/withoutHexPrefixfrom foundation