toxcore/testing/fuzzing/fuzz_support.cc
iphydf 941026266e
refactor: Allow overriding mono_time in tox_new.
This makes it so if mono_time is overridden, no monotonic time-related
system call is invoked in tox_new.
2022-04-03 22:48:16 +00:00

22 lines
660 B
C++

/* SPDX-License-Identifier: GPL-3.0-or-later
* Copyright © 2021-2022 The TokTok team.
*/
#include "fuzz_support.h"
#include <memory>
#include "../../toxcore/crypto_core.h"
#include "../../toxcore/network.h"
#include "../../toxcore/tox_private.h"
std::unique_ptr<Tox_System> fuzz_system(uint64_t &clock)
{
auto sys = std::make_unique<Tox_System>();
sys->mono_time_callback = [](void *user_data) { return *static_cast<uint64_t *>(user_data); };
sys->mono_time_user_data = &clock;
sys->rng = system_random(); // TODO(iphydf): Put fuzz_random here.
sys->ns = system_network(); // TODO(iphydf): Put fuzz_network here.
return sys;
}