Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #350 +/- ##
==========================================
+ Coverage 58.74% 58.83% +0.08%
==========================================
Files 25 25
Lines 4608 4618 +10
==========================================
+ Hits 2707 2717 +10
Misses 1901 1901
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
b5a675e to
d3ec317
Compare
vadim-anfv
left a comment
There was a problem hiding this comment.
Thanks for picking this up, @Jennycj.
I left one note inline on the new test. Happy to test once it is rebased.
| // as a `"wallet"` field inside each entry. | ||
| #[cfg(feature = "rpc")] | ||
| #[test] | ||
| fn test_list_wallets_entry_has_no_redundant_wallet_field() { |
There was a problem hiding this comment.
I am not sure a test for an absent field is needed at all: the field is gone from WalletConfigInner, so serde cannot emit it either way, and the type already guarantees that.
If you would rather keep the check, maybe move it into test_list_wallets_with_entries just above, which already does the same setup.
There was a problem hiding this comment.
Thanks for the review @vadim-anfv . I agree, and have removed the test.
|
|
||
| fn try_from(config: &WalletConfigInner) -> Result<Self, Self::Error> { | ||
| impl WalletConfigInner { | ||
| fn try_to_wallet_opts(&self, wallet_name: &str) -> Result<WalletOpts, Error> { |
There was a problem hiding this comment.
I'd prefer to_wallet_opts name as the method does not implement TryFrom trait and there is no infallible to_wallet_opts here
There was a problem hiding this comment.
Thanks for pointing this out. I have renamed to to_wallet_opts, and also dropped the leftover let config = self; binding.
`WalletConfigInner` duplicated its own wallet name in a `wallet` field, even though it's already the key in `WalletConfig::wallets` - this showed up as a redundant `"wallet"` entry in `wallets list` output. `TryFrom<&WalletConfigInner> for WalletOpts` relied on that field, so it's replaced with a private `to_wallet_opts(&self, wallet_name: &str)` that takes the name from the caller's map lookup instead. Old config.toml files still load fine; serde ignores the now-unknown `wallet` key. Fixes bitcoindevkit#332
d3ec317 to
bc050c7
Compare
I have now rebased on master, addressed both review comments, and squashed my commits into a single signed commit. |
Description
Removes the redundant
walletfield fromWalletConfigInner. The wallet name was being stored twice: once as the key inWalletConfig::wallets, and once inside each entry aswallet: String. Thewalletscommand's JSON/TOML output showed both.For example:
{ "my_wallet": { "wallet": "my_wallet", "network": "testnet", ... } }The
"wallet"field inside the entry is gone and the name is still available as the map key.Fixes #332
Notes to the reviewers
TryFrom<&WalletConfigInner> for WalletOptsneeded to be removed because it only receives the struct. It is now replaced with a privatetry_to_wallet_opts(&self, wallet_name: &str)that takes the name from the caller instead.Backward compatible: old config.toml files with the stray
wallet = "..."line still load (serde ignores unknown fields). This is covered bytest_load_tolerates_legacy_wallet_field.CHANGELOG updated under
[Unreleased].Checklists
All Submissions:
cargo fmtandcargo clippybefore committing