aboutsummaryrefslogtreecommitdiff
path: root/tests/fuzz/base58.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/base58.cpp
parentMerge pull request #6510 (diff)
downloadmonero-81773f55a430e75fe5c6bee355ca518f16286dd1.tar.xz
fuzz_tests: refactor and add OSS-Fuzz compatibility
Diffstat (limited to '')
-rw-r--r--tests/fuzz/base58.cpp49
1 files changed, 6 insertions, 43 deletions
diff --git a/tests/fuzz/base58.cpp b/tests/fuzz/base58.cpp
index 5f909a5d9..08fa402dd 100644
--- a/tests/fuzz/base58.cpp
+++ b/tests/fuzz/base58.cpp
@@ -27,50 +27,13 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "include_base_utils.h"
-#include "file_io_utils.h"
#include "common/base58.h"
#include "fuzzer.h"
-class Base58Fuzzer: public Fuzzer
-{
-public:
- Base58Fuzzer() {}
- virtual int init();
- virtual int run(const std::string &filename);
-};
-
-int Base58Fuzzer::init()
-{
- return 0;
-}
-
-int Base58Fuzzer::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;
- }
- try
- {
- std::string data;
- tools::base58::decode(s, data);
- }
- catch (const std::exception &e)
- {
- std::cerr << "Failed to load from binary: " << e.what() << std::endl;
- return 1;
- }
- return 0;
-}
-
-int main(int argc, const char **argv)
-{
- TRY_ENTRY();
- Base58Fuzzer fuzzer;
- return run_fuzzer(argc, argv, fuzzer);
- CATCH_ENTRY_L0("main", 1);
-}
+BEGIN_INIT_SIMPLE_FUZZER()
+END_INIT_SIMPLE_FUZZER()
+BEGIN_SIMPLE_FUZZER()
+ std::string data;
+ tools::base58::decode(std::string((const char*)buf, len), data);
+END_SIMPLE_FUZZER()