mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-10 22:35:49 -05:00
Add second testing Simulator.
It has a number of PeerNodes, and captures traffic for examination. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7271 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3a13b2ac65
commit
6be4a464a5
6 changed files with 599 additions and 0 deletions
78
tests/librssimulator/testing/SetServiceTester.h
Normal file
78
tests/librssimulator/testing/SetServiceTester.h
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include "retroshare/rsids.h"
|
||||
#include "pqi/p3linkmgr.h"
|
||||
|
||||
#include "SetPacket.h"
|
||||
#include "SetFilter.h"
|
||||
|
||||
class RsItem;
|
||||
class PeerNode;
|
||||
class RsSerialType;
|
||||
class RsSerialiser;
|
||||
|
||||
class SetServiceTester
|
||||
{
|
||||
public:
|
||||
SetServiceTester();
|
||||
~SetServiceTester();
|
||||
|
||||
enum EventType {
|
||||
UNTIL_CAPTURE = 0,
|
||||
UNTIL_FINISH,
|
||||
UNTIL_NONE
|
||||
};
|
||||
|
||||
bool addNode(const RsPeerId &peerId, std::list<RsPeerId> friendIds);
|
||||
bool addNode(const RsPeerId &peerId, PeerNode *node);
|
||||
|
||||
void addSerialType(RsSerialType *st);
|
||||
bool startup();
|
||||
|
||||
bool bringOnline(const RsPeerId &peerId, std::list<RsPeerId> peers);
|
||||
|
||||
bool tick();
|
||||
bool tickUntilCapturedPacket(int max_ticks, uint32_t &idx);
|
||||
bool tickUntilFinish(int max_ticks);
|
||||
|
||||
// return true, if we not transmit it.
|
||||
virtual bool filter(const SetPacket& packet);
|
||||
|
||||
// return true, if we should save it.
|
||||
virtual bool capture(const SetPacket& packet);
|
||||
|
||||
// return true to finish.
|
||||
virtual bool finish(const SetPacket& packet);
|
||||
|
||||
uint32_t getPacketCount();
|
||||
SetPacket &examinePacket(uint32_t idx);
|
||||
bool injectPacket(const SetPacket &pkt);
|
||||
|
||||
uint32_t getNodeCount();
|
||||
PeerNode *getPeerNode(const RsPeerId &id);
|
||||
|
||||
SetFilter &getDropFilter() { return mDropFilter; }
|
||||
SetFilter &getCaptureFilter() { return mCaptureFilter; }
|
||||
SetFilter &getFinishFilter() { return mFinishFilter; }
|
||||
|
||||
private:
|
||||
|
||||
bool tickUntilEvent(int max_ticks, EventType eventType);
|
||||
|
||||
RsItem *convertToRsItem(RsRawItem *rawitem, bool toDelete);
|
||||
RsRawItem *convertToRsRawItem(RsItem *item, bool toDelete);
|
||||
|
||||
|
||||
time_t mRefTime;
|
||||
std::map<RsPeerId, PeerNode *> mNodes;
|
||||
RsSerialiser *mRsSerialiser;
|
||||
std::vector<SetPacket> mPackets;
|
||||
|
||||
SetFilter mDropFilter;
|
||||
SetFilter mCaptureFilter;
|
||||
SetFilter mFinishFilter;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue