aboutsummaryrefslogtreecommitdiff
path: root/tests/fuzz/bulletproof.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-05-15 17:17:24 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-05-15 17:18:27 +0000
commit81773f55a430e75fe5c6bee355ca518f16286dd1 (patch)
treefc7ac88a76cc6a06cf5310ef2a353be92d6bb931 /tests/fuzz/bulletproof.cpp
parentMerge pull request #6510 (diff)
downloadmonero-81773f55a430e75fe5c6bee355ca518f16286dd1.tar.xz
fuzz_tests: refactor and add OSS-Fuzz compatibility
Diffstat (limited to 'tests/fuzz/bulletproof.cpp')
-rw-r--r--tests/fuzz/bulletproof.cpp39
1 files changed, 6 insertions, 33 deletions
diff --git a/tests/fuzz/bulletproof.cpp b/tests/fuzz/bulletproof.cpp
index e9a6ded7d..7e58770ca 100644
--- a/tests/fuzz/bulletproof.cpp
+++ b/tests/fuzz/bulletproof.cpp
@@ -33,40 +33,13 @@
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "fuzzer.h"
-class BulletproofFuzzer: public Fuzzer
-{
-public:
- virtual int run(const std::string &filename);
+BEGIN_INIT_SIMPLE_FUZZER()
+END_INIT_SIMPLE_FUZZER()
-private:
-};
-
-int BulletproofFuzzer::run(const std::string &filename)
-{
- std::string s;
-
- if (!epee::file_io_utils::load_file_to_string(filename, s))
- {
- std::cout << "Error: failed to load file " << filename << std::endl;
- return 1;
- }
+BEGIN_SIMPLE_FUZZER()
std::stringstream ss;
- ss << s;
+ ss << std::string((const char*)buf, len);
binary_archive<false> ba(ss);
rct::Bulletproof proof = AUTO_VAL_INIT(proof);
- bool r = ::serialization::serialize(ba, proof);
- if(!r)
- {
- std::cout << "Error: failed to parse bulletproof from file " << filename << std::endl;
- return 1;
- }
- return 0;
-}
-
-int main(int argc, const char **argv)
-{
- TRY_ENTRY();
- BulletproofFuzzer fuzzer;
- return run_fuzzer(argc, argv, fuzzer);
- CATCH_ENTRY_L0("main", 1);
-}
+ ::serialization::serialize(ba, proof);
+END_SIMPLE_FUZZER()