Skip to content

test: Give BlockHeader's scalars default initializers - #1681

Merged
chfast merged 1 commit into
masterfrom
test/blockheader-nsdmi
Aug 29, 2026
Merged

test: Give BlockHeader's scalars default initializers#1681
chfast merged 1 commit into
masterfrom
test/blockheader-nsdmi

Conversation

@chfast

@chfast chfast commented Aug 29, 2026

Copy link
Copy Markdown
Member

test::BlockHeader left six scalars without initializers — difficulty, block_number,
gas_limit, gas_used, timestamp and base_fee_per_gas — so BlockchainTest t; carried
whatever was on the stack. Every other member self-initializes, and state::BlockInfo, the type
this parallels, has = 0 on all of its, so this was the one gap.

Production never noticed because load_blockchain_tests() fills every field from JSON. A
hand-built fixture did: the blockchain runner test reported a genesis block number of
100566652073168 and worked around it with value-initialization, which this removes — leaving the
test as the canary if a bare scalar ever comes back. Verified by default-initializing a
BlockHeader into memory poisoned with 0xAA: before, all six held the poison; after, all six
are zero.

Six of them had none, so a default-initialized BlockchainTest carried
whatever was on the stack. Nothing in production noticed, because the JSON
loader fills every field, but a hand-built fixture did: the blockchain
runner test reported a genesis block number of 100566652073168 and worked
around it with value-initialization.

state::BlockInfo, the type this parallels, initializes every scalar.
@codspeed-hq

codspeed-hq Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 129 untouched benchmarks


Comparing test/blockheader-nsdmi (62e6989) with master (aa9ca51)

Open in CodSpeed

@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.86%. Comparing base (aa9ca51) to head (62e6989).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1681   +/-   ##
=======================================
  Coverage   97.86%   97.86%           
=======================================
  Files         176      176           
  Lines       15995    15995           
  Branches     3666     3666           
=======================================
  Hits        15654    15654           
  Misses        255      255           
  Partials       86       86           
Flag Coverage Δ
eest-develop 87.66% <ø> (ø)
eest-develop-gmp 26.08% <0.00%> (ø)
eest-legacy 16.82% <0.00%> (ø)
eest-libsecp256k1 28.31% <0.00%> (ø)
eest-stable 87.66% <ø> (ø)
evmone-unittests 93.88% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
core 96.19% <ø> (ø)
tooling 92.89% <ø> (ø)
tests 99.81% <100.00%> (ø)
Files with missing lines Coverage Δ
test/unittests/blockchaintest_runner_test.cpp 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Initializes all scalar BlockHeader fields to prevent indeterminate values in hand-built test fixtures.

Changes:

  • Adds zero-valued default member initializers.
  • Updates the runner fixture to exercise default initialization.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/utils/blockchaintest.hpp Zero-initializes scalar header fields.
test/unittests/blockchaintest_runner_test.cpp Uses default initialization as a regression canary.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chfast
chfast merged commit 009d950 into master Aug 29, 2026
26 checks passed
@chfast
chfast deleted the test/blockheader-nsdmi branch August 29, 2026 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants