sdk%refac(test): move corpus-based tests to serde direct deser, add dash-dev test utility module, inline tests into parent modules#8
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (73)
💤 Files with no reviewable changes (17)
✅ Files skipped from review due to trivial changes (9)
🚧 Files skipped from review as they are similar to previous changes (31)
📝 WalkthroughWalkthroughAdds a new dev crate (dash-dev) for JSON5 corpus handling and wire/serde validation, introduces serde helpers (str_u64), applies camelCase and custom serde codecs across types, adds corpus fixtures and tests in p2p_core and primitives, and migrates many corpus JSON5 schemas to new shapes. ChangesCorpus-driven test infrastructure and serde standardization
|
|
Note This pull request has no conflicts! 🎊 🎉 🎊 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
pkgs/dev/src/lib.rs (1)
10-11: ⚡ Quick winPrefer
#[expect]over#[allow]per coding guidelines.The coding guidelines specify: "Use
#[expect]over#[allow]". The#[expect]attribute provides better lint hygiene because it will fail if the lint is no longer triggered, helping catch obsolete suppressions.♻️ Proposed fix
-#![allow(dead_code, reason = "exports consumed by tests")] -#![allow(clippy::panic, reason = "development crate")] +#![expect(dead_code, reason = "exports consumed by tests")] +#![expect(clippy::panic, reason = "development crate")]🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkgs/dev/src/lib.rs` around lines 10 - 11, Replace the top-level crate attributes that use allow with expect: change #![allow(dead_code, reason = "exports consumed by tests")] to #![expect(dead_code, reason = "exports consumed by tests")] and change #![allow(clippy::panic, reason = "development crate")] to #![expect(clippy::panic, reason = "development crate")], preserving the reason strings so the lints are asserted rather than silently suppressed.Source: Coding guidelines
pkgs/p2p_core/src/primitives/mn_list.rs (1)
208-213: 💤 Low valueConsider removing
rstestfor non-parameterized tests.The test uses
#[rstest]but has no parameters or test cases. The standard#[test]attribute would be more idiomatic for simple tests.✨ Simplify test attribute
- #[rstest] - fn corpus_mnlistdiff() { + #[test] + fn test_corpus_mnlistdiff() {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkgs/p2p_core/src/primitives/mn_list.rs` around lines 208 - 213, The test function corpus_mnlistdiff is annotated with #[rstest] despite having no parameters; change the attribute to the standard #[test] to be idiomatic and avoid pulling in the rstest harness. Locate the corpus_mnlistdiff function and replace the #[rstest] attribute with #[test], leaving the body (load_corpus_file, read_corpus::<MnListDiffPayload>, assert_serde_rt) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkgs/dev/Cargo.toml`:
- Around line 8-10: The Cargo.toml features section is missing the required
"full" feature; update the [features] block to include full = ["std"] so it
follows the workspace standard (keep default = [] and std = [] as-is). Locate
the features declaration in the pkgs/dev crate (the [features] table and keys
default, std) and add the full feature entry referencing "std" (full = ["std"]).
---
Nitpick comments:
In `@pkgs/dev/src/lib.rs`:
- Around line 10-11: Replace the top-level crate attributes that use allow with
expect: change #![allow(dead_code, reason = "exports consumed by tests")] to
#![expect(dead_code, reason = "exports consumed by tests")] and change
#![allow(clippy::panic, reason = "development crate")] to
#![expect(clippy::panic, reason = "development crate")], preserving the reason
strings so the lints are asserted rather than silently suppressed.
In `@pkgs/p2p_core/src/primitives/mn_list.rs`:
- Around line 208-213: The test function corpus_mnlistdiff is annotated with
#[rstest] despite having no parameters; change the attribute to the standard
#[test] to be idiomatic and avoid pulling in the rstest harness. Locate the
corpus_mnlistdiff function and replace the #[rstest] attribute with #[test],
leaving the body (load_corpus_file, read_corpus::<MnListDiffPayload>,
assert_serde_rt) unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d7bfb864-36b3-44fc-802a-2a3dd7b23f37
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (72)
Cargo.tomlpkgs/dev/Cargo.tomlpkgs/dev/src/corpus.rspkgs/dev/src/lambda.rspkgs/dev/src/lib.rspkgs/dev/src/prelude.rspkgs/p2p_core/Cargo.tomlpkgs/p2p_core/corpus/headers2.json5pkgs/p2p_core/corpus/inv.json5pkgs/p2p_core/corpus/mnlistdiff.json5pkgs/p2p_core/corpus/ping.json5pkgs/p2p_core/corpus/version.json5pkgs/p2p_core/src/msg/headers2.rspkgs/p2p_core/src/msg/inv.rspkgs/p2p_core/src/msg/ping.rspkgs/p2p_core/src/msg/version.rspkgs/p2p_core/src/primitives/inventory.rspkgs/p2p_core/src/primitives/mn_list.rspkgs/p2p_core/src/primitives/user_agent.rspkgs/p2p_core/tests/mnlistdiff.rspkgs/primitives/Cargo.tomlpkgs/primitives/corpus/assetlock.json5pkgs/primitives/corpus/blocks.json5pkgs/primitives/corpus/cbtx.json5pkgs/primitives/corpus/coinbase.json5pkgs/primitives/corpus/data.json5pkgs/primitives/corpus/govobj.json5pkgs/primitives/corpus/govobjvote.json5pkgs/primitives/corpus/mnhftx.json5pkgs/primitives/corpus/proposals.json5pkgs/primitives/corpus/proregtx.json5pkgs/primitives/corpus/proupregtx.json5pkgs/primitives/corpus/prouprevtx.json5pkgs/primitives/corpus/proupservtx.json5pkgs/primitives/corpus/qctx.json5pkgs/primitives/corpus/spend.json5pkgs/primitives/corpus/triggers.json5pkgs/primitives/src/block.rspkgs/primitives/src/block_header.rspkgs/primitives/src/gov.rspkgs/primitives/src/outpoint.rspkgs/primitives/src/payload/assetlock.rspkgs/primitives/src/payload/assetunlock.rspkgs/primitives/src/payload/cbtx.rspkgs/primitives/src/payload/mnhftx.rspkgs/primitives/src/payload/proregtx.rspkgs/primitives/src/payload/proupregtx.rspkgs/primitives/src/payload/prouprevtx.rspkgs/primitives/src/payload/proupservtx.rspkgs/primitives/src/payload/quorum.rspkgs/primitives/src/support.rspkgs/primitives/src/transaction.rspkgs/primitives/src/tx_in.rspkgs/primitives/src/tx_out.rspkgs/primitives/tests/assetlock.rspkgs/primitives/tests/assetunlock.rspkgs/primitives/tests/blocks.rspkgs/primitives/tests/cbtx.rspkgs/primitives/tests/coinbase.rspkgs/primitives/tests/data.rspkgs/primitives/tests/mnhftx.rspkgs/primitives/tests/proposals.rspkgs/primitives/tests/proregtx.rspkgs/primitives/tests/proupregtx.rspkgs/primitives/tests/prouprevtx.rspkgs/primitives/tests/proupservtx.rspkgs/primitives/tests/qctx.rspkgs/primitives/tests/spend.rspkgs/primitives/tests/triggers.rspkgs/primitives/tests/util/mod.rspkgs/types/src/lib.rspkgs/types/src/serialize.rs
💤 Files with no reviewable changes (17)
- pkgs/primitives/tests/proupservtx.rs
- pkgs/primitives/tests/mnhftx.rs
- pkgs/primitives/tests/assetlock.rs
- pkgs/primitives/tests/proupregtx.rs
- pkgs/primitives/tests/assetunlock.rs
- pkgs/primitives/tests/proregtx.rs
- pkgs/p2p_core/tests/mnlistdiff.rs
- pkgs/primitives/tests/triggers.rs
- pkgs/primitives/tests/prouprevtx.rs
- pkgs/primitives/tests/cbtx.rs
- pkgs/primitives/tests/data.rs
- pkgs/primitives/tests/coinbase.rs
- pkgs/primitives/tests/util/mod.rs
- pkgs/primitives/tests/blocks.rs
- pkgs/primitives/tests/proposals.rs
- pkgs/primitives/tests/qctx.rs
- pkgs/primitives/tests/spend.rs
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkgs/dev/src/corpus.rs (1)
11-16: ⚡ Quick winConsolidate external imports into one section.
The guideline specifies "internal imports, blank line, external imports, blank line, code" with one external imports section. Currently, there's a blank line separating external crate imports from
coreimports. Consider removing the blank line at line 14 so all external imports form one contiguous block per the guideline.♻️ Consolidate imports
use hex_conservative::FromHex; use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; - use core::fmt::Debug;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkgs/dev/src/corpus.rs` around lines 11 - 16, The external imports are split by an extra blank line before core::fmt::Debug; remove the blank line so all external imports are contiguous. In pkgs/dev/src/corpus.rs consolidate the import block by placing use core::fmt::Debug alongside use hex_conservative::FromHex, use serde::de::DeserializeOwned, and use serde::{Deserialize, Serialize} (i.e., one external imports section with no intervening blank line).Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pkgs/dev/src/corpus.rs`:
- Around line 11-16: The external imports are split by an extra blank line
before core::fmt::Debug; remove the blank line so all external imports are
contiguous. In pkgs/dev/src/corpus.rs consolidate the import block by placing
use core::fmt::Debug alongside use hex_conservative::FromHex, use
serde::de::DeserializeOwned, and use serde::{Deserialize, Serialize} (i.e., one
external imports section with no intervening blank line).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8b94efce-42e4-455a-9188-6e28a68f89c3
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (44)
Cargo.tomlpkgs/dev/Cargo.tomlpkgs/dev/src/corpus.rspkgs/dev/src/lambda.rspkgs/dev/src/lib.rspkgs/dev/src/prelude.rspkgs/p2p_core/Cargo.tomlpkgs/p2p_core/src/msg/headers2.rspkgs/p2p_core/src/msg/inv.rspkgs/p2p_core/src/msg/ping.rspkgs/p2p_core/src/msg/version.rspkgs/p2p_core/src/primitives/mn_list.rspkgs/p2p_core/tests/mnlistdiff.rspkgs/primitives/Cargo.tomlpkgs/primitives/corpus/govobj.json5pkgs/primitives/corpus/govobjvote.json5pkgs/primitives/src/block.rspkgs/primitives/src/gov.rspkgs/primitives/src/payload/assetlock.rspkgs/primitives/src/payload/assetunlock.rspkgs/primitives/src/payload/cbtx.rspkgs/primitives/src/payload/mnhftx.rspkgs/primitives/src/payload/proregtx.rspkgs/primitives/src/payload/proupregtx.rspkgs/primitives/src/payload/prouprevtx.rspkgs/primitives/src/payload/proupservtx.rspkgs/primitives/src/payload/quorum.rspkgs/primitives/src/transaction.rspkgs/primitives/tests/assetlock.rspkgs/primitives/tests/assetunlock.rspkgs/primitives/tests/blocks.rspkgs/primitives/tests/cbtx.rspkgs/primitives/tests/coinbase.rspkgs/primitives/tests/data.rspkgs/primitives/tests/mnhftx.rspkgs/primitives/tests/proposals.rspkgs/primitives/tests/proregtx.rspkgs/primitives/tests/proupregtx.rspkgs/primitives/tests/prouprevtx.rspkgs/primitives/tests/proupservtx.rspkgs/primitives/tests/qctx.rspkgs/primitives/tests/spend.rspkgs/primitives/tests/triggers.rspkgs/primitives/tests/util/mod.rs
💤 Files with no reviewable changes (17)
- pkgs/primitives/tests/mnhftx.rs
- pkgs/primitives/tests/coinbase.rs
- pkgs/primitives/tests/assetlock.rs
- pkgs/primitives/tests/cbtx.rs
- pkgs/primitives/tests/spend.rs
- pkgs/primitives/tests/data.rs
- pkgs/primitives/tests/proupservtx.rs
- pkgs/primitives/tests/blocks.rs
- pkgs/primitives/tests/triggers.rs
- pkgs/p2p_core/tests/mnlistdiff.rs
- pkgs/primitives/tests/proupregtx.rs
- pkgs/primitives/tests/assetunlock.rs
- pkgs/primitives/tests/proposals.rs
- pkgs/primitives/tests/proregtx.rs
- pkgs/primitives/tests/util/mod.rs
- pkgs/primitives/tests/qctx.rs
- pkgs/primitives/tests/prouprevtx.rs
✅ Files skipped from review due to trivial changes (5)
- Cargo.toml
- pkgs/primitives/Cargo.toml
- pkgs/primitives/corpus/govobjvote.json5
- pkgs/p2p_core/Cargo.toml
- pkgs/primitives/corpus/govobj.json5
🚧 Files skipped from review as they are similar to previous changes (20)
- pkgs/primitives/src/payload/assetunlock.rs
- pkgs/primitives/src/payload/assetlock.rs
- pkgs/primitives/src/payload/prouprevtx.rs
- pkgs/dev/src/lib.rs
- pkgs/dev/src/prelude.rs
- pkgs/primitives/src/transaction.rs
- pkgs/p2p_core/src/msg/headers2.rs
- pkgs/primitives/src/block.rs
- pkgs/dev/Cargo.toml
- pkgs/primitives/src/payload/proupregtx.rs
- pkgs/p2p_core/src/msg/ping.rs
- pkgs/primitives/src/payload/cbtx.rs
- pkgs/primitives/src/payload/mnhftx.rs
- pkgs/dev/src/lambda.rs
- pkgs/primitives/src/payload/proupservtx.rs
- pkgs/p2p_core/src/msg/version.rs
- pkgs/primitives/src/payload/proregtx.rs
- pkgs/p2p_core/src/primitives/mn_list.rs
- pkgs/primitives/src/payload/quorum.rs
- pkgs/primitives/src/gov.rs
Additional Information
Depends on sdk%feat(codec): add
Checkabletrait, move inherentvalidate()functions to it, dropDeploymentContext, trim down checks to be stateless #7The corpus
.json5files are restructured so that eachdetailsobject matches the Rust struct shape, allowingserdeto deserialize them without manual field extraction. Best-effort compatibility is made with Dash Core's RPC outputs to ensure the JSON representations are directly diff-able against the reference implementation.UserAgentswitches from a derivedSerialize/Deserializeto a custom string-based impl because the derive would expose the innerVec<u8>as an array of integers rather than the human-readable string expected.Breaking Changes
None expected.
How Has This Been Tested?
Checklist