Skip to content

Add eth_subscribe(logs) test coverage#3475

Draft
wen-coding wants to merge 2 commits into
mainfrom
wen/add_eth_subscribe_logs_coverage
Draft

Add eth_subscribe(logs) test coverage#3475
wen-coding wants to merge 2 commits into
mainfrom
wen/add_eth_subscribe_logs_coverage

Conversation

@wen-coding
Copy link
Copy Markdown
Contributor

@wen-coding wen-coding commented May 20, 2026

Summary

Seven eth_subscribe/log-filter tests in evmrpc/ were silently skipped via t.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 existing newHeads integration test.

Changes

evmrpc/ (commit 1) — Five distinct test-only mock-setup issues were keeping the 7 tests broken. The load-bearing one: DebugTraceHashHex literal happens to equal tx1.Hash(), so a later MockReceipt on 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) — New TestEthSubscribeLogs. A tiny emitter contract whose constructor emits one LOG1 is 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 vet clean
  • CI green on both EVM RPC and Autobahn RPC matrix jobs

🤖 Generated with Claude Code

wen-coding and others added 2 commits May 20, 2026 11:04
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>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMay 20, 2026, 6:08 PM

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.07%. Comparing base (7f33afe) to head (473a966).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            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     
Flag Coverage Δ
sei-chain-pr 69.53% <ø> (?)
sei-db 70.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant