Skip to content

Commit fa40c09

Browse files
author
MarcoFalke
committed
fuzz: Move ConsumeTxDestination to cpp file
Moving the implementation out of the header will reduce compile time
1 parent 7a49fdc commit fa40c09

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

src/test/fuzz/util.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,34 @@ uint32_t ConsumeSequence(FuzzedDataProvider& fuzzed_data_provider) noexcept
304304
}) :
305305
fuzzed_data_provider.ConsumeIntegral<uint32_t>();
306306
}
307+
308+
CTxDestination ConsumeTxDestination(FuzzedDataProvider& fuzzed_data_provider) noexcept
309+
{
310+
CTxDestination tx_destination;
311+
CallOneOf(
312+
fuzzed_data_provider,
313+
[&] {
314+
tx_destination = CNoDestination{};
315+
},
316+
[&] {
317+
tx_destination = PKHash{ConsumeUInt160(fuzzed_data_provider)};
318+
},
319+
[&] {
320+
tx_destination = ScriptHash{ConsumeUInt160(fuzzed_data_provider)};
321+
},
322+
[&] {
323+
tx_destination = WitnessV0ScriptHash{ConsumeUInt256(fuzzed_data_provider)};
324+
},
325+
[&] {
326+
tx_destination = WitnessV0KeyHash{ConsumeUInt160(fuzzed_data_provider)};
327+
},
328+
[&] {
329+
WitnessUnknown witness_unknown{};
330+
witness_unknown.version = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
331+
const std::vector<uint8_t> witness_unknown_program_1 = fuzzed_data_provider.ConsumeBytes<uint8_t>(40);
332+
witness_unknown.length = witness_unknown_program_1.size();
333+
std::copy(witness_unknown_program_1.begin(), witness_unknown_program_1.end(), witness_unknown.program);
334+
tx_destination = witness_unknown;
335+
});
336+
return tx_destination;
337+
}

src/test/fuzz/util.h

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -178,36 +178,7 @@ template <typename WeakEnumType, size_t size>
178178
return CTxMemPoolEntry{MakeTransactionRef(tx), fee, time, entry_height, spends_coinbase, sig_op_cost, {}};
179179
}
180180

181-
[[nodiscard]] inline CTxDestination ConsumeTxDestination(FuzzedDataProvider& fuzzed_data_provider) noexcept
182-
{
183-
CTxDestination tx_destination;
184-
CallOneOf(
185-
fuzzed_data_provider,
186-
[&] {
187-
tx_destination = CNoDestination{};
188-
},
189-
[&] {
190-
tx_destination = PKHash{ConsumeUInt160(fuzzed_data_provider)};
191-
},
192-
[&] {
193-
tx_destination = ScriptHash{ConsumeUInt160(fuzzed_data_provider)};
194-
},
195-
[&] {
196-
tx_destination = WitnessV0ScriptHash{ConsumeUInt256(fuzzed_data_provider)};
197-
},
198-
[&] {
199-
tx_destination = WitnessV0KeyHash{ConsumeUInt160(fuzzed_data_provider)};
200-
},
201-
[&] {
202-
WitnessUnknown witness_unknown{};
203-
witness_unknown.version = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
204-
const std::vector<uint8_t> witness_unknown_program_1 = fuzzed_data_provider.ConsumeBytes<uint8_t>(40);
205-
witness_unknown.length = witness_unknown_program_1.size();
206-
std::copy(witness_unknown_program_1.begin(), witness_unknown_program_1.end(), witness_unknown.program);
207-
tx_destination = witness_unknown;
208-
});
209-
return tx_destination;
210-
}
181+
[[nodiscard]] CTxDestination ConsumeTxDestination(FuzzedDataProvider& fuzzed_data_provider) noexcept;
211182

212183
template <typename T>
213184
[[nodiscard]] bool MultiplicationOverflow(const T i, const T j) noexcept

0 commit comments

Comments
 (0)