|
6 | 6 | #include <compressor.h> |
7 | 7 | #include <core_io.h> |
8 | 8 | #include <core_memusage.h> |
| 9 | +#include <key_io.h> |
9 | 10 | #include <policy/policy.h> |
10 | 11 | #include <pubkey.h> |
| 12 | +#include <rpc/util.h> |
11 | 13 | #include <script/descriptor.h> |
12 | 14 | #include <script/interpreter.h> |
13 | 15 | #include <script/script.h> |
@@ -184,26 +186,26 @@ FUZZ_TARGET_INIT(script, initialize_script) |
184 | 186 | } |
185 | 187 |
|
186 | 188 | { |
187 | | - WitnessUnknown witness_unknown_1{}; |
188 | | - witness_unknown_1.version = fuzzed_data_provider.ConsumeIntegral<uint32_t>(); |
189 | | - const std::vector<uint8_t> witness_unknown_program_1 = fuzzed_data_provider.ConsumeBytes<uint8_t>(40); |
190 | | - witness_unknown_1.length = witness_unknown_program_1.size(); |
191 | | - std::copy(witness_unknown_program_1.begin(), witness_unknown_program_1.end(), witness_unknown_1.program); |
192 | | - |
193 | | - WitnessUnknown witness_unknown_2{}; |
194 | | - witness_unknown_2.version = fuzzed_data_provider.ConsumeIntegral<uint32_t>(); |
195 | | - const std::vector<uint8_t> witness_unknown_program_2 = fuzzed_data_provider.ConsumeBytes<uint8_t>(40); |
196 | | - witness_unknown_2.length = witness_unknown_program_2.size(); |
197 | | - std::copy(witness_unknown_program_2.begin(), witness_unknown_program_2.end(), witness_unknown_2.program); |
198 | | - |
199 | | - (void)(witness_unknown_1 == witness_unknown_2); |
200 | | - (void)(witness_unknown_1 < witness_unknown_2); |
201 | | - } |
| 189 | + const CTxDestination tx_destination_1{ |
| 190 | + fuzzed_data_provider.ConsumeBool() ? |
| 191 | + DecodeDestination(fuzzed_data_provider.ConsumeRandomLengthString()) : |
| 192 | + ConsumeTxDestination(fuzzed_data_provider)}; |
| 193 | + const CTxDestination tx_destination_2{ConsumeTxDestination(fuzzed_data_provider)}; |
| 194 | + const std::string encoded_dest{EncodeDestination(tx_destination_1)}; |
| 195 | + const UniValue json_dest{DescribeAddress(tx_destination_1)}; |
| 196 | + Assert(tx_destination_1 == DecodeDestination(encoded_dest)); |
| 197 | + (void)GetKeyForDestination(/* store */ {}, tx_destination_1); |
| 198 | + const CScript dest{GetScriptForDestination(tx_destination_1)}; |
| 199 | + const bool valid{IsValidDestination(tx_destination_1)}; |
| 200 | + Assert(dest.empty() != valid); |
| 201 | + |
| 202 | + Assert(valid == IsValidDestinationString(encoded_dest)); |
202 | 203 |
|
203 | | - { |
204 | | - const CTxDestination tx_destination_1 = ConsumeTxDestination(fuzzed_data_provider); |
205 | | - const CTxDestination tx_destination_2 = ConsumeTxDestination(fuzzed_data_provider); |
206 | | - (void)(tx_destination_1 == tx_destination_2); |
207 | 204 | (void)(tx_destination_1 < tx_destination_2); |
| 205 | + if (tx_destination_1 == tx_destination_2) { |
| 206 | + Assert(encoded_dest == EncodeDestination(tx_destination_2)); |
| 207 | + Assert(json_dest.write() == DescribeAddress(tx_destination_2).write()); |
| 208 | + Assert(dest == GetScriptForDestination(tx_destination_2)); |
| 209 | + } |
208 | 210 | } |
209 | 211 | } |
0 commit comments