aboutsummaryrefslogtreecommitdiff
path: root/src/test/fuzz/load_external_block_file.cpp
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-07-04 18:59:49 +0200
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2023-09-15 14:33:51 +0200
commitfa389d902fbf5fac19fba8c5d0c5e0a25f15ca63 (patch)
treed34f7fbba3507483e03c6d120ab23c930c2ddbdb /src/test/fuzz/load_external_block_file.cpp
parentf608a409f7591b4f5cf170898bee58b9d9dcf1b6 (diff)
refactor: Drop unused fclose() from BufferedFile
This was only explicitly used in the tests, where it can be replaced by wrapping the original raw file pointer into a CAutoFile on creation and then calling CAutoFile::fclose(). Also, it was used in LoadExternalBlockFile(), where it can also be replaced by the (implicit call to the) CAutoFile destructor after wrapping the original raw file pointer in a CAutoFile.
Diffstat (limited to 'src/test/fuzz/load_external_block_file.cpp')
-rw-r--r--src/test/fuzz/load_external_block_file.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/test/fuzz/load_external_block_file.cpp b/src/test/fuzz/load_external_block_file.cpp
index bdaa4ad1b8..3ca2aa711b 100644
--- a/src/test/fuzz/load_external_block_file.cpp
+++ b/src/test/fuzz/load_external_block_file.cpp
@@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chainparams.h>
+#include <clientversion.h>
#include <flatfile.h>
#include <test/fuzz/FuzzedDataProvider.h>
#include <test/fuzz/fuzz.h>
@@ -27,17 +28,17 @@ FUZZ_TARGET(load_external_block_file, .init = initialize_load_external_block_fil
{
FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
FuzzedFileProvider fuzzed_file_provider = ConsumeFile(fuzzed_data_provider);
- FILE* fuzzed_block_file = fuzzed_file_provider.open();
- if (fuzzed_block_file == nullptr) {
+ CAutoFile fuzzed_block_file{fuzzed_file_provider.open(), CLIENT_VERSION};
+ if (fuzzed_block_file.IsNull()) {
return;
}
if (fuzzed_data_provider.ConsumeBool()) {
// Corresponds to the -reindex case (track orphan blocks across files).
FlatFilePos flat_file_pos;
std::multimap<uint256, FlatFilePos> blocks_with_unknown_parent;
- g_setup->m_node.chainman->LoadExternalBlockFile(fuzzed_block_file, &flat_file_pos, &blocks_with_unknown_parent);
+ g_setup->m_node.chainman->LoadExternalBlockFile(fuzzed_block_file.Get(), &flat_file_pos, &blocks_with_unknown_parent);
} else {
// Corresponds to the -loadblock= case (orphan blocks aren't tracked across files).
- g_setup->m_node.chainman->LoadExternalBlockFile(fuzzed_block_file);
+ g_setup->m_node.chainman->LoadExternalBlockFile(fuzzed_block_file.Get());
}
}