Skip to content

Conversation

@ZocoLini
Copy link
Collaborator

@ZocoLini ZocoLini commented Jan 5, 2026

I dont really know why this feature exists since there is no incomplete mock implementation but here is a PR removing it and enabling and updating tests in the process:

  • rollback tests where removed since that feature is not implemented and doesn't look like its gonna be
  • chain lock tests made unit test to have access to private fields because they need them (idk why a lot of integration tests are unit tests in the wrong place)
  • removed the skip_mock_implementation_incomplete feature enabling a lot of tests (didn't really review their logic since they pass)

Summary by CodeRabbit

  • Tests
    • Removed feature flag gating for mock implementation tests.
    • Enabled previously ignored integration and unit tests for block download, filter sync, and filter header verification.
    • Expanded ChainLock test coverage with new tests for queue/process flow, cache operations, and reorganization protection.
    • Removed obsolete disabled test files.

✏️ Tip: You can customize this high-level summary in your review settings.

@ZocoLini ZocoLini marked this pull request as draft January 5, 2026 21:05
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

📝 Walkthrough

Walkthrough

This PR removes the skip_mock_implementation_incomplete feature flag from Cargo.toml, enables previously disabled tests by removing feature-gate and ignore attributes, deletes two incomplete test files, and expands chainlock test coverage with a new helper function and additional test cases.

Changes

Cohort / File(s) Summary
Feature and Configuration Cleanup
dash-spv/Cargo.toml
Removed the skip_mock_implementation_incomplete feature flag and its preceding comment from the features section, simplifying the build configuration.
Test Activation and Cleanup
dash-spv/tests/block_download_test.rs, dash-spv/tests/edge_case_filter_sync_test.rs, dash-spv/tests/filter_header_verification_test.rs
Enabled previously disabled tests by removing #[ignore] attributes and #[cfg(feature = "skip_mock_implementation_incomplete")] feature-gating, allowing tests to run by default without modifying test logic.
Deleted Test Files
dash-spv/tests/chainlock_validation_test.rs, dash-spv/tests/rollback_test.rs
Removed incomplete integration test files that were heavily gated behind feature flags and ignore attributes. Chainlock validation file contained mock network manager implementation and chainlock validation tests; rollback test file contained disabled disk storage and filter header rollback tests.
Test Expansion
dash-spv/src/chain/chainlock_test.rs
Introduced create_test_chainlock() helper function for constructing test ChainLock objects. Expanded test imports and reworked test_chainlock_processing to use temporary disk storage. Added three new tests: test_chainlock_queue_and_process_flow, test_chainlock_manager_cache_operations, and enhanced test_reorganization_protection to exercise storage-backed processing and cache lookups.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

A rabbit hops through test code clean,
Features gated are now unseen, 🐰
Mock-incomplete, begone! Hooray,
New tests run bright in light of day,
Chainlock helpers bloom so grand,
Progress spreads throughout the land! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective of removing the skip_mock_implementation_incomplete feature flag and enabling previously skipped tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@github-actions github-actions bot added the merge-conflict The PR conflicts with the target branch. label Jan 8, 2026
@ZocoLini ZocoLini force-pushed the chore/enabled-skipped-tests branch from c2b0eee to 45b9134 Compare January 12, 2026 15:36
@github-actions github-actions bot removed the merge-conflict The PR conflicts with the target branch. label Jan 12, 2026
@ZocoLini ZocoLini force-pushed the chore/enabled-skipped-tests branch from 45b9134 to 5fc263b Compare January 12, 2026 16:13
@ZocoLini ZocoLini changed the title chore: enabled skipped tests chore: removed skip_mock_implementation_incomplete feature Jan 12, 2026
@ZocoLini ZocoLini marked this pull request as ready for review January 12, 2026 16:24
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @dash-spv/src/chain/chainlock_test.rs:
- Around line 148-156: The test currently builds a genesis header with
genesis_block(Network::Dash) but constructs a generic ChainState via
ChainState::new() and discards the process result; fix by creating the chain
state for Dash (use ChainState::new_for_network(Network::Dash) or equivalent) to
ensure network consistency with genesis_block, and replace the discarded result
of chainlock_manager.process_chain_lock(...) with an assertion that the call
succeeded (e.g., assert matches Ok/expected variant) so the test fails on errors
instead of hiding them.
🧹 Nitpick comments (2)
dash-spv/src/chain/chainlock_test.rs (2)

11-18: Good helper function, but consider consistent usage across tests.

The helper is used in test_chainlock_superseding (line 62), test_chainlock_queue_and_process_flow (lines 122-124), and test_chainlock_manager_cache_operations (line 152), but test_chainlock_processing (lines 29-33) and test_reorganization_protection (lines 98-102) still construct ChainLock inline. Consider refactoring for consistency.


131-138: Remove or update misleading comment.

The comment on line 132 states "pending_chainlocks is private, can't access directly" but the code immediately accesses it directly. This comment is confusing and should be removed or clarified (e.g., explain that unit tests have access via super::super::*).

♻️ Proposed fix
         // Verify all are queued
         {
-            // Note: pending_chainlocks is private, can't access directly
+            // Unit tests can access internal fields via super::super::*
             let pending = chainlock_manager.pending_chainlocks.read().unwrap();
             assert_eq!(pending.len(), 3);
             assert_eq!(pending[0].block_height, 100);
             assert_eq!(pending[1].block_height, 200);
             assert_eq!(pending[2].block_height, 300);
         }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a01febe and 5fc263b.

📒 Files selected for processing (7)
  • dash-spv/Cargo.toml
  • dash-spv/src/chain/chainlock_test.rs
  • dash-spv/tests/block_download_test.rs
  • dash-spv/tests/chainlock_validation_test.rs
  • dash-spv/tests/edge_case_filter_sync_test.rs
  • dash-spv/tests/filter_header_verification_test.rs
  • dash-spv/tests/rollback_test.rs
💤 Files with no reviewable changes (6)
  • dash-spv/tests/edge_case_filter_sync_test.rs
  • dash-spv/tests/block_download_test.rs
  • dash-spv/Cargo.toml
  • dash-spv/tests/filter_header_verification_test.rs
  • dash-spv/tests/chainlock_validation_test.rs
  • dash-spv/tests/rollback_test.rs
🧰 Additional context used
📓 Path-based instructions (3)
dash-spv/**/*.rs

📄 CodeRabbit inference engine (dash-spv/CLAUDE.md)

dash-spv/**/*.rs: Use async/await throughout the codebase, built on tokio runtime
Use Arc for trait objects to enable runtime polymorphism for NetworkManager and StorageManager
Use Tokio channels for inter-component message passing between async tasks
Maintain minimum Rust version (MSRV) of 1.89 and use only compatible syntax and features

Files:

  • dash-spv/src/chain/chainlock_test.rs
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: MSRV (Minimum Supported Rust Version) is 1.89; ensure compatibility with this version for all builds
Unit tests should live alongside code with #[cfg(test)] annotation; integration tests use the tests/ directory
Use snake_case for function and variable names
Use UpperCamelCase for types and traits
Use SCREAMING_SNAKE_CASE for constants
Format code with rustfmt before commits; ensure cargo fmt --all is run
Run cargo clippy --workspace --all-targets -- -D warnings for linting; avoid warnings in CI
Prefer async/await via tokio for asynchronous operations

**/*.rs: Never hardcode network parameters, addresses, or keys in Rust code
Use proper error types (thiserror) and propagate errors appropriately in Rust
Use tokio runtime for async operations in Rust
Use conditional compilation with feature flags for optional features
Write unit tests for new functionality in Rust
Format code using cargo fmt
Run clippy with all features and all targets, treating warnings as errors
Never log or expose private keys in any code
Always validate inputs from untrusted sources in Rust
Use secure random number generation for keys

Files:

  • dash-spv/src/chain/chainlock_test.rs
**/*test*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

**/*test*.rs: Test both mainnet and testnet configurations
Use proptest for property-based testing where appropriate

Files:

  • dash-spv/src/chain/chainlock_test.rs
🧠 Learnings (11)
📓 Common learnings
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-30T22:00:57.000Z
Learning: Applies to **/*.rs : Use conditional compilation with feature flags for optional features
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-22T17:59:51.097Z
Learning: Run pre-PR checks: `cargo fmt`, `cargo clippy`, `cargo test` (workspace) before submitting pull requests
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-30T22:00:57.000Z
Learning: Applies to **/*.rs : Write unit tests for new functionality in Rust
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-22T17:59:51.097Z
Learning: Applies to **/tests/**/*.rs : Mark network-dependent or long-running tests with `#[ignore]` and run with `-- --ignored`
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Run 'cargo fmt --check' to verify formatting, 'cargo clippy --all-targets --all-features -- -D warnings' for linting, and 'cargo check --all-features' to verify all features compile
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/tests/**/*.rs : Organize tests into unit tests (in-module), integration tests (tests/ directory), real network tests (with live Dash Core nodes), and performance benchmarks

Applied to files:

  • dash-spv/src/chain/chainlock_test.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/sync/**/*.rs : Implement sequential phase-based synchronization via SyncManager with phases progressing in order: Headers → Masternode List → Filter Headers → Filters → Blocks

Applied to files:

  • dash-spv/src/chain/chainlock_test.rs
📚 Learning: 2025-12-01T07:59:58.608Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:58.608Z
Learning: Applies to dash-spv-ffi/tests/unit/**/*.rs : Add corresponding unit tests in `tests/unit/` for each new FFI function

Applied to files:

  • dash-spv/src/chain/chainlock_test.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/tests/**/*.rs : Integration tests should gracefully handle unavailable Dash Core nodes at 127.0.0.1:9999 without failing the test suite

Applied to files:

  • dash-spv/src/chain/chainlock_test.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/validation/**/*.rs : Implement three validation modes: ValidationMode::None (no validation), ValidationMode::Basic (structure and timestamp validation), and ValidationMode::Full (complete PoW and chain validation)

Applied to files:

  • dash-spv/src/chain/chainlock_test.rs
📚 Learning: 2025-12-01T07:59:58.608Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv-ffi/CLAUDE.md:0-0
Timestamp: 2025-12-01T07:59:58.608Z
Learning: Applies to dash-spv-ffi/src/**/*.rs : Use thread-local storage for error propagation via `dash_spv_ffi_get_last_error()` function

Applied to files:

  • dash-spv/src/chain/chainlock_test.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/storage/**/*.rs : Store headers in 10,000-header segments with index files in headers/ directory, filter headers and compact block filters in filters/ directory, and state in state/ directory

Applied to files:

  • dash-spv/src/chain/chainlock_test.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/src/network/**/*.rs : Use DNS-first peer discovery with automatic DNS seeds (dnsseed.dash.org, testnet-seed.dashdot.io) when no explicit peers are configured; implement immediate startup with 10-second delay only for subsequent peer searches

Applied to files:

  • dash-spv/src/chain/chainlock_test.rs
📚 Learning: 2025-06-26T15:54:02.509Z
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T15:54:02.509Z
Learning: The `StorageManager` trait in `dash-spv/src/storage/mod.rs` uses `&mut self` methods but is also `Send + Sync`, and implementations often use interior mutability for concurrency. This can be confusing, so explicit documentation should clarify thread-safety expectations and the rationale for the API design.

Applied to files:

  • dash-spv/src/chain/chainlock_test.rs
📚 Learning: 2025-12-16T09:03:55.811Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: dash-spv/CLAUDE.md:0-0
Timestamp: 2025-12-16T09:03:55.811Z
Learning: Applies to dash-spv/**/*.rs : Use Arc<dyn TraitName> for trait objects to enable runtime polymorphism for NetworkManager and StorageManager

Applied to files:

  • dash-spv/src/chain/chainlock_test.rs
🧬 Code graph analysis (1)
dash-spv/src/chain/chainlock_test.rs (3)
dash/src/blockdata/constants.rs (1)
  • genesis_block (111-184)
test-utils/src/fixtures.rs (1)
  • test_block_hash (42-46)
dash-spv/src/chain/chainlock_manager.rs (2)
  • new (53-62)
  • has_chain_lock_at_height (349-351)
🔇 Additional comments (3)
dash-spv/src/chain/chainlock_test.rs (3)

20-52: LGTM!

The test properly initializes storage, processes a ChainLock, and verifies both storage and retrieval. The assertions are appropriate.


54-87: LGTM!

The test correctly validates that multiple ChainLocks at different heights can be stored and that the highest height is tracked properly.


89-115: LGTM!

The test covers three important scenarios for reorganization protection: before chainlocks, overlapping chainlocks, and after chainlocks.

Comment on lines +148 to +156
let genesis = genesis_block(Network::Dash).header;
storage.store_headers_at_height(&[genesis], 0).await.unwrap();

// Create and process a ChainLock
let chain_lock = create_test_chainlock(0, genesis.block_hash());
let chain_state = ChainState::new();
let _ = chainlock_manager
.process_chain_lock(chain_lock.clone(), &chain_state, &mut storage)
.await;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Verify network consistency and check process result.

Two concerns:

  1. The test uses genesis_block(Network::Dash) but ChainState::new() instead of ChainState::new_for_network(Network::Dash). If ChainState::new() defaults to a different network, this could cause subtle test failures or false positives.

  2. The result of process_chain_lock is discarded with let _ = .... Consider asserting success like other tests do, or at least documenting why the result is intentionally ignored.

🔧 Proposed fix
         // Create and process a ChainLock
         let chain_lock = create_test_chainlock(0, genesis.block_hash());
-        let chain_state = ChainState::new();
-        let _ = chainlock_manager
+        let chain_state = ChainState::new_for_network(Network::Dash);
+        chainlock_manager
             .process_chain_lock(chain_lock.clone(), &chain_state, &mut storage)
-            .await;
+            .await
+            .expect("ChainLock processing should succeed");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let genesis = genesis_block(Network::Dash).header;
storage.store_headers_at_height(&[genesis], 0).await.unwrap();
// Create and process a ChainLock
let chain_lock = create_test_chainlock(0, genesis.block_hash());
let chain_state = ChainState::new();
let _ = chainlock_manager
.process_chain_lock(chain_lock.clone(), &chain_state, &mut storage)
.await;
let genesis = genesis_block(Network::Dash).header;
storage.store_headers_at_height(&[genesis], 0).await.unwrap();
// Create and process a ChainLock
let chain_lock = create_test_chainlock(0, genesis.block_hash());
let chain_state = ChainState::new_for_network(Network::Dash);
chainlock_manager
.process_chain_lock(chain_lock.clone(), &chain_state, &mut storage)
.await
.expect("ChainLock processing should succeed");
🤖 Prompt for AI Agents
In @dash-spv/src/chain/chainlock_test.rs around lines 148 - 156, The test
currently builds a genesis header with genesis_block(Network::Dash) but
constructs a generic ChainState via ChainState::new() and discards the process
result; fix by creating the chain state for Dash (use
ChainState::new_for_network(Network::Dash) or equivalent) to ensure network
consistency with genesis_block, and replace the discarded result of
chainlock_manager.process_chain_lock(...) with an assertion that the call
succeeded (e.g., assert matches Ok/expected variant) so the test fails on errors
instead of hiding them.

@xdustinface xdustinface merged commit 230fbdf into v0.42-dev Jan 12, 2026
53 checks passed
@xdustinface xdustinface deleted the chore/enabled-skipped-tests branch January 12, 2026 23: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.

3 participants