mirror of https://github.com/oxen-io/lokinet
Add missing files
parent
b2a72dd46a
commit
d69d538f1a
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "router_event.hpp"
|
||||
|
||||
namespace tooling
|
||||
{
|
||||
struct LinkSessionEstablishedEvent : public RouterEvent
|
||||
{
|
||||
llarp::RouterID remoteId;
|
||||
bool inbound = false;
|
||||
|
||||
LinkSessionEstablishedEvent(
|
||||
const llarp::RouterID& ourRouterId, const llarp::RouterID& remoteId_, bool inbound_)
|
||||
: RouterEvent("Link: LinkSessionEstablishedEvent", ourRouterId, false)
|
||||
, remoteId(remoteId_)
|
||||
, inbound(inbound_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
ToString() const
|
||||
{
|
||||
return RouterEvent::ToString() + (inbound ? "inbound" : "outbound")
|
||||
+ " : LinkSessionEstablished with " + remoteId.ToString();
|
||||
}
|
||||
};
|
||||
|
||||
struct ConnectionAttemptEvent : public RouterEvent
|
||||
{
|
||||
llarp::RouterID remoteId;
|
||||
|
||||
ConnectionAttemptEvent(const llarp::RouterID& ourRouterId, const llarp::RouterID& remoteId_)
|
||||
: RouterEvent("Link: ConnectionAttemptEvent", ourRouterId, false), remoteId(remoteId_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
ToString() const
|
||||
{
|
||||
return RouterEvent::ToString() + " : LinkSessionEstablished with " + remoteId.ToString();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace tooling
|
@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include "router_event.hpp"
|
||||
|
||||
namespace tooling
|
||||
{
|
||||
struct LinkSessionEstablishedEvent : public RouterEvent
|
||||
{
|
||||
llarp::RouterID remoteId;
|
||||
bool inbound = false;
|
||||
|
||||
LinkSessionEstablishedEvent(
|
||||
const llarp::RouterID& ourRouterId, const llarp::RouterID& remoteId_, bool inbound_)
|
||||
: RouterEvent("Link: LinkSessionEstablishedEvent", ourRouterId, false)
|
||||
, remoteId(remoteId_)
|
||||
, inbound(inbound_)
|
||||
{
|
||||
}
|
||||
|
||||
std::string
|
||||
ToString() const
|
||||
{
|
||||
return RouterEvent::ToString() + (inbound ? "inbound" : "outbound")
|
||||
+ " : LinkSessionEstablished with " + remoteId.ToString();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace tooling
|
@ -0,0 +1,44 @@
|
||||
import pyllarp
|
||||
from time import time
|
||||
|
||||
def test_peer_stats(HiveForPeerStats):
|
||||
hive = HiveForPeerStats(n_relays=5, n_clients=0, netid="hive")
|
||||
|
||||
start_time = time()
|
||||
cur_time = start_time
|
||||
test_duration = 30 #seconds
|
||||
|
||||
paths = []
|
||||
|
||||
print("looking for events...")
|
||||
|
||||
numInbound = 0
|
||||
numOutbound = 0
|
||||
numAttempts = 0
|
||||
|
||||
while cur_time < start_time + test_duration:
|
||||
|
||||
hive.CollectAllEvents()
|
||||
|
||||
for event in hive.events:
|
||||
event_name = event.__class__.__name__
|
||||
|
||||
if event_name == "LinkSessionEstablishedEvent":
|
||||
if event.inbound:
|
||||
numInbound += 1
|
||||
else:
|
||||
numOutbound += 1
|
||||
|
||||
if event_name == "ConnectionAttemptEvent":
|
||||
numAttempts += 1
|
||||
|
||||
hive.events = []
|
||||
cur_time = time()
|
||||
|
||||
print("test duration exceeded")
|
||||
print("in: {} out: {} attempts: {}", numInbound, numOutbound, numAttempts);
|
||||
assert(numInbound == numOutbound)
|
||||
assert(numOutbound == numAttempts)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue