Repository navigation
Test onEvent where from config.yaml to rows over real HyperSync and RPC sources - #1762
Merged
Merged
Conversation
A Scenario chain can now be left unmocked with `~servedChains`, so its config.yaml HyperSync or RPC url reaches a local server and the real source builds, sends and decodes the query. The mock HyperSync server gains a fixed port, the Cap'n Proto query format the configured client sends by default, and a chain mode that answers each query with the logs its selection matches. `ServedEvmChain` serves one set of logs over both HyperSync and JSON-RPC, filtering eth_getLogs the same way, and reads back the filters each source sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WdwJuj1pgyeoPb8vfekdfy
The `where` coverage asserted on resolved topic selections, parser output and registration fields. It now runs the real indexer loop on Postgres against served chains, over HyperSync and RPC alike, and asserts the rows the handlers wrote and the filters each source sent: every indexed param type, OR alternatives, per-chain callbacks, `false`, chain.<Contract>.addresses (including an address registered mid-run and client-side filtering), and block start blocks. Registration errors are asserted from a user test module calling indexer.onEvent. Two cases can't pass from the outside today and are marked as expected failures: a Fuel registration drops its `where` entirely, and an AND of address params misses a log whose addresses sit in different address partitions when queried server-side. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WdwJuj1pgyeoPb8vfekdfy
Contributor
…75h83-where-tests
- Mock HyperSync chain mode: drop transaction rows and include_all_blocks handling; the indexer loop needs neither, and chain_page can't fail. - ServedEvmChain: own the ports/height, emit config.yaml chain entries, share the Routed schema/handler prelude, and run a scenario to its end block with a fresh exit flag per run (replaces the per-test endBlock value and the served() thunk). - Scenario: a run either mocks every chain or leaves every chain on its YAML source (~yamlSources), instead of a per-chain served list. - Drop the unused EmptyFiltersArray event from HandlerRegisterLifecycle. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WdwJuj1pgyeoPb8vfekdfy
With EventFilters, EventBlockFilter and ClientAddressFilter gone, nothing calls LogSelection.materializeTopicSelections or Config.getEventConfig. That leaves Internal.topicSelection, the TopicFilter module and the Viem pad/toHex bindings unused too. TestChainMetrics.caughtUpAt was already unused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WdwJuj1pgyeoPb8vfekdfy
DZakh
enabled auto-merge (squash)
October 22, 2026 20:24
DZakh
disabled auto-merge
October 22, 2026 20:25
This branch was successfully deployed
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.
Replaces the white-box
onEventwheretests with tests from the outside. The old tests asserted on resolved topic selections,parseWhereOrThrowoutput and registration fields. The new ones run a real config.yaml, real handler source and the real indexer loop on Postgres. The real HyperSync and RPC sources fetch from local servers that return only the logs the query's filter matches. The tests assert two things: the rows the handlers wrote, and the filters each source sent.This is groundwork for anonymous EVM events (discussed on #1706). That work changes how topics are assembled, and these tests don't depend on the internals it touches. Production code is unchanged.
Harness
mock_hypersync_server.rs(test-only):takeQueries.Scenario.run ~yamlSources: every chain keeps the source its YAML names instead ofMockSource.ServedEvmChain:eth_getLogsfiltered on address and topics).{fromBlock, filters: [{address, topics}]}.Routedschema and handler (one row per log, keyedchain-block-logIndex-name), and arunthat drains old queries, runs the scenario and waits for every chain to reach its end block.Old → new
OnEventWhereParams: a matching and a non-matching log per type, rows over HyperSync (chains 1, 2) and RPC (chains 3, 4)OnEventWhereParamsTransferchain.X.addresses, address-param groupsOnEventWhereAddresses: rows plus the address topics sent, including an address registered mid-run and client-side filteringparams: [], equal-resolving second registration,where: falseOnEventWhereParamsUnfiltered / Dropped (no rows, no raw_events)_gte, block + params,true/false/per-chain callbacks, start_block override, firstfromBlockOnEventWhereBlock: rows and firstfrom_blockon both sourcesOnEventWhereErrors: exact textOnEventWhereParamsDroppedwhere, callback once per chain,where: false+ raw eventsOnEventWhereAddresses; aWhereCallsentity; a raw_events assertionblock.height/block.numberFuelOnEventWhere(expected failure, see below)Deleted:
EventFilters_test.res,EventBlockFilter_test.resandClientAddressFilter_test.res.wherecases inOnEventRegistration_test,HandlerRegister_testandHandlerRegisterLifecycle_test. Their onBlock tests stay.HandlerRegister_test.reswas also reformatted by the formatter hook; it wasn't formatted on main.Gaps found (kept as expected failures)
where.buildFuelOnEventRegistrationdrops it, soblock.height._gtenever sets a start block andblock.numberis never rejected. The old tests calledparseWhereOrThrowwith the Fuel schema directly, a path Fuel itself never takes.chain.X.addressesparams misses logs across address partitions. Take{from: addresses, to: addresses}, with one address from config and one added by contractRegister. HyperSync is queried withfrom∈{R1},to∈{R1}andfrom∈{R2},to∈{R2}, so the transfer R1→R2 is never fetched. It works when both addresses are configured, and with client-side filtering. Turning this case into a normal test fails withexpected [] to deeply equal ['1-9-0-Moved','2-9-0-Moved'].Not reproduced from the outside: a
wherecallback on a handler registered beforestartRegistration. The old test only asserted that nothing threw.Verification
cargo fmt --checkandcargo clippy --all-targets --all-features -D warningsare clean. Mock-server Rust tests: 6/6.ENVIO_TEST_STORAGE=clickhouse) on the scenario files: 7 passed + 1 expected failure.pnpm lintandrescript format --checkare clean.ENVIO_API_TOKEN, which theenvio-testsCI job already gets.🤖 Generated with Claude Code
https://claude.ai/code/session_01WdwJuj1pgyeoPb8vfekdfy
Summary by CodeRabbit