Add eth_subscribe(logs) test coverage#3475
Draft
wen-coding wants to merge 2 commits into
Draft
Conversation
Remove t.Skip() from: - TestFilterGetLogs, TestFilterSeiGetLogs, TestFilterGetFilterLogs, TestFilterGetFilterChanges, TestGetLogsBlockHashIsNotZero, TestFilterEthEndpointReturnsNormalEvmLogEvenIfSyntheticLogIsInSameBlock (filter_test.go) - TestSubscribeNewLogs (subscribe_test.go) Five distinct test-only mock-setup issues were keeping these broken, none of which are production bugs: - DebugTraceHashHex literal equals tx1.Hash(); the second MockReceipt(CtxDebugTrace, DebugTraceHashHex, ...) call clobbered Tx1's full receipt with an empty-logs one, so every per-receipt log query on block 8 returned zero matches. - Non-LatestCtxHeight ctxProvider branches left ClosestUpgradeName unset, routing isReceiptFromAnteError onto its pre-v5.8.0 branch and wrongly excluding synthetic receipts with EffectiveGasPrice==0. - ctxProvider(LatestCtxHeight) returned baseCtx (height 8); the WatermarkManager's min-across-sources behaviour then capped the latest watermark below blocks 100/103 that the mocks populate. - The block-100 synthetic receipt had EffectiveGasPrice=0, tripping the Status==0 && EGP==0 ante-error nonce-continuity gate even though the TxType=ShellEVMTxType marker still handles eth-namespace filtering. - Default-range eth_getLogs queries resolve to [latest, latest], but MockHeight103 had no logs for the synthetic-topic subtest to match. Test-side fixes: - evmrpc/setup_test.go: drop the redundant MockReceipt overwrite on tx1's hash; apply LatestCtxUpgradeName on every ctxProvider branch and report MockHeight103 as the latest height; bump the block-100 synth receipt EGP and add a synth log at MockHeight103. - evmrpc/subscribe_test.go: query a fixed historical block range (MockHeight8) rather than depending on the FromBlock=0+ToBlock=latest rewrite path. - evmrpc/filter_test.go: update TestFilterGetFilterChanges expected count (5 -> 7) to match the always-include-synthetic semantics for eth_/sei_ log endpoints. - evmrpc/info_test.go: update TestBlockNumber and TestFeeHistory to expect MockHeight103 as the latest height. No production code is touched. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Extend the ws_test integration package with a full end-to-end check
of eth_subscribe("logs") delivery, mirroring the existing
eth_subscribe("newHeads") coverage:
- New emitter contract (hand-crafted ~43-byte init code) whose
constructor emits a single LOG1 with a fixed topic
(0x4242…4242) and returns a 1-byte STOP runtime. Source is
committed alongside the hex for documentation; no solc step is
required to rebuild.
- evm_rpc_tests.sh deploys the emitter in the seed phase, captures
contractAddress + blockNumber from the deploy receipt, and exports
SEI_EVM_WS_EMITTER_ADDRESS + SEI_EVM_WS_EMITTER_BLOCK for the Go
test. The pattern mirrors how the reverter contract is wired; a
failed deploy logs a WARNING and the new test skips rather than
fails.
- TestEthSubscribeLogs subscribes with
{fromBlock=deploy_block, toBlock=deploy_block, address=emitter},
reads the ack, reads one log notification, and asserts on
subscription id, log address, blockNumber, single topic, and topic
value. Uses strings.EqualFold throughout for hex-casing tolerance.
The test is consensus-mode agnostic and will run on both the EVM RPC
and Autobahn RPC matrix jobs that already exercise newHeads.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3475 +/- ##
==========================================
+ Coverage 59.02% 59.07% +0.04%
==========================================
Files 2188 2188
Lines 181890 181890
==========================================
+ Hits 107362 107443 +81
+ Misses 64908 64831 -77
+ Partials 9620 9616 -4
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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
Seven
eth_subscribe/log-filter tests inevmrpc/were silently skipped viat.Skip(), leaving a coverage gap in the EVM log path. Unskip them by fixing mock-setup issues — no production code touched.Also add an end-to-end integration test for
eth_subscribe("logs")on a live cluster, mirroring the existingnewHeadsintegration test.Changes
evmrpc/(commit 1) — Five distinct test-only mock-setup issues were keeping the 7 tests broken. The load-bearing one:DebugTraceHashHexliteral happens to equaltx1.Hash(), so a laterMockReceipton that hash was overwriting tx1's full receipt with an empty-logs one. Per-commit log explains the rest.integration_test/evm_module/(commit 2) — NewTestEthSubscribeLogs. A tiny emitter contract whose constructor emits oneLOG1is deployed in the seed phase; the test subscribes to{fromBlock=deploy_block, toBlock=deploy_block, address=emitter}and asserts the log is delivered over the WS. Consensus-mode agnostic — runs on both the EVM RPC and Autobahn RPC matrix jobs.Test plan
go test ./evmrpc/ -count=1— PASS (24.9s)gofmt -s -l+go vetclean🤖 Generated with Claude Code