diff options
author | merge-script <fanquake@gmail.com> | 2024-06-03 14:01:47 +0100 |
---|---|---|
committer | merge-script <fanquake@gmail.com> | 2024-06-03 14:01:47 +0100 |
commit | c065ae84695de811716cb4fc89357346d7decc8f (patch) | |
tree | 8e843e3ea839c28eab793903f5a67f25a0217114 /src/wallet | |
parent | e40df5468d1187a608f3821a23f37939e24804a1 (diff) | |
parent | e3249f21111f1dd4beb66f10af933c34a36c30ac (diff) |
Merge bitcoin/bitcoin#30134: fuzz: add more coverage for `ScriptPubKeyMan`
e3249f21111f1dd4beb66f10af933c34a36c30ac fuzz: add more coverage for `ScriptPubKeyMan` (brunoerg)
Pull request description:
This PR adds more coverage for `ScriptPubKeyMan`:
- Check `GetKey` and `HasPrivKey` after adding descriptor key.
- Cover `GetEndRange` and `GetKeyPoolSize`.
- Cover `MarkUnusedAddresses` with the scripts from ScriptPubKeys and `GetMetadata` with the destinations from them.
ACKs for top commit:
marcofleon:
Tested ACK e3249f21111f1dd4beb66f10af933c34a36c30ac. I ran the updated harness for ~9 hours on an empty corpus, generated a coverage report, and checked that the new functions mentioned were hit. Coverage of `scriptpubkeyman.cpp` increased.
murchandamus:
Tested ACK e3249f21111f1dd4beb66f10af933c34a36c30ac
Tree-SHA512: cfab91f6c8401174842e79209c0e9225c08f011fe9b41d0a58bcec716ae4545eaf803867f899ed7b5fbcefea45711f91894e36df082ba19732dd310cd9e61a79
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/test/fuzz/scriptpubkeyman.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/wallet/test/fuzz/scriptpubkeyman.cpp b/src/wallet/test/fuzz/scriptpubkeyman.cpp index 228e9629ed..835470aeae 100644 --- a/src/wallet/test/fuzz/scriptpubkeyman.cpp +++ b/src/wallet/test/fuzz/scriptpubkeyman.cpp @@ -137,6 +137,15 @@ FUZZ_TARGET(scriptpubkeyman, .init = initialize_spkm) PKHash{ConsumeUInt160(fuzzed_data_provider)}}; std::string str_sig; (void)spk_manager->SignMessage(msg, pk_hash, str_sig); + (void)spk_manager->GetMetadata(dest); + } + } + }, + [&] { + auto spks{spk_manager->GetScriptPubKeys()}; + for (const CScript& spk : spks) { + if (fuzzed_data_provider.ConsumeBool()) { + spk_manager->MarkUnusedAddresses(spk); } } }, @@ -148,6 +157,10 @@ FUZZ_TARGET(scriptpubkeyman, .init = initialize_spkm) } spk_manager->AddDescriptorKey(key, key.GetPubKey()); spk_manager->TopUp(); + LOCK(spk_manager->cs_desc_man); + auto particular_key{spk_manager->GetKey(key.GetPubKey().GetID())}; + assert(*particular_key == key); + assert(spk_manager->HasPrivKey(key.GetPubKey().GetID())); }, [&] { std::string descriptor; @@ -194,6 +207,9 @@ FUZZ_TARGET(scriptpubkeyman, .init = initialize_spkm) } ); } + + (void)spk_manager->GetEndRange(); + (void)spk_manager->GetKeyPoolSize(); } } // namespace |