mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
fix crashing tests
This commit is contained in:
parent
0787b6e2fd
commit
0d6e3bcd89
|
@ -1,2 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
PYTHONPATH=pybind pytest-3 ../test/
|
export PYTHONPATH=pybind
|
||||||
|
rm -f crash.out.txt exit.out.txt
|
||||||
|
gdb -q -x $(readlink -e $(dirname $0))/gdb-filter.py --args /usr/bin/python3 -m pytest ../test/
|
||||||
|
test -e crash.out.txt && cat crash.out.txt
|
||||||
|
exit $(cat exit.out.txt)
|
||||||
|
|
|
@ -616,8 +616,6 @@ namespace llarp
|
||||||
if (not stream or not stream->is_open())
|
if (not stream or not stream->is_open())
|
||||||
throw std::runtime_error(stringify("Failed to open file ", confFile, " for writing"));
|
throw std::runtime_error(stringify("Failed to open file ", confFile, " for writing"));
|
||||||
|
|
||||||
llarp::LogInfo("confStr: ", confStr);
|
|
||||||
|
|
||||||
*stream << confStr;
|
*stream << confStr;
|
||||||
stream->flush();
|
stream->flush();
|
||||||
|
|
||||||
|
|
|
@ -463,28 +463,8 @@ namespace libuv
|
||||||
auto* self = static_cast<udp_glue*>(udp->impl);
|
auto* self = static_cast<udp_glue*>(udp->impl);
|
||||||
if (self == nullptr)
|
if (self == nullptr)
|
||||||
return -1;
|
return -1;
|
||||||
char* data = new char[sz];
|
auto buf = uv_buf_init((char*)ptr, sz);
|
||||||
std::copy_n(ptr, sz, data);
|
return uv_udp_try_send(&self->m_Handle, &buf, 1, to);
|
||||||
uv_buf_t buf = uv_buf_init(data, sz);
|
|
||||||
uv_udp_send_t* req = new uv_udp_send_t;
|
|
||||||
req->data = data;
|
|
||||||
if (uv_udp_send(
|
|
||||||
req,
|
|
||||||
&self->m_Handle,
|
|
||||||
&buf,
|
|
||||||
1,
|
|
||||||
to,
|
|
||||||
[](uv_udp_send_t* req, int) {
|
|
||||||
delete[](char*) req->data;
|
|
||||||
delete req;
|
|
||||||
})
|
|
||||||
!= 0)
|
|
||||||
|
|
||||||
{
|
|
||||||
delete req;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -2,37 +2,6 @@
|
||||||
#include <router_id.hpp>
|
#include <router_id.hpp>
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
TEST_CASE("Thrash DecayingHashSet", "[decaying-hashset]")
|
|
||||||
{
|
|
||||||
static constexpr auto duration = 5s;
|
|
||||||
|
|
||||||
static constexpr auto decayInterval = 50ms;
|
|
||||||
llarp::util::DecayingHashSet<llarp::AlignedBuffer<32>> hashset(decayInterval);
|
|
||||||
const llarp_time_t started = llarp::time_now_ms();
|
|
||||||
const auto end = duration + started;
|
|
||||||
llarp_time_t nextDecay = started + decayInterval;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
const auto now = llarp::time_now_ms();
|
|
||||||
for (size_t i = 0; i < 500; i++)
|
|
||||||
{
|
|
||||||
llarp::AlignedBuffer<32> rando;
|
|
||||||
rando.Randomize();
|
|
||||||
hashset.Insert(rando, now);
|
|
||||||
/// maybe reinsert to simulate filter hits
|
|
||||||
if (i % 20 == 0)
|
|
||||||
hashset.Insert(rando, now);
|
|
||||||
}
|
|
||||||
if (now >= nextDecay)
|
|
||||||
{
|
|
||||||
REQUIRE(not hashset.Empty());
|
|
||||||
hashset.Decay(now);
|
|
||||||
nextDecay += decayInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
} while (llarp::time_now_ms() <= end);
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_CASE("DecayingHashSet test decay static time", "[decaying-hashset]")
|
TEST_CASE("DecayingHashSet test decay static time", "[decaying-hashset]")
|
||||||
{
|
{
|
||||||
static constexpr auto timeout = 5s;
|
static constexpr auto timeout = 5s;
|
||||||
|
|
Loading…
Reference in a new issue