-
Notifications
You must be signed in to change notification settings - Fork 9
refactor: consolidate UTXO helpers in test_utils.rs
#334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v0.42-dev
Are you sure you want to change the base?
Conversation
test_utils.rstest_utils.rs
📝 WalkthroughWalkthroughThis pull request consolidates test utilities across the key-wallet crate by creating a shared Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
key-wallet/src/wallet/managed_wallet_info/transaction_building.rs (1)
180-409: Consolidate localtest_utxohelper intest_optimal_consolidation.rsto centralized utilities.The migration is incomplete.
key-wallet/tests/test_optimal_consolidation.rscontains a localtest_utxo(value: u64, confirmed: bool)helper that duplicates centralized functionality already available viatest_utxo_full(value, height, vout, confirmed)intest_utils.rs. Replace the local helper with calls totest_utxo_full(value, 100, 0, confirmed)or add a convenience wrapperpub fn test_utxo_with_confirmed(value: u64, confirmed: bool)to the centralized utilities.key-wallet/src/tests/test_utils.rs (1)
25-37: Consider adding doc comments and validating ScriptBuf usage.Two optional improvements to enhance test utility quality:
Missing doc comments: Adding documentation for the public functions would help users understand the purpose and parameters (especially the
confirmedparameter's behavior).Empty ScriptBuf on Line 32: The
TxOutis created with an emptyScriptBuf, which may not be realistic for tests that validate script execution or UTXO spending logic. Consider whether tests might benefit from a proper script corresponding to the address (e.g., usingaddress.script_pubkey()).Example: Adding doc comment and proper script
+/// Creates a test UTXO with full control over parameters. +/// +/// # Arguments +/// * `value` - Amount in satoshis +/// * `height` - Block height +/// * `vout` - Transaction output index +/// * `confirmed` - Whether the UTXO is confirmed pub fn test_utxo_full(value: u64, height: u32, vout: u32, confirmed: bool) -> Utxo { let outpoint = OutPoint { txid: Txid::from_raw_hash(sha256d::Hash::from_slice(&[1u8; 32]).unwrap()), vout, }; + let address = test_address(); let txout = TxOut { value, - script_pubkey: ScriptBuf::new(), + script_pubkey: address.script_pubkey(), }; - let mut utxo = Utxo::new(outpoint, txout, test_address(), height, false); + let mut utxo = Utxo::new(outpoint, txout, address, height, false); utxo.is_confirmed = confirmed; utxo }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
key-wallet/src/tests/mod.rskey-wallet/src/tests/test_utils.rskey-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rs
🧰 Additional context used
📓 Path-based instructions (5)
key-wallet/**/*.rs
📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)
key-wallet/**/*.rs: Separate immutable structures (Account,Wallet) containing only identity information from mutable wrappers (ManagedAccount,ManagedWalletInfo) with state management
Never serialize or log private keys in production; use public keys or key fingerprints for identification instead
Always validate network consistency when deriving or validating addresses; never mix mainnet and testnet operations
UseBTreeMapfor ordered data (accounts, transactions) andHashMapfor lookups (address mappings); apply memory management strategies for old transaction data
Apply atomic state updates when managing watch-only wallets: validate that external signatures match expected pubkeys and never attempt signing operations
Use the?operator for error propagation, provide context in error messages, never panic in library code, and returnResult<T>for all fallible operations
Files:
key-wallet/src/tests/mod.rskey-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/tests/test_utils.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
key-wallet/**/tests/**/*.rs
📄 CodeRabbit inference engine (key-wallet/CLAUDE.md)
key-wallet/**/tests/**/*.rs: Organize unit tests by functionality: separate test files for BIP32, mnemonics, addresses, derivation paths, and PSBT operations
Use deterministic testing with known test vectors and fixed seeds for reproducible results
Use property-based testing for complex invariants such as gap limit constraints
Files:
key-wallet/src/tests/mod.rskey-wallet/src/tests/test_utils.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 thetests/directory
Usesnake_casefor function and variable names
UseUpperCamelCasefor types and traits
UseSCREAMING_SNAKE_CASEfor constants
Format code withrustfmtbefore commits; ensurecargo fmt --allis run
Runcargo clippy --workspace --all-targets -- -D warningsfor linting; avoid warnings in CI
Preferasync/awaitviatokiofor 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:
key-wallet/src/tests/mod.rskey-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/tests/test_utils.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
**/tests/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/tests/**/*.rs: Use descriptive test names (e.g.,test_parse_address_mainnet)
Mark network-dependent or long-running tests with#[ignore]and run with-- --ignored
Files:
key-wallet/src/tests/mod.rskey-wallet/src/tests/test_utils.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:
key-wallet/src/tests/test_utils.rs
🧠 Learnings (25)
📓 Common learnings
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/tests/**/*.rs : Organize unit tests by functionality: separate test files for BIP32, mnemonics, addresses, derivation paths, and PSBT operations
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
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/managed_account/**/*.rs : Implement atomic state updates when processing transactions: update transactions, UTXOs, balances, and address usage state together
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/address_pool/**/*.rs : Support multiple `KeySource` variants (Private, Public, NoKeySource) to enable both full wallets and watch-only wallets with the same interface
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/tests/**/*.rs : Use deterministic testing with known test vectors and fixed seeds for reproducible results
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Separate immutable structures (`Account`, `Wallet`) containing only identity information from mutable wrappers (`ManagedAccount`, `ManagedWalletInfo`) with state management
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/address_pool/**/*.rs : Pre-generate addresses in batches (typically 20-100) and store them in pools; only derive on-demand when the pool is exhausted
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Always validate network consistency when deriving or validating addresses; never mix mainnet and testnet operations
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/tests/**/*.rs : Use property-based testing for complex invariants such as gap limit constraints
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/tests/**/*.rs : Organize unit tests by functionality: separate test files for BIP32, mnemonics, addresses, derivation paths, and PSBT operations
Applied to files:
key-wallet/src/tests/mod.rskey-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/tests/test_utils.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/address_pool/**/*.rs : Support multiple `KeySource` variants (Private, Public, NoKeySource) to enable both full wallets and watch-only wallets with the same interface
Applied to files:
key-wallet/src/tests/mod.rskey-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/tests/test_utils.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Separate immutable structures (`Account`, `Wallet`) containing only identity information from mutable wrappers (`ManagedAccount`, `ManagedWalletInfo`) with state management
Applied to files:
key-wallet/src/tests/mod.rskey-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/tests/test_utils.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/tests/**/*.rs : Use deterministic testing with known test vectors and fixed seeds for reproducible results
Applied to files:
key-wallet/src/tests/mod.rskey-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/tests/test_utils.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
📚 Learning: 2025-12-30T22:00:57.000Z
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
Applied to files:
key-wallet/src/tests/mod.rs
📚 Learning: 2025-12-22T17:59:51.097Z
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 : Use descriptive test names (e.g., `test_parse_address_mainnet`)
Applied to files:
key-wallet/src/tests/mod.rskey-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/tests/test_utils.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.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 : 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:
key-wallet/src/tests/mod.rskey-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/tests/test_utils.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
📚 Learning: 2025-12-30T22:00:57.000Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-30T22:00:57.000Z
Learning: Applies to **/*integration*.rs : Write integration tests for network operations
Applied to files:
key-wallet/src/tests/mod.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.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:
key-wallet/src/tests/mod.rskey-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/tests/test_utils.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
📚 Learning: 2025-12-22T17:59:51.097Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-22T17:59:51.097Z
Learning: Applies to **/*.rs : Unit tests should live alongside code with `#[cfg(test)]` annotation; integration tests use the `tests/` directory
Applied to files:
key-wallet/src/tests/mod.rs
📚 Learning: 2025-12-30T22:00:57.000Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-30T22:00:57.000Z
Learning: Applies to **/*test*.rs : Test both mainnet and testnet configurations
Applied to files:
key-wallet/src/tests/mod.rskey-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/address_pool/**/*.rs : Pre-generate addresses in batches (typically 20-100) and store them in pools; only derive on-demand when the pool is exhausted
Applied to files:
key-wallet/src/tests/mod.rskey-wallet/src/tests/test_utils.rs
📚 Learning: 2025-12-22T17:59:51.097Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-22T17:59:51.097Z
Learning: FFI bindings are organized in `*-ffi` crates; shared helpers in `internals/` and `test-utils/`
Applied to files:
key-wallet/src/tests/mod.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/managed_account/**/*.rs : Implement atomic state updates when processing transactions: update transactions, UTXOs, balances, and address usage state together
Applied to files:
key-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Apply atomic state updates when managing watch-only wallets: validate that external signatures match expected pubkeys and never attempt signing operations
Applied to files:
key-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
📚 Learning: 2025-12-22T17:59:51.097Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-22T17:59:51.097Z
Learning: Cover critical parsing, networking, SPV, and wallet flows in tests; add regression tests for fixes; consider property tests with `proptest`
Applied to files:
key-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/tests/test_utils.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Always validate network consistency when deriving or validating addresses; never mix mainnet and testnet operations
Applied to files:
key-wallet/src/utxo.rskey-wallet/src/tests/test_utils.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.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:
key-wallet/src/utxo.rskey-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
📚 Learning: 2025-06-26T16:01:37.609Z
Learnt from: DCG-Claude
Repo: dashpay/rust-dashcore PR: 0
File: :0-0
Timestamp: 2025-06-26T16:01:37.609Z
Learning: The mempool tracking infrastructure (UnconfirmedTransaction, MempoolState, configuration, and mempool_filter.rs) is fully implemented and integrated in the Dash SPV client as of this PR, including client logic, FFI APIs, and tests.
Applied to files:
key-wallet/src/utxo.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/*.rs : Use `BTreeMap` for ordered data (accounts, transactions) and `HashMap` for lookups (address mappings); apply memory management strategies for old transaction data
Applied to files:
key-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/transaction_checking/**/*.rs : Implement transaction classification and routing through `TransactionRouter` to avoid checking all accounts for every transaction
Applied to files:
key-wallet/src/wallet/managed_wallet_info/transaction_building.rskey-wallet/src/wallet/managed_wallet_info/transaction_builder.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/address_pool/**/*.rs : Generate addresses in batches using gap limit and staged generation instead of unbounded address generation to prevent memory and performance issues
Applied to files:
key-wallet/src/tests/test_utils.rs
📚 Learning: 2025-12-19T00:07:22.904Z
Learnt from: CR
Repo: dashpay/rust-dashcore PR: 0
File: key-wallet/CLAUDE.md:0-0
Timestamp: 2025-12-19T00:07:22.904Z
Learning: Applies to key-wallet/**/tests/**/*.rs : Use property-based testing for complex invariants such as gap limit constraints
Applied to files:
key-wallet/src/tests/test_utils.rskey-wallet/src/wallet/managed_wallet_info/coin_selection.rs
📚 Learning: 2025-06-15T15:31:44.136Z
Learnt from: QuantumExplorer
Repo: dashpay/rust-dashcore PR: 74
File: key-wallet/src/address.rs:30-40
Timestamp: 2025-06-15T15:31:44.136Z
Learning: In the key-wallet crate, QuantumExplorer prefers keeping wildcard arms that default unknown Network variants to testnet prefixes rather than using exhaustive matches or panics. This fallback behavior is intentional.
Applied to files:
key-wallet/src/tests/test_utils.rs
🧬 Code graph analysis (5)
key-wallet/src/utxo.rs (1)
key-wallet/src/tests/test_utils.rs (1)
test_utxo_full(25-37)
key-wallet/src/wallet/managed_wallet_info/transaction_building.rs (1)
key-wallet/tests/test_optimal_consolidation.rs (1)
test_utxo(11-35)
key-wallet/src/tests/test_utils.rs (1)
key-wallet/src/utxo.rs (3)
value(61-63)new(41-58)new(130-138)
key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs (2)
key-wallet/src/tests/test_utils.rs (2)
test_address(17-19)test_utxo(21-23)key-wallet/tests/test_optimal_consolidation.rs (1)
test_utxo(11-35)
key-wallet/src/wallet/managed_wallet_info/coin_selection.rs (2)
key-wallet/src/tests/test_utils.rs (1)
test_utxo(21-23)key-wallet/tests/test_optimal_consolidation.rs (1)
test_utxo(11-35)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
- GitHub Check: fuzz (hashes_ripemd160)
- GitHub Check: fuzz (hashes_sha1)
- GitHub Check: fuzz (hashes_sha512_256)
- GitHub Check: fuzz (dash_deserialize_address)
- GitHub Check: fuzz (hashes_cbor)
- GitHub Check: fuzz (dash_deserialize_amount)
- GitHub Check: fuzz (dash_deserialize_witness)
- GitHub Check: fuzz (dash_deser_net_msg)
- GitHub Check: fuzz (dash_deserialize_block)
- GitHub Check: fuzz (dash_outpoint_string)
- GitHub Check: Thread Sanitizer
- GitHub Check: Address Sanitizer
- GitHub Check: Pre-commit (macos-latest)
- GitHub Check: Pre-commit (windows-latest)
- GitHub Check: Pre-commit (ubuntu-latest)
🔇 Additional comments (6)
key-wallet/src/tests/mod.rs (1)
5-6: LGTM - Clean consolidation of test utilities.The public exposure of the
test_utilsmodule successfully centralizes UTXO creation helpers, eliminating duplication across test files and improving maintainability.key-wallet/src/wallet/managed_wallet_info/transaction_builder.rs (1)
838-838: LGTM - Successful migration to centralized test utilities.The import correctly references the new shared test utilities module, eliminating local test helper duplication and aligning with the PR's consolidation objective.
key-wallet/src/utxo.rs (1)
310-333: LGTM - Proper use of test_utxo_full for fine-grained control.The tests correctly use
test_utxo_fulldirectly to control specific parameters:
- Line 314: Creates an unconfirmed UTXO (confirmed=false) to test confirmation logic
- Lines 332-333: Uses different vout values (0 and 1) to ensure unique OutPoints for distinct UTXOs
This demonstrates the value of having both
test_utxo(simplified defaults) andtest_utxo_full(explicit control) available.key-wallet/src/wallet/managed_wallet_info/coin_selection.rs (1)
693-756: LGTM - Simplified test data construction.The migration to
test_utxo(value)from the centralized utilities successfully simplifies test setup by defaulting to confirmed UTXOs, which is appropriate for all coin selection tests in this file.key-wallet/src/tests/test_utils.rs (2)
1-19: LGTM! Deterministic test fixtures with consistent network usage.The use of a fixed test public key and consistent Testnet network aligns well with the learning to "Use deterministic testing with known test vectors and fixed seeds for reproducible results." This ensures test reproducibility across runs.
Based on learnings, deterministic testing with fixed seeds is the preferred approach for the key-wallet crate.
21-23: LGTM! Convenient wrapper with sensible defaults.The convenience function provides sensible defaults for the common case of a confirmed UTXO, reducing test boilerplate.
|
Before approving the PR, I would like to ask: I think it would be best to have a testutils/ in src, only available under cfg(test) and behind a feature. That way, we would have them available for integration tests, unit tests, and other crates (dash-spv). I am making this suggestion under the assumption that we would take advantage of those utils in more places. |
Can you see a place where this particular helpers could be reused other than where they are used now? Surely this would make sense if we have helpers reused in other places. Feel free to explore the repo in this regard and add an extra module to the wallet if there is a use for it. Just a sidethought, i think if you add it feature gated you dont need the cfg(test) restriction? |
Consolidate all UTXO creation helpers within
key-walletcrate in a single filetest_utils.rs.Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.