test(stf): add unit tests for processDeposit#288
test(stf): add unit tests for processDeposit#288lodekeeper-z wants to merge 1 commit intoChainSafe:mainfrom
Conversation
Add inline tests for the deposit processing module covering: - DepositData union accessors for phase0 and electra variants - addValidatorToRegistry with correct effective balance, epoch fields, and participation entries - applyDeposit electra path for existing validators (pending deposit) - applyDeposit with invalid BLS signature (silently skipped) - applyDeposit with valid signature (new validator + pending deposit) 🤖 Generated with AI assistance Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the test coverage for the deposit processing logic, which is a critical component of the state transition function. By introducing these tests, the codebase gains better validation for validator registration and deposit handling, ensuring correctness for the upcoming network upgrades. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates a doc comment for capitalization and introduces a comprehensive suite of unit tests for deposit processing in the Electra fork, covering validator registration and deposit application logic. The review feedback focuses on adhering to the repository's style guide regarding punctuation in comments and improving test clarity by replacing magic numbers with named constants.
| } | ||
|
|
||
| /// refer to https://github.com/ethereum/consensus-specs/blob/v1.5.0/specs/electra/beacon-chain.md#new-is_valid_deposit_signature | ||
| /// Refer to https://github.com/ethereum/consensus-specs/blob/v1.5.0/specs/electra/beacon-chain.md#new-is_valid_deposit_signature |
There was a problem hiding this comment.
According to the style guide, comments that are sentences should end with a period. While you've correctly capitalized 'Refer', please also add a period at the end of the line for full compliance.
/// Refer to https://github.com/ethereum/consensus-specs/blob/v1.5.0/specs/electra/beacon-chain.md#new-is_valid_deposit_signature.
References
- Comments are sentences, with a space after the slash, with a capital letter and a full stop, or a colon if they relate to something that follows. Comments after the end of a line can be phrases, with no punctuation. (link)
| var new_pubkeys: [257]BLSPubkey = undefined; | ||
| try interopPubkeysCached(257, &new_pubkeys); | ||
| const new_pubkey = new_pubkeys[256]; |
There was a problem hiding this comment.
To improve clarity and avoid magic numbers, it's better to define a constant for the new validator's index. This also improves consistency with other tests in this file. You can define the array size based on this constant.
const new_validator_index: usize = 256;
var new_pubkeys: [new_validator_index + 1]BLSPubkey = undefined;
try interopPubkeysCached(new_pubkeys.len, &new_pubkeys);
const new_pubkey = new_pubkeys[new_validator_index];
| var new_pubkeys: [257]BLSPubkey = undefined; | ||
| try interopPubkeysCached(257, &new_pubkeys); | ||
| const new_pubkey = new_pubkeys[256]; |
There was a problem hiding this comment.
To improve clarity and avoid magic numbers, it's better to define a constant for the new validator's index. This also improves consistency with other tests in this file. You can define the array size based on this constant.
const new_validator_index: usize = 256;
var new_pubkeys: [new_validator_index + 1]BLSPubkey = undefined;
try interopPubkeysCached(new_pubkeys.len, &new_pubkeys);
const new_pubkey = new_pubkeys[new_validator_index];
| var all_pubkeys: [257]BLSPubkey = undefined; | ||
| try interopPubkeysCached(257, &all_pubkeys); |
There was a problem hiding this comment.
Summary
Add 6 unit tests for
process_deposit.zig— the largest untested block processor (228 lines, 0 tests).Tests added
Motivation
Improves test coverage for the deposit processing path, which is critical for North Star 1 (native STF correctness).
🤖 Generated with AI assistance