mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-15 11:36:00 -05:00
fuzz: Move ConsumeTxDestination to cpp file
Moving the implementation out of the header will reduce compile time
This commit is contained in:
parent
7a49fdc581
commit
fa40c0964b
2 changed files with 32 additions and 30 deletions
|
@ -304,3 +304,34 @@ uint32_t ConsumeSequence(FuzzedDataProvider& fuzzed_data_provider) noexcept
|
||||||
}) :
|
}) :
|
||||||
fuzzed_data_provider.ConsumeIntegral<uint32_t>();
|
fuzzed_data_provider.ConsumeIntegral<uint32_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CTxDestination ConsumeTxDestination(FuzzedDataProvider& fuzzed_data_provider) noexcept
|
||||||
|
{
|
||||||
|
CTxDestination tx_destination;
|
||||||
|
CallOneOf(
|
||||||
|
fuzzed_data_provider,
|
||||||
|
[&] {
|
||||||
|
tx_destination = CNoDestination{};
|
||||||
|
},
|
||||||
|
[&] {
|
||||||
|
tx_destination = PKHash{ConsumeUInt160(fuzzed_data_provider)};
|
||||||
|
},
|
||||||
|
[&] {
|
||||||
|
tx_destination = ScriptHash{ConsumeUInt160(fuzzed_data_provider)};
|
||||||
|
},
|
||||||
|
[&] {
|
||||||
|
tx_destination = WitnessV0ScriptHash{ConsumeUInt256(fuzzed_data_provider)};
|
||||||
|
},
|
||||||
|
[&] {
|
||||||
|
tx_destination = WitnessV0KeyHash{ConsumeUInt160(fuzzed_data_provider)};
|
||||||
|
},
|
||||||
|
[&] {
|
||||||
|
WitnessUnknown witness_unknown{};
|
||||||
|
witness_unknown.version = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
|
||||||
|
const std::vector<uint8_t> witness_unknown_program_1 = fuzzed_data_provider.ConsumeBytes<uint8_t>(40);
|
||||||
|
witness_unknown.length = witness_unknown_program_1.size();
|
||||||
|
std::copy(witness_unknown_program_1.begin(), witness_unknown_program_1.end(), witness_unknown.program);
|
||||||
|
tx_destination = witness_unknown;
|
||||||
|
});
|
||||||
|
return tx_destination;
|
||||||
|
}
|
||||||
|
|
|
@ -178,36 +178,7 @@ template <typename WeakEnumType, size_t size>
|
||||||
return CTxMemPoolEntry{MakeTransactionRef(tx), fee, time, entry_height, spends_coinbase, sig_op_cost, {}};
|
return CTxMemPoolEntry{MakeTransactionRef(tx), fee, time, entry_height, spends_coinbase, sig_op_cost, {}};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] inline CTxDestination ConsumeTxDestination(FuzzedDataProvider& fuzzed_data_provider) noexcept
|
[[nodiscard]] CTxDestination ConsumeTxDestination(FuzzedDataProvider& fuzzed_data_provider) noexcept;
|
||||||
{
|
|
||||||
CTxDestination tx_destination;
|
|
||||||
CallOneOf(
|
|
||||||
fuzzed_data_provider,
|
|
||||||
[&] {
|
|
||||||
tx_destination = CNoDestination{};
|
|
||||||
},
|
|
||||||
[&] {
|
|
||||||
tx_destination = PKHash{ConsumeUInt160(fuzzed_data_provider)};
|
|
||||||
},
|
|
||||||
[&] {
|
|
||||||
tx_destination = ScriptHash{ConsumeUInt160(fuzzed_data_provider)};
|
|
||||||
},
|
|
||||||
[&] {
|
|
||||||
tx_destination = WitnessV0ScriptHash{ConsumeUInt256(fuzzed_data_provider)};
|
|
||||||
},
|
|
||||||
[&] {
|
|
||||||
tx_destination = WitnessV0KeyHash{ConsumeUInt160(fuzzed_data_provider)};
|
|
||||||
},
|
|
||||||
[&] {
|
|
||||||
WitnessUnknown witness_unknown{};
|
|
||||||
witness_unknown.version = fuzzed_data_provider.ConsumeIntegral<uint32_t>();
|
|
||||||
const std::vector<uint8_t> witness_unknown_program_1 = fuzzed_data_provider.ConsumeBytes<uint8_t>(40);
|
|
||||||
witness_unknown.length = witness_unknown_program_1.size();
|
|
||||||
std::copy(witness_unknown_program_1.begin(), witness_unknown_program_1.end(), witness_unknown.program);
|
|
||||||
tx_destination = witness_unknown;
|
|
||||||
});
|
|
||||||
return tx_destination;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
[[nodiscard]] bool MultiplicationOverflow(const T i, const T j) noexcept
|
[[nodiscard]] bool MultiplicationOverflow(const T i, const T j) noexcept
|
||||||
|
|
Loading…
Add table
Reference in a new issue