mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
1c2b43b7e0
But running failed.
124 lines
3.5 KiB
C++
124 lines
3.5 KiB
C++
|
|
// local
|
|
#include "GxsPairServiceTester.h"
|
|
#include "GxsPeerNode.h"
|
|
#include "gxstestservice.h"
|
|
|
|
// libretroshare
|
|
#include "rsitems/rsnxsitems.h"
|
|
|
|
GxsPairServiceTester::GxsPairServiceTester(const RsPeerId &peerId1, const RsPeerId &peerId2, int testMode, bool useIdentityService)
|
|
:SetServiceTester()
|
|
{
|
|
// setup stuff.
|
|
addSerialType(new RsNxsSerialiser(RS_SERVICE_GXS_TYPE_GXSID));
|
|
addSerialType(new RsNxsSerialiser(RS_SERVICE_GXS_TYPE_GXSCIRCLE));
|
|
addSerialType(new RsNxsSerialiser(RS_SERVICE_GXS_TYPE_TEST));
|
|
|
|
std::list<RsPeerId> friendList1, friendList2;
|
|
friendList1.push_back(peerId2);
|
|
friendList2.push_back(peerId1);
|
|
|
|
GxsPeerNode *n1 = new GxsPeerNode(peerId1, friendList1, testMode, useIdentityService);
|
|
GxsPeerNode *n2 = new GxsPeerNode(peerId2, friendList2, testMode, useIdentityService);
|
|
|
|
addNode(peerId1, n1);
|
|
addNode(peerId2, n2);
|
|
|
|
startup();
|
|
tick();
|
|
|
|
bringOnline(peerId1, friendList1);
|
|
bringOnline(peerId2, friendList2);
|
|
}
|
|
|
|
|
|
GxsPairServiceTester::GxsPairServiceTester(
|
|
const RsPeerId &peerId1,
|
|
const RsPeerId &peerId2,
|
|
const RsPeerId &peerId3,
|
|
const RsPeerId &peerId4,
|
|
int testMode,
|
|
bool useIdentityService)
|
|
|
|
:SetServiceTester()
|
|
{
|
|
// setup stuff.
|
|
addSerialType(new RsNxsSerialiser(RS_SERVICE_GXS_TYPE_GXSID));
|
|
addSerialType(new RsNxsSerialiser(RS_SERVICE_GXS_TYPE_GXSCIRCLE));
|
|
addSerialType(new RsNxsSerialiser(RS_SERVICE_GXS_TYPE_TEST));
|
|
|
|
std::list<RsPeerId> friendList1, friendList2, friendList3, friendList4;
|
|
friendList1.push_back(peerId2);
|
|
friendList1.push_back(peerId3);
|
|
friendList1.push_back(peerId4);
|
|
|
|
friendList2.push_back(peerId1);
|
|
friendList2.push_back(peerId3);
|
|
friendList2.push_back(peerId4);
|
|
|
|
friendList3.push_back(peerId1);
|
|
friendList3.push_back(peerId2);
|
|
friendList3.push_back(peerId4);
|
|
|
|
friendList4.push_back(peerId1);
|
|
friendList4.push_back(peerId2);
|
|
friendList4.push_back(peerId3);
|
|
|
|
GxsPeerNode *n1 = new GxsPeerNode(peerId1, friendList1, testMode, useIdentityService);
|
|
GxsPeerNode *n2 = new GxsPeerNode(peerId2, friendList2, testMode, useIdentityService);
|
|
GxsPeerNode *n3 = new GxsPeerNode(peerId3, friendList3, testMode, useIdentityService);
|
|
GxsPeerNode *n4 = new GxsPeerNode(peerId4, friendList4, testMode, useIdentityService);
|
|
|
|
addNode(peerId1, n1);
|
|
addNode(peerId2, n2);
|
|
addNode(peerId3, n3);
|
|
addNode(peerId4, n4);
|
|
|
|
startup();
|
|
tick();
|
|
|
|
bringOnline(peerId1, friendList1);
|
|
bringOnline(peerId2, friendList2);
|
|
bringOnline(peerId3, friendList3);
|
|
bringOnline(peerId4, friendList4);
|
|
}
|
|
|
|
|
|
GxsPairServiceTester::~GxsPairServiceTester()
|
|
{
|
|
return;
|
|
}
|
|
|
|
|
|
GxsPeerNode *GxsPairServiceTester::getGxsPeerNode(const RsPeerId &id)
|
|
{
|
|
return (GxsPeerNode *) getPeerNode(id);
|
|
}
|
|
|
|
|
|
void GxsPairServiceTester::PrintCapturedPackets()
|
|
{
|
|
std::cerr << "==========================================================================================";
|
|
std::cerr << std::endl;
|
|
std::cerr << "#Packets: " << getPacketCount();
|
|
std::cerr << std::endl;
|
|
|
|
for(uint32_t i = 0; i < getPacketCount(); i++)
|
|
{
|
|
SetPacket &pkt = examinePacket(i);
|
|
|
|
std::cerr << "==========================================================================================";
|
|
std::cerr << std::endl;
|
|
std::cerr << "Time: " << pkt.mTime;
|
|
std::cerr << " From: " << pkt.mSrcId.toStdString() << " To: " << pkt.mDestId.toStdString();
|
|
std::cerr << std::endl;
|
|
std::cerr << "-----------------------------------------------------------------------------------------";
|
|
std::cerr << std::endl;
|
|
pkt.mItem->print(std::cerr);
|
|
std::cerr << "==========================================================================================";
|
|
std::cerr << std::endl;
|
|
}
|
|
}
|
|
|