mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Add Gxs Circle test.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7307 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
23480be883
commit
b184bc1809
@ -70,7 +70,7 @@ rs_nxs_test::NxsTestHub::NxsTestHub(NxsTestScenario::pointer testScenario)
|
|||||||
new NotifyWithPeerId(*cit, *this),
|
new NotifyWithPeerId(*cit, *this),
|
||||||
mTestScenario->getServiceInfo(),
|
mTestScenario->getServiceInfo(),
|
||||||
mTestScenario->getDummyReputations(*cit),
|
mTestScenario->getDummyReputations(*cit),
|
||||||
mTestScenario->getDummyCircles(*cit), true
|
mTestScenario->getDummyCircles(*cit), NULL, true
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
113
tests/unittests/libretroshare/services/gxs/FakePgpAuxUtils.cc
Normal file
113
tests/unittests/libretroshare/services/gxs/FakePgpAuxUtils.cc
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
* unittests/libretroshare/services: fakepgpauxutils.h
|
||||||
|
*
|
||||||
|
* Identity interface for RetroShare.
|
||||||
|
*
|
||||||
|
* Copyright 2014-2014 by Robert Fernie.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License Version 2.1 as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "FakePgpAuxUtils.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
FakePgpAuxUtils::FakePgpAuxUtils(const RsPeerId& ownId)
|
||||||
|
{
|
||||||
|
mOwnId = getPGPId(ownId);
|
||||||
|
addPeerIdToPgpList(ownId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FakePgpAuxUtils::addPeerListToPgpList(const std::list<RsPeerId> &ids)
|
||||||
|
{
|
||||||
|
std::list<RsPeerId>::const_iterator it;
|
||||||
|
for(it = ids.begin(); it != ids.end(); it++)
|
||||||
|
{
|
||||||
|
addPeerIdToPgpList(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FakePgpAuxUtils::addPeerIdToPgpList(const RsPeerId &id)
|
||||||
|
{
|
||||||
|
RsPgpId pgpId = getPGPId(id);
|
||||||
|
if (mPgpList.end() == std::find(mPgpList.begin(), mPgpList.end(), pgpId))
|
||||||
|
{
|
||||||
|
mPgpList.push_back(pgpId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const RsPgpId & FakePgpAuxUtils::getPGPOwnId()
|
||||||
|
{
|
||||||
|
return mOwnId;
|
||||||
|
}
|
||||||
|
|
||||||
|
RsPgpId FakePgpAuxUtils::getPGPId(const RsPeerId& sslid)
|
||||||
|
{
|
||||||
|
std::cerr << "FakePgpAuxUtils::getPGPId()";
|
||||||
|
/* convert an sslId */
|
||||||
|
std::string idstring = sslid.toStdString();
|
||||||
|
idstring.resize(RsPgpId::SIZE_IN_BYTES*2, '0');
|
||||||
|
RsPgpId pgpId(idstring);
|
||||||
|
|
||||||
|
std::cerr << " RsPeerId: " << sslid.toStdString();
|
||||||
|
std::cerr << " RsPgpId: " << pgpId.toStdString();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return pgpId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FakePgpAuxUtils::getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const
|
||||||
|
{
|
||||||
|
std::cerr << "FakePgpAuxUtils::getKeyFingerprint()";
|
||||||
|
/* convert an sslId */
|
||||||
|
std::string idstring = id.toStdString();
|
||||||
|
idstring.resize(PGPFingerprintType::SIZE_IN_BYTES*2, '0');
|
||||||
|
PGPFingerprintType pgpfp(idstring);
|
||||||
|
|
||||||
|
std::cerr << " RsPeerId: " << id.toStdString();
|
||||||
|
std::cerr << " RsPgpId: " << pgpfp.toStdString();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
fp = pgpfp;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FakePgpAuxUtils::VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FakePgpAuxUtils::getGPGAllList(std::list<RsPgpId> &ids)
|
||||||
|
{
|
||||||
|
ids = mPgpList;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FakePgpAuxUtils::askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result )
|
||||||
|
{
|
||||||
|
for(int i = 0; i < *signlen; i++)
|
||||||
|
{
|
||||||
|
sign[i] = 0;
|
||||||
|
}
|
||||||
|
signature_result = 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
51
tests/unittests/libretroshare/services/gxs/FakePgpAuxUtils.h
Normal file
51
tests/unittests/libretroshare/services/gxs/FakePgpAuxUtils.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* unittests/libretroshare/services: fakepgpauxutils.h
|
||||||
|
*
|
||||||
|
* Identity interface for RetroShare.
|
||||||
|
*
|
||||||
|
* Copyright 2014-2014 by Robert Fernie.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Library General Public
|
||||||
|
* License Version 2.1 as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Library General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Library General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||||
|
* USA.
|
||||||
|
*
|
||||||
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "pgp/pgpauxutils.h"
|
||||||
|
|
||||||
|
class FakePgpAuxUtils: public PgpAuxUtils
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FakePgpAuxUtils(const RsPeerId& ownId);
|
||||||
|
|
||||||
|
virtual const RsPgpId &getPGPOwnId();
|
||||||
|
virtual RsPgpId getPGPId(const RsPeerId& sslid);
|
||||||
|
|
||||||
|
virtual bool getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const;
|
||||||
|
virtual bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint);
|
||||||
|
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result );
|
||||||
|
|
||||||
|
virtual void addPeerListToPgpList(const std::list<RsPeerId> &ids);
|
||||||
|
virtual void addPeerIdToPgpList(const RsPeerId &id);
|
||||||
|
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
|
||||||
|
private:
|
||||||
|
RsPgpId mOwnId;
|
||||||
|
std::list<RsPgpId> mPgpList;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -7,18 +7,20 @@
|
|||||||
// libretroshare
|
// libretroshare
|
||||||
#include "serialiser/rsnxsitems.h"
|
#include "serialiser/rsnxsitems.h"
|
||||||
|
|
||||||
GxsPairServiceTester::GxsPairServiceTester(const RsPeerId &peerId1, const RsPeerId &peerId2, int testMode)
|
GxsPairServiceTester::GxsPairServiceTester(const RsPeerId &peerId1, const RsPeerId &peerId2, int testMode, bool useIdentityService)
|
||||||
:SetServiceTester()
|
:SetServiceTester()
|
||||||
{
|
{
|
||||||
// setup stuff.
|
// 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));
|
addSerialType(new RsNxsSerialiser(RS_SERVICE_GXS_TYPE_TEST));
|
||||||
|
|
||||||
std::list<RsPeerId> friendList1, friendList2;
|
std::list<RsPeerId> friendList1, friendList2;
|
||||||
friendList1.push_back(peerId2);
|
friendList1.push_back(peerId2);
|
||||||
friendList2.push_back(peerId1);
|
friendList2.push_back(peerId1);
|
||||||
|
|
||||||
GxsPeerNode *n1 = new GxsPeerNode(peerId1, friendList1, testMode);
|
GxsPeerNode *n1 = new GxsPeerNode(peerId1, friendList1, testMode, useIdentityService);
|
||||||
GxsPeerNode *n2 = new GxsPeerNode(peerId2, friendList2, testMode);
|
GxsPeerNode *n2 = new GxsPeerNode(peerId2, friendList2, testMode, useIdentityService);
|
||||||
|
|
||||||
addNode(peerId1, n1);
|
addNode(peerId1, n1);
|
||||||
addNode(peerId2, n2);
|
addNode(peerId2, n2);
|
||||||
@ -31,6 +33,58 @@ GxsPairServiceTester::GxsPairServiceTester(const RsPeerId &peerId1, const RsPeer
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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()
|
GxsPairServiceTester::~GxsPairServiceTester()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -43,22 +97,27 @@ GxsPeerNode *GxsPairServiceTester::getGxsPeerNode(const RsPeerId &id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GxsPairServiceTester::createGroup(const RsPeerId &id, const std::string &name)
|
void GxsPairServiceTester::PrintCapturedPackets()
|
||||||
{
|
{
|
||||||
/* create a couple of groups */
|
std::cerr << "==========================================================================================";
|
||||||
GxsTestService *testService = getGxsPeerNode(id)->mTestService;
|
std::cerr << std::endl;
|
||||||
RsTokenService *tokenService = testService->RsGenExchange::getTokenService();
|
std::cerr << "#Packets: " << getPacketCount();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
RsTestGroup grp1;
|
for(int i = 0; i < getPacketCount(); i++)
|
||||||
grp1.mMeta.mGroupName = name;
|
{
|
||||||
grp1.mTestString = "testString";
|
SetPacket &pkt = examinePacket(i);
|
||||||
uint32_t token1;
|
|
||||||
|
|
||||||
testService->submitTestGroup(token1, grp1);
|
std::cerr << "==========================================================================================";
|
||||||
while(tokenService->requestStatus(token1) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
std::cerr << std::endl;
|
||||||
{
|
std::cerr << "Time: " << pkt.mTime;
|
||||||
tick();
|
std::cerr << " From: " << pkt.mSrcId.toStdString() << " To: " << pkt.mDestId.toStdString();
|
||||||
sleep(1);
|
std::cerr << std::endl;
|
||||||
}
|
std::cerr << "-----------------------------------------------------------------------------------------";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
pkt.mItem->print(std::cerr);
|
||||||
|
std::cerr << "==========================================================================================";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
// from librssimulator
|
// from librssimulator
|
||||||
#include "testing/SetServiceTester.h"
|
#include "testing/SetServiceTester.h"
|
||||||
|
#include "gxstestservice.h"
|
||||||
|
|
||||||
class GxsPeerNode;
|
class GxsPeerNode;
|
||||||
|
|
||||||
@ -9,12 +10,20 @@ class GxsPairServiceTester: public SetServiceTester
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GxsPairServiceTester(const RsPeerId &peerId1, const RsPeerId &peerId2, int testMode);
|
GxsPairServiceTester(const RsPeerId &peerId1, const RsPeerId &peerId2, int testMode, bool useIdentityService);
|
||||||
~GxsPairServiceTester();
|
~GxsPairServiceTester();
|
||||||
|
|
||||||
void createGroup(const RsPeerId &id, const std::string &name);
|
// Make 4 peer version.
|
||||||
|
GxsPairServiceTester(
|
||||||
|
const RsPeerId &peerId1,
|
||||||
|
const RsPeerId &peerId2,
|
||||||
|
const RsPeerId &peerId3,
|
||||||
|
const RsPeerId &peerId4,
|
||||||
|
int testMode,
|
||||||
|
bool useIdentityService);
|
||||||
|
|
||||||
GxsPeerNode *getGxsPeerNode(const RsPeerId &id);
|
GxsPeerNode *getGxsPeerNode(const RsPeerId &id);
|
||||||
|
void PrintCapturedPackets();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
|
||||||
// from libretroshare
|
// from libretroshare
|
||||||
#include "services/p3statusservice.h"
|
//#include "serialiser/rsstatusitems.h"
|
||||||
#include "serialiser/rsstatusitems.h"
|
#include "services/p3idservice.h"
|
||||||
|
#include "services/p3gxscircles.h"
|
||||||
#include "gxs/rsgixs.h"
|
#include "gxs/rsgixs.h"
|
||||||
#include "gxs/rsdataservice.h"
|
#include "gxs/rsdataservice.h"
|
||||||
#include "gxs/rsgxsnetservice.h"
|
#include "gxs/rsgxsnetservice.h"
|
||||||
@ -9,10 +10,12 @@
|
|||||||
|
|
||||||
// local
|
// local
|
||||||
#include "GxsPeerNode.h"
|
#include "GxsPeerNode.h"
|
||||||
|
#include "FakePgpAuxUtils.h"
|
||||||
#include "gxstestservice.h"
|
#include "gxstestservice.h"
|
||||||
|
|
||||||
GxsPeerNode::GxsPeerNode(const RsPeerId &ownId, const std::list<RsPeerId> &friends, int testMode)
|
GxsPeerNode::GxsPeerNode(const RsPeerId &ownId, const std::list<RsPeerId> &friends, int testMode, bool useIdentityService)
|
||||||
:PeerNode(ownId, friends, false),
|
:PeerNode(ownId, friends, false),
|
||||||
|
mUseIdentityService(useIdentityService),
|
||||||
mTestMode(testMode),
|
mTestMode(testMode),
|
||||||
mGxsDir("./gxs_unittest/" + ownId.toStdString() + "/"),
|
mGxsDir("./gxs_unittest/" + ownId.toStdString() + "/"),
|
||||||
mGxsIdService(NULL),
|
mGxsIdService(NULL),
|
||||||
@ -30,27 +33,89 @@ GxsPeerNode::GxsPeerNode(const RsPeerId &ownId, const std::list<RsPeerId> &frien
|
|||||||
|
|
||||||
// Create Service for Testing.
|
// Create Service for Testing.
|
||||||
// Specific Testing service here.
|
// Specific Testing service here.
|
||||||
RsDirUtil::checkCreateDirectory(mGxsDir);
|
RsDirUtil::checkCreateDirectory(mGxsDir);
|
||||||
|
|
||||||
std::set<std::string> filesToKeep;
|
std::set<std::string> filesToKeep;
|
||||||
RsDirUtil::cleanupDirectory(mGxsDir, filesToKeep);
|
RsDirUtil::cleanupDirectory(mGxsDir, filesToKeep);
|
||||||
|
|
||||||
mTestDs = new RsDataService(mGxsDir, "test_db",
|
std::string gxs_passwd = "testpassword";
|
||||||
RS_SERVICE_GXS_TYPE_TEST,
|
|
||||||
NULL, "testPasswd");
|
|
||||||
|
|
||||||
mTestService = new GxsTestService(mTestDs, NULL, mGxsIdService, testMode);
|
mPgpAuxUtils = new FakePgpAuxUtils(ownId);
|
||||||
|
mPgpAuxUtils->addPeerListToPgpList(friends);
|
||||||
|
|
||||||
mTestNs = new RsGxsNetService(
|
if (mUseIdentityService)
|
||||||
RS_SERVICE_GXS_TYPE_TEST, mTestDs, nxsMgr,
|
{
|
||||||
mTestService, mTestService->getServiceInfo(),
|
/**** Identity service ****/
|
||||||
mGxsIdService, mGxsCircles);
|
mGxsIdDs = new RsDataService(mGxsDir, "gxsid_db",
|
||||||
|
RS_SERVICE_GXS_TYPE_GXSID, NULL, gxs_passwd);
|
||||||
|
mGxsIdService = new p3IdService(mGxsIdDs, NULL, mPgpAuxUtils);
|
||||||
|
|
||||||
|
// circles created here, as needed by Ids.
|
||||||
|
mGxsCirclesDs = new RsDataService(mGxsDir, "gxscircles_db",
|
||||||
|
RS_SERVICE_GXS_TYPE_GXSCIRCLE, NULL, gxs_passwd);
|
||||||
|
mGxsCircles = new p3GxsCircles(mGxsCirclesDs, NULL, mGxsIdService, mPgpAuxUtils);
|
||||||
|
|
||||||
|
// create GXS ID service
|
||||||
|
mGxsIdNs = new RsGxsNetService(
|
||||||
|
RS_SERVICE_GXS_TYPE_GXSID, mGxsIdDs, nxsMgr,
|
||||||
|
mGxsIdService, mGxsIdService->getServiceInfo(),
|
||||||
|
mGxsIdService, mGxsCircles,
|
||||||
|
mPgpAuxUtils,
|
||||||
|
false); // don't synchronise group automatic (need explicit group request)
|
||||||
|
|
||||||
|
mGxsIdService->setNes(mGxsIdNs);
|
||||||
|
/**** GxsCircle service ****/
|
||||||
|
|
||||||
|
mGxsCirclesNs = new RsGxsNetService(
|
||||||
|
RS_SERVICE_GXS_TYPE_GXSCIRCLE, mGxsCirclesDs, nxsMgr,
|
||||||
|
mGxsCircles, mGxsCircles->getServiceInfo(),
|
||||||
|
mGxsIdService, mGxsCircles,
|
||||||
|
mPgpAuxUtils);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mGxsIdDs = NULL;
|
||||||
|
mGxsIdService = NULL;
|
||||||
|
mGxsCirclesDs = NULL;
|
||||||
|
mGxsCircles = NULL;
|
||||||
|
mGxsIdNs = NULL;
|
||||||
|
mGxsCirclesNs = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
mTestDs = new RsDataService(mGxsDir, "test_db",
|
||||||
|
RS_SERVICE_GXS_TYPE_TEST,
|
||||||
|
NULL, "testPasswd");
|
||||||
|
|
||||||
|
mTestService = new GxsTestService(mTestDs, NULL, mGxsIdService, testMode);
|
||||||
|
|
||||||
|
mTestNs = new RsGxsNetService(
|
||||||
|
RS_SERVICE_GXS_TYPE_TEST, mTestDs, nxsMgr,
|
||||||
|
mTestService, mTestService->getServiceInfo(),
|
||||||
|
mGxsIdService, mGxsCircles,
|
||||||
|
mPgpAuxUtils);
|
||||||
|
|
||||||
|
if (mUseIdentityService)
|
||||||
|
{
|
||||||
|
AddService(mGxsIdNs);
|
||||||
|
AddService(mGxsCirclesNs);
|
||||||
|
}
|
||||||
AddService(mTestNs);
|
AddService(mTestNs);
|
||||||
|
|
||||||
//mConfigMgr->addConfiguration("posted.cfg", posted_ns);
|
//mConfigMgr->addConfiguration("testservice.cfg", mTestService);
|
||||||
|
|
||||||
|
if (mUseIdentityService)
|
||||||
|
{
|
||||||
|
//mConfigMgr->addConfiguration("gxsid.cfg", mGxsIdNs);
|
||||||
|
//mConfigMgr->addConfiguration("gxscircles.cfg", mGxsCircleNs);
|
||||||
|
|
||||||
|
createThread(*mGxsIdService);
|
||||||
|
createThread(*mGxsIdNs);
|
||||||
|
createThread(*mGxsCircles);
|
||||||
|
createThread(*mGxsCirclesNs);
|
||||||
|
}
|
||||||
|
|
||||||
createThread(*mTestService);
|
createThread(*mTestService);
|
||||||
createThread(*mTestNs);
|
createThread(*mTestNs);
|
||||||
|
|
||||||
//node->AddPqiServiceMonitor(status);
|
//node->AddPqiServiceMonitor(status);
|
||||||
}
|
}
|
||||||
@ -59,16 +124,452 @@ GxsPeerNode::GxsPeerNode(const RsPeerId &ownId, const std::list<RsPeerId> &frien
|
|||||||
GxsPeerNode::~GxsPeerNode()
|
GxsPeerNode::~GxsPeerNode()
|
||||||
{
|
{
|
||||||
mTestService->join();
|
mTestService->join();
|
||||||
mTestNs->join();
|
mTestNs->join();
|
||||||
|
|
||||||
|
if (mUseIdentityService)
|
||||||
|
{
|
||||||
|
mGxsIdService->join();
|
||||||
|
mGxsIdNs->join();
|
||||||
|
mGxsCircles->join();
|
||||||
|
mGxsCirclesNs->join();
|
||||||
|
|
||||||
|
delete mGxsIdNs;
|
||||||
|
delete mGxsIdService;
|
||||||
|
|
||||||
|
delete mGxsCirclesNs;
|
||||||
|
delete mGxsCircles;
|
||||||
|
}
|
||||||
|
|
||||||
delete mTestNs;
|
delete mTestNs;
|
||||||
delete mTestService;
|
delete mTestService;
|
||||||
// this is deleted somewhere else?
|
// this is deleted somewhere else?
|
||||||
//delete mTestDs;
|
//delete mTestDs;
|
||||||
|
|
||||||
std::set<std::string> filesToKeep;
|
std::set<std::string> filesToKeep;
|
||||||
RsDirUtil::cleanupDirectory(mGxsDir, filesToKeep);
|
RsDirUtil::cleanupDirectory(mGxsDir, filesToKeep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool GxsPeerNode::createIdentity(const std::string &name,
|
||||||
|
bool pgpLinked,
|
||||||
|
uint32_t circleType,
|
||||||
|
const RsGxsCircleId &circleId,
|
||||||
|
RsGxsId &gxsId)
|
||||||
|
{
|
||||||
|
/* create a couple of groups */
|
||||||
|
RsTokenService *tokenService = mGxsIdService->RsGenExchange::getTokenService();
|
||||||
|
|
||||||
|
|
||||||
|
RsGxsIdGroup id;
|
||||||
|
id.mMeta.mGroupName = name;
|
||||||
|
if (pgpLinked)
|
||||||
|
{
|
||||||
|
id.mMeta.mGroupFlags = RSGXSID_GROUPFLAG_REALID;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id.mMeta.mGroupFlags = 0;
|
||||||
|
}
|
||||||
|
id.mMeta.mCircleType = circleType;
|
||||||
|
|
||||||
|
switch(circleType)
|
||||||
|
{
|
||||||
|
case GXS_CIRCLE_TYPE_YOUREYESONLY:
|
||||||
|
id.mMeta.mInternalCircle = circleId;
|
||||||
|
break;
|
||||||
|
case GXS_CIRCLE_TYPE_LOCAL:
|
||||||
|
// no CircleId,
|
||||||
|
break;
|
||||||
|
case GXS_CIRCLE_TYPE_PUBLIC:
|
||||||
|
// no CircleId,
|
||||||
|
break;
|
||||||
|
case GXS_CIRCLE_TYPE_EXTERNAL:
|
||||||
|
id.mMeta.mCircleId = circleId;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case GXS_CIRCLE_TYPE_EXT_SELF:
|
||||||
|
std::cerr << "GxsPeerNode::createIdentity() Invalid circleType";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
if (!mGxsIdService->createGroup(token, id))
|
||||||
|
{
|
||||||
|
std::cerr << "GxsPeerNode::createIdentity() failed";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
RsGxsGroupId groupId;
|
||||||
|
if (mGxsIdService->acknowledgeTokenGrp(token, groupId))
|
||||||
|
{
|
||||||
|
RsGxsId tmpGxsId(groupId.toStdString());
|
||||||
|
gxsId = tmpGxsId;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GxsPeerNode::createCircle(const std::string &name,
|
||||||
|
uint32_t circleType,
|
||||||
|
const RsGxsCircleId &circleId,
|
||||||
|
const RsGxsId &authorId,
|
||||||
|
std::list<RsPgpId> localMembers,
|
||||||
|
std::list<RsGxsId> externalMembers,
|
||||||
|
RsGxsGroupId &groupId)
|
||||||
|
{
|
||||||
|
/* create a couple of groups */
|
||||||
|
RsTokenService *tokenService = mGxsCircles->RsGenExchange::getTokenService();
|
||||||
|
|
||||||
|
RsGxsCircleGroup grp1;
|
||||||
|
grp1.mMeta.mGroupName = name;
|
||||||
|
grp1.mMeta.mAuthorId = authorId;
|
||||||
|
grp1.mMeta.mCircleType = circleType;
|
||||||
|
|
||||||
|
switch(circleType)
|
||||||
|
{
|
||||||
|
case GXS_CIRCLE_TYPE_LOCAL:
|
||||||
|
// no CircleId,
|
||||||
|
// THIS is for LOCAL Storage....
|
||||||
|
grp1.mLocalFriends = localMembers;
|
||||||
|
break;
|
||||||
|
case GXS_CIRCLE_TYPE_YOUREYESONLY:
|
||||||
|
// Circle shouldn't use this.
|
||||||
|
// but could potentially.
|
||||||
|
grp1.mMeta.mInternalCircle = circleId;
|
||||||
|
grp1.mInvitedMembers = externalMembers;
|
||||||
|
break;
|
||||||
|
case GXS_CIRCLE_TYPE_PUBLIC:
|
||||||
|
// no CircleId,
|
||||||
|
grp1.mInvitedMembers = externalMembers;
|
||||||
|
break;
|
||||||
|
case GXS_CIRCLE_TYPE_EXTERNAL:
|
||||||
|
grp1.mMeta.mCircleId = circleId;
|
||||||
|
grp1.mInvitedMembers = externalMembers;
|
||||||
|
break;
|
||||||
|
case GXS_CIRCLE_TYPE_EXT_SELF:
|
||||||
|
// no CircleId.
|
||||||
|
grp1.mInvitedMembers = externalMembers;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
std::cerr << "GxsPeerNode::createCircle() Invalid circleType";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
if (!mGxsCircles->createGroup(token, grp1))
|
||||||
|
{
|
||||||
|
std::cerr << "GxsPeerNode::createCircle() failed";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
return mGxsCircles->acknowledgeTokenGrp(token, groupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool GxsPeerNode::createGroup(const std::string &name,
|
||||||
|
uint32_t circleType,
|
||||||
|
const RsGxsCircleId &circleId,
|
||||||
|
const RsGxsId &authorId,
|
||||||
|
RsGxsGroupId &groupId)
|
||||||
|
{
|
||||||
|
/* create a couple of groups */
|
||||||
|
RsTokenService *tokenService = mTestService->RsGenExchange::getTokenService();
|
||||||
|
|
||||||
|
RsTestGroup grp1;
|
||||||
|
grp1.mMeta.mGroupName = name;
|
||||||
|
grp1.mMeta.mAuthorId = authorId;
|
||||||
|
grp1.mMeta.mCircleType = circleType;
|
||||||
|
grp1.mTestString = "testString";
|
||||||
|
|
||||||
|
switch(circleType)
|
||||||
|
{
|
||||||
|
case GXS_CIRCLE_TYPE_YOUREYESONLY:
|
||||||
|
grp1.mMeta.mInternalCircle = circleId;
|
||||||
|
break;
|
||||||
|
case GXS_CIRCLE_TYPE_LOCAL:
|
||||||
|
// no CircleId,
|
||||||
|
break;
|
||||||
|
case GXS_CIRCLE_TYPE_PUBLIC:
|
||||||
|
// no CircleId,
|
||||||
|
break;
|
||||||
|
case GXS_CIRCLE_TYPE_EXTERNAL:
|
||||||
|
grp1.mMeta.mCircleId = circleId;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
case GXS_CIRCLE_TYPE_EXT_SELF:
|
||||||
|
std::cerr << "GxsPeerNode::createGroup() Invalid circleType";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
if (!mTestService->submitTestGroup(token, grp1))
|
||||||
|
{
|
||||||
|
std::cerr << "GxsPeerNode::createGroup() failed";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
return mTestService->acknowledgeTokenGrp(token, groupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GxsPeerNode::createMsg(const std::string &msgstr,
|
||||||
|
const RsGxsGroupId &groupId,
|
||||||
|
const RsGxsId &authorId,
|
||||||
|
RsGxsMessageId &msgId)
|
||||||
|
{
|
||||||
|
/* create a couple of groups */
|
||||||
|
RsTokenService *tokenService = mTestService->RsGenExchange::getTokenService();
|
||||||
|
|
||||||
|
RsTestMsg msg;
|
||||||
|
msg.mMeta.mGroupId = groupId;
|
||||||
|
msg.mMeta.mAuthorId = authorId;
|
||||||
|
msg.mTestString = msgstr;
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
if (!mTestService->submitTestMsg(token, msg))
|
||||||
|
{
|
||||||
|
std::cerr << "GxsPeerNode::createMsg() failed";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
RsGxsGrpMsgIdPair pairId;
|
||||||
|
bool retval = mTestService->acknowledgeTokenMsg(token, pairId);
|
||||||
|
if (retval)
|
||||||
|
{
|
||||||
|
msgId = pairId.second;
|
||||||
|
}
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GxsPeerNode::subscribeToGroup(const RsGxsGroupId &groupId, bool subscribe)
|
||||||
|
{
|
||||||
|
/* create a couple of groups */
|
||||||
|
RsTokenService *tokenService = mTestService->RsGenExchange::getTokenService();
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
if (!mTestService->RsGenExchange::subscribeToGroup(token, groupId, subscribe))
|
||||||
|
{
|
||||||
|
std::cerr << "GxsPeerNode::subscribeToGroup() failed";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
RsGxsGroupId ackGroupId;
|
||||||
|
return mTestService->acknowledgeTokenGrp(token, ackGroupId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool GxsPeerNode::getGroups(std::vector<RsTestGroup> &groups)
|
||||||
|
{
|
||||||
|
std::cerr << "GxsPeerNode::getGroups()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
RsTokenService *tokenService = mTestService->RsGenExchange::getTokenService();
|
||||||
|
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts);
|
||||||
|
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
return mTestService->getTestGroups(token, groups);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool GxsPeerNode::getGroupList(std::list<RsGxsGroupId> &groups)
|
||||||
|
{
|
||||||
|
std::cerr << "GxsPeerNode::getGroupList()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
RsTokenService *tokenService = mTestService->RsGenExchange::getTokenService();
|
||||||
|
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_IDS;
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts);
|
||||||
|
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mTestService->RsGenExchange::getGroupList(token, groups);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GxsPeerNode::getMsgList(const RsGxsGroupId &id, std::list<RsGxsMessageId> &msgIds)
|
||||||
|
{
|
||||||
|
std::cerr << "GxsPeerNode::getMsgList()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
RsTokenService *tokenService = mTestService->RsGenExchange::getTokenService();
|
||||||
|
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_IDS;
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
std::list<RsGxsGroupId> grpIds;
|
||||||
|
grpIds.push_back(id);
|
||||||
|
|
||||||
|
tokenService->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts, grpIds);
|
||||||
|
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > msgResult;
|
||||||
|
|
||||||
|
if (mTestService->RsGenExchange::getMsgList(token, msgResult))
|
||||||
|
{
|
||||||
|
std::vector<RsGxsMessageId>::iterator vit;
|
||||||
|
for(vit = msgResult[id].begin(); vit != msgResult[id].end(); vit++)
|
||||||
|
{
|
||||||
|
msgIds.push_back(*vit);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GxsPeerNode::getIdentities(std::vector<RsGxsIdGroup> &groups)
|
||||||
|
{
|
||||||
|
std::cerr << "GxsPeerNode::getIdentities()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
RsTokenService *tokenService = mGxsIdService->RsGenExchange::getTokenService();
|
||||||
|
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts);
|
||||||
|
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
return mGxsIdService->getGroupData(token, groups);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GxsPeerNode::getIdentitiesList(std::list<RsGxsGroupId> &groups)
|
||||||
|
{
|
||||||
|
std::cerr << "GxsPeerNode::getIdentitiesList()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
RsTokenService *tokenService = mGxsIdService->RsGenExchange::getTokenService();
|
||||||
|
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_IDS;
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts);
|
||||||
|
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mGxsIdService->RsGenExchange::getGroupList(token, groups);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool GxsPeerNode::getCircles(std::vector<RsGxsCircleGroup> &groups)
|
||||||
|
{
|
||||||
|
std::cerr << "GxsPeerNode::getCircles()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
RsTokenService *tokenService = mGxsCircles->RsGenExchange::getTokenService();
|
||||||
|
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts);
|
||||||
|
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
return mGxsCircles->getGroupData(token, groups);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GxsPeerNode::getCirclesList(std::list<RsGxsGroupId> &groups)
|
||||||
|
{
|
||||||
|
std::cerr << "GxsPeerNode::getCirclesList()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
RsTokenService *tokenService = mGxsCircles->RsGenExchange::getTokenService();
|
||||||
|
|
||||||
|
RsTokReqOptions opts;
|
||||||
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_IDS;
|
||||||
|
|
||||||
|
uint32_t token;
|
||||||
|
tokenService->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_LIST, opts);
|
||||||
|
while(tokenService->requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mGxsCircles->RsGenExchange::getGroupList(token, groups);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,27 +1,83 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
// from retroshare
|
||||||
|
#include "retroshare/rsids.h"
|
||||||
|
#include "retroshare/rstypes.h"
|
||||||
|
#include "retroshare/rsgxscircles.h"
|
||||||
|
#include "retroshare/rsidentity.h"
|
||||||
|
|
||||||
// from librssimulator
|
// from librssimulator
|
||||||
#include "peer/PeerNode.h"
|
#include "peer/PeerNode.h"
|
||||||
|
|
||||||
|
#include "gxstestservice.h"
|
||||||
|
|
||||||
class RsGxsIdExchange;
|
class RsGxsIdExchange;
|
||||||
class RsGxsCircleExchange;
|
class RsGxsCircleExchange;
|
||||||
class GxsTestService;
|
class GxsTestService;
|
||||||
class RsGeneralDataService;
|
class RsGeneralDataService;
|
||||||
class RsGxsNetService;
|
class RsGxsNetService;
|
||||||
|
class p3IdService;
|
||||||
|
class p3GxsCircles;
|
||||||
|
class FakePgpAuxUtils;
|
||||||
|
|
||||||
class GxsPeerNode: public PeerNode
|
class GxsPeerNode: public PeerNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
GxsPeerNode(const RsPeerId &ownId, const std::list<RsPeerId> &peers, int testMode);
|
GxsPeerNode(const RsPeerId &ownId, const std::list<RsPeerId> &peers, int testMode, bool useIdentityService);
|
||||||
~GxsPeerNode();
|
~GxsPeerNode();
|
||||||
|
|
||||||
|
bool createIdentity(const std::string &name,
|
||||||
|
bool pgpLinked,
|
||||||
|
uint32_t circleType,
|
||||||
|
const RsGxsCircleId &circleId,
|
||||||
|
RsGxsId &gxsId);
|
||||||
|
|
||||||
|
bool createCircle(const std::string &name,
|
||||||
|
uint32_t circleType,
|
||||||
|
const RsGxsCircleId &circleId,
|
||||||
|
const RsGxsId &authorId,
|
||||||
|
std::list<RsPgpId> localMembers,
|
||||||
|
std::list<RsGxsId> externalMembers,
|
||||||
|
RsGxsGroupId &groupId);
|
||||||
|
|
||||||
|
bool createGroup(const std::string &name,
|
||||||
|
uint32_t circleType,
|
||||||
|
const RsGxsCircleId &circleId,
|
||||||
|
const RsGxsId &authorId,
|
||||||
|
RsGxsGroupId &groupId);
|
||||||
|
|
||||||
|
bool createMsg(const std::string &msgstr,
|
||||||
|
const RsGxsGroupId &groupId,
|
||||||
|
const RsGxsId &authorId,
|
||||||
|
RsGxsMessageId &msgId);
|
||||||
|
|
||||||
|
bool subscribeToGroup(const RsGxsGroupId &groupId, bool subscribe);
|
||||||
|
|
||||||
|
bool getGroups(std::vector<RsTestGroup> &groups);
|
||||||
|
bool getGroupList(std::list<RsGxsGroupId> &groups);
|
||||||
|
bool getMsgList(const RsGxsGroupId &id, std::list<RsGxsMessageId> &msgIds);
|
||||||
|
|
||||||
|
bool getIdentities(std::vector<RsGxsIdGroup> &groups);
|
||||||
|
bool getIdentitiesList(std::list<RsGxsGroupId> &groups);
|
||||||
|
|
||||||
|
bool getCircles(std::vector<RsGxsCircleGroup> &groups);
|
||||||
|
bool getCirclesList(std::list<RsGxsGroupId> &groups);
|
||||||
|
|
||||||
|
uint32_t mUseIdentityService;
|
||||||
uint32_t mTestMode;
|
uint32_t mTestMode;
|
||||||
std::string mGxsDir;
|
std::string mGxsDir;
|
||||||
|
|
||||||
// Id and Circle Interfaces. (NULL for now).
|
FakePgpAuxUtils *mPgpAuxUtils;
|
||||||
RsGxsIdExchange *mGxsIdService;
|
|
||||||
RsGxsCircleExchange *mGxsCircles;
|
p3IdService *mGxsIdService;
|
||||||
|
p3GxsCircles *mGxsCircles;
|
||||||
|
|
||||||
|
RsGeneralDataService* mGxsIdDs;
|
||||||
|
RsGxsNetService* mGxsIdNs;
|
||||||
|
|
||||||
|
RsGeneralDataService* mGxsCirclesDs;
|
||||||
|
RsGxsNetService* mGxsCirclesNs;
|
||||||
|
|
||||||
GxsTestService *mTestService;
|
GxsTestService *mTestService;
|
||||||
RsGeneralDataService* mTestDs;
|
RsGeneralDataService* mTestDs;
|
||||||
@ -29,6 +85,3 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
503
tests/unittests/libretroshare/services/gxs/gxscircle_tests.cc
Normal file
503
tests/unittests/libretroshare/services/gxs/gxscircle_tests.cc
Normal file
@ -0,0 +1,503 @@
|
|||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
// from librssimulator
|
||||||
|
|
||||||
|
// from libretroshare
|
||||||
|
#include "serialiser/rsnxsitems.h"
|
||||||
|
|
||||||
|
// local
|
||||||
|
#include "GxsPairServiceTester.h"
|
||||||
|
#include "GxsPeerNode.h"
|
||||||
|
#include "gxstestservice.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fancy Circle / ID tests.
|
||||||
|
*
|
||||||
|
* 1) Have to create a GxsID-PgpLinked for external Circle tests...
|
||||||
|
* - These take some time to move + be hash checked.
|
||||||
|
*
|
||||||
|
* 2) Have to create Forums with Signed Msgs to make the Authors Move.
|
||||||
|
*
|
||||||
|
* 3) Then we create a bunch of Circles.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test 1: nothing in Groups.... only sync packets.
|
||||||
|
*
|
||||||
|
* This test is rather slow - should speed it up.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//TEST(libretroshare_services, DISABLED_GxsCircles1)
|
||||||
|
TEST(libretroshare_services, GxsCircles1)
|
||||||
|
{
|
||||||
|
time_t starttime = time(NULL);
|
||||||
|
RsGxsCircleId nullCircleId;
|
||||||
|
RsGxsId nullAuthorId;
|
||||||
|
std::list<RsPgpId> nullLocalMembers;
|
||||||
|
std::list<RsGxsId> nullExtMembers;
|
||||||
|
|
||||||
|
RsPeerId p1 = RsPeerId::random();
|
||||||
|
RsPeerId p2 = RsPeerId::random();
|
||||||
|
RsPeerId p3 = RsPeerId::random();
|
||||||
|
RsPeerId p4 = RsPeerId::random();
|
||||||
|
|
||||||
|
/* tweak ids - so that they are easy to ID. */
|
||||||
|
((unsigned char *) p1.toByteArray())[0] = 1;
|
||||||
|
((unsigned char *) p2.toByteArray())[0] = 2;
|
||||||
|
((unsigned char *) p3.toByteArray())[0] = 3;
|
||||||
|
((unsigned char *) p4.toByteArray())[0] = 4;
|
||||||
|
|
||||||
|
std::cerr << "TEST(libretroshare_services, GxsCircles1) PeerIds";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "TIME TO GET HERE: " << time(NULL) - starttime;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "Peer1 : " << p1.toStdString();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "Peer2 : " << p2.toStdString();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "Peer3 : " << p3.toStdString();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "Peer4 : " << p4.toStdString();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
int testMode = 0;
|
||||||
|
|
||||||
|
GxsPairServiceTester tester(p1, p2, p3, p4, testMode, true);
|
||||||
|
GxsPeerNode *peerNode1 = tester.getGxsPeerNode(p1);
|
||||||
|
GxsPeerNode *peerNode2 = tester.getGxsPeerNode(p2);
|
||||||
|
GxsPeerNode *peerNode3 = tester.getGxsPeerNode(p3);
|
||||||
|
GxsPeerNode *peerNode4 = tester.getGxsPeerNode(p4);
|
||||||
|
|
||||||
|
// Standard Filters.
|
||||||
|
|
||||||
|
// create Identities.
|
||||||
|
std::cerr << "TEST(libretroshare_services, GxsCircles1) Create Identities";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "TIME TO GET HERE: " << time(NULL) - starttime;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
RsGxsId gxsId1, gxsId2, gxsId3, gxsId4;
|
||||||
|
EXPECT_TRUE(peerNode1->createIdentity("gxsid1", true, GXS_CIRCLE_TYPE_PUBLIC, nullCircleId, gxsId1));
|
||||||
|
EXPECT_TRUE(peerNode2->createIdentity("gxsid2", true, GXS_CIRCLE_TYPE_PUBLIC, nullCircleId, gxsId2));
|
||||||
|
EXPECT_TRUE(peerNode3->createIdentity("gxsid3", true, GXS_CIRCLE_TYPE_PUBLIC, nullCircleId, gxsId3));
|
||||||
|
EXPECT_TRUE(peerNode4->createIdentity("gxsid4", true, GXS_CIRCLE_TYPE_PUBLIC, nullCircleId, gxsId4));
|
||||||
|
|
||||||
|
std::map<RsPeerId, RsGxsId> NodeIdMap;
|
||||||
|
NodeIdMap[p1] = gxsId1;
|
||||||
|
NodeIdMap[p2] = gxsId2;
|
||||||
|
NodeIdMap[p3] = gxsId3;
|
||||||
|
NodeIdMap[p4] = gxsId4;
|
||||||
|
|
||||||
|
// create Group / Msg (for Id exchange).
|
||||||
|
RsGxsGroupId p1GroupId1;
|
||||||
|
RsGxsMessageId p1g1MsgId1;
|
||||||
|
EXPECT_TRUE(peerNode1->createGroup("p1group1", GXS_CIRCLE_TYPE_PUBLIC, nullCircleId, nullAuthorId, p1GroupId1));
|
||||||
|
EXPECT_TRUE(peerNode1->createMsg("p1g1msg1", p1GroupId1, gxsId1, p1g1MsgId1));
|
||||||
|
std::cerr << "p1->group1 id: " << p1GroupId1;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "p1->group1, msgId: " << p1g1MsgId1;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
// let Group Exchange.
|
||||||
|
std::cerr << "TEST(libretroshare_services, GxsCircles1) Let Groups Exchange";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "TIME TO GET HERE: " << time(NULL) - starttime;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
|
while(counter < 30)
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
tester.tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "TEST(libretroshare_services, GxsCircles1) Checking Group Exchange";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "TIME TO GET HERE: " << time(NULL) - starttime;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
std::list<RsGxsGroupId> p1GroupList;
|
||||||
|
std::list<RsGxsGroupId> p2GroupList;
|
||||||
|
EXPECT_TRUE(peerNode1->getGroupList(p1GroupList));
|
||||||
|
EXPECT_TRUE(peerNode2->getGroupList(p2GroupList));
|
||||||
|
EXPECT_TRUE(p1GroupList.size() == 1);
|
||||||
|
EXPECT_TRUE(p2GroupList.size() == 1);
|
||||||
|
EXPECT_TRUE(p1GroupList.end() != std::find(p1GroupList.begin(), p1GroupList.end(), p1GroupId1));
|
||||||
|
EXPECT_TRUE(p2GroupList.end() != std::find(p2GroupList.begin(), p2GroupList.end(), p1GroupId1));
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
std::vector<RsTestGroup> p1Groups;
|
||||||
|
std::vector<RsTestGroup> p2Groups;
|
||||||
|
EXPECT_TRUE(peerNode1->getGroups(p1Groups));
|
||||||
|
EXPECT_TRUE(peerNode2->getGroups(p2Groups));
|
||||||
|
EXPECT_TRUE(p1Groups.size() == 2);
|
||||||
|
EXPECT_TRUE(p2Groups.size() == 2);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subscribe to Groups - so that we can get a msgs, and reply msg for
|
||||||
|
std::cerr << "TEST(libretroshare_services, GxsCircles1) Subscribing to Groups";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "TIME TO GET HERE: " << time(NULL) - starttime;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
EXPECT_TRUE(peerNode2->subscribeToGroup(p1GroupId1, true));
|
||||||
|
EXPECT_TRUE(peerNode3->subscribeToGroup(p1GroupId1, true));
|
||||||
|
EXPECT_TRUE(peerNode4->subscribeToGroup(p1GroupId1, true));
|
||||||
|
RsGxsMessageId p2g1MsgId2;
|
||||||
|
RsGxsMessageId p3g1MsgId3;
|
||||||
|
RsGxsMessageId p4g1MsgId4;
|
||||||
|
EXPECT_TRUE(peerNode2->createMsg("p2g1msg2", p1GroupId1, gxsId2, p2g1MsgId2));
|
||||||
|
EXPECT_TRUE(peerNode3->createMsg("p3g1msg3", p1GroupId1, gxsId3, p3g1MsgId3));
|
||||||
|
EXPECT_TRUE(peerNode4->createMsg("p4g1msg4", p1GroupId1, gxsId4, p4g1MsgId4));
|
||||||
|
|
||||||
|
// let Group Exchange.
|
||||||
|
std::cerr << "TEST(libretroshare_services, GxsCircles1) Let Groups Exchange";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "TIME TO GET HERE: " << time(NULL) - starttime;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
counter = 0;
|
||||||
|
while(counter < 30)
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
tester.tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now we have setup the basics... GxsIds have been exchanged.
|
||||||
|
// now create some circles....
|
||||||
|
std::cerr << "TEST(libretroshare_services, GxsCircles1) Creating Circles";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "TIME TO GET HERE: " << time(NULL) - starttime;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
// Ext Group, containing everyone, shared publicly.
|
||||||
|
RsGxsGroupId p1c1_circleId;
|
||||||
|
std::list<RsGxsId> p1c1_members;
|
||||||
|
p1c1_members.push_back(gxsId1);
|
||||||
|
p1c1_members.push_back(gxsId2);
|
||||||
|
p1c1_members.push_back(gxsId3);
|
||||||
|
p1c1_members.push_back(gxsId4);
|
||||||
|
EXPECT_TRUE(peerNode1->createCircle("p1c1-EC-public-p1p2p3p4", GXS_CIRCLE_TYPE_PUBLIC,
|
||||||
|
nullCircleId, nullAuthorId, nullLocalMembers, p1c1_members, p1c1_circleId));
|
||||||
|
|
||||||
|
// Ext Group containing p1,p2, shared publicly.
|
||||||
|
RsGxsGroupId p1c2_circleId;
|
||||||
|
std::list<RsGxsId> p1c2_members;
|
||||||
|
p1c2_members.push_back(gxsId1);
|
||||||
|
p1c2_members.push_back(gxsId2);
|
||||||
|
EXPECT_TRUE(peerNode1->createCircle("p1c2-EC-public-p1p2", GXS_CIRCLE_TYPE_PUBLIC,
|
||||||
|
nullCircleId, nullAuthorId, nullLocalMembers, p1c2_members, p1c2_circleId));
|
||||||
|
|
||||||
|
// Ext Group containing p2 (missing creator!) shared publicly.
|
||||||
|
RsGxsGroupId p1c3_circleId;
|
||||||
|
std::list<RsGxsId> p1c3_members;
|
||||||
|
p1c3_members.push_back(gxsId2);
|
||||||
|
EXPECT_TRUE(peerNode1->createCircle("p1c3-EC-public-p2", GXS_CIRCLE_TYPE_PUBLIC,
|
||||||
|
nullCircleId, nullAuthorId, nullLocalMembers, p1c3_members, p1c3_circleId));
|
||||||
|
|
||||||
|
// Ext Group containing p1,p2,p3 shared SELF-REF.
|
||||||
|
RsGxsGroupId p1c4_circleId;
|
||||||
|
std::list<RsGxsId> p1c4_members;
|
||||||
|
p1c4_members.push_back(gxsId1);
|
||||||
|
p1c4_members.push_back(gxsId2);
|
||||||
|
p1c4_members.push_back(gxsId3);
|
||||||
|
EXPECT_TRUE(peerNode1->createCircle("p1c4-EC-self-p1p2p3", GXS_CIRCLE_TYPE_EXT_SELF,
|
||||||
|
nullCircleId, nullAuthorId, nullLocalMembers, p1c4_members, p1c4_circleId));
|
||||||
|
|
||||||
|
// Ext Group containing p1,p2 shared EXT p1c4. (p1,p2,p3).
|
||||||
|
RsGxsGroupId p1c5_circleId;
|
||||||
|
std::list<RsGxsId> p1c5_members;
|
||||||
|
p1c5_members.push_back(gxsId1);
|
||||||
|
p1c5_members.push_back(gxsId2);
|
||||||
|
EXPECT_TRUE(peerNode1->createCircle("p1c5-EC-ext-p1p2", GXS_CIRCLE_TYPE_EXTERNAL,
|
||||||
|
nullCircleId, nullAuthorId, nullLocalMembers, p1c5_members, p1c5_circleId));
|
||||||
|
|
||||||
|
|
||||||
|
// Ext Group containing p1,p4 shared EXT p1c4. (p1,p2,p3).
|
||||||
|
// (does p4 get stuff).
|
||||||
|
RsGxsGroupId p1c6_circleId;
|
||||||
|
std::list<RsGxsId> p1c6_members;
|
||||||
|
p1c6_members.push_back(gxsId1);
|
||||||
|
p1c6_members.push_back(gxsId4);
|
||||||
|
EXPECT_TRUE(peerNode1->createCircle("p1c6-EC-ext-p1p4", GXS_CIRCLE_TYPE_EXTERNAL,
|
||||||
|
nullCircleId, nullAuthorId, nullLocalMembers, p1c6_members, p1c6_circleId));
|
||||||
|
|
||||||
|
std::cerr << "TEST(libretroshare_services, GxsCircles1) Creating Groups";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "TIME TO GET HERE: " << time(NULL) - starttime;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
RsGxsCircleId circleId1(p1c1_circleId.toStdString());
|
||||||
|
RsGxsCircleId circleId2(p1c2_circleId.toStdString());
|
||||||
|
RsGxsCircleId circleId3(p1c3_circleId.toStdString());
|
||||||
|
RsGxsCircleId circleId4(p1c4_circleId.toStdString());
|
||||||
|
RsGxsCircleId circleId5(p1c5_circleId.toStdString());
|
||||||
|
RsGxsCircleId circleId6(p1c6_circleId.toStdString());
|
||||||
|
|
||||||
|
RsGxsGroupId cgId1;
|
||||||
|
RsGxsMessageId cmId1;
|
||||||
|
RsGxsGroupId cgId2;
|
||||||
|
RsGxsMessageId cmId2;
|
||||||
|
RsGxsGroupId cgId3;
|
||||||
|
RsGxsMessageId cmId3;
|
||||||
|
RsGxsGroupId cgId4;
|
||||||
|
RsGxsMessageId cmId4;
|
||||||
|
RsGxsGroupId cgId5;
|
||||||
|
RsGxsMessageId cmId5;
|
||||||
|
RsGxsGroupId cgId6;
|
||||||
|
RsGxsMessageId cmId6;
|
||||||
|
EXPECT_TRUE(peerNode1->createGroup("cgId1", GXS_CIRCLE_TYPE_EXTERNAL, circleId1, nullAuthorId, cgId1));
|
||||||
|
EXPECT_TRUE(peerNode1->createMsg("cmId1", cgId1, gxsId1, cmId1));
|
||||||
|
EXPECT_TRUE(peerNode1->createGroup("cgId2", GXS_CIRCLE_TYPE_EXTERNAL, circleId2, nullAuthorId, cgId2));
|
||||||
|
EXPECT_TRUE(peerNode1->createMsg("cmId2", cgId2, gxsId1, cmId2));
|
||||||
|
EXPECT_TRUE(peerNode1->createGroup("cgId3", GXS_CIRCLE_TYPE_EXTERNAL, circleId3, nullAuthorId, cgId3));
|
||||||
|
EXPECT_TRUE(peerNode1->createMsg("cmId3", cgId3, gxsId1, cmId3));
|
||||||
|
EXPECT_TRUE(peerNode1->createGroup("cgId4", GXS_CIRCLE_TYPE_EXTERNAL, circleId4, nullAuthorId, cgId4));
|
||||||
|
EXPECT_TRUE(peerNode1->createMsg("cmId4", cgId4, gxsId1, cmId4));
|
||||||
|
EXPECT_TRUE(peerNode1->createGroup("cgId5", GXS_CIRCLE_TYPE_EXTERNAL, circleId5, nullAuthorId, cgId5));
|
||||||
|
EXPECT_TRUE(peerNode1->createMsg("cmId5", cgId5, gxsId1, cmId5));
|
||||||
|
EXPECT_TRUE(peerNode1->createGroup("cgId6", GXS_CIRCLE_TYPE_EXTERNAL, circleId6, nullAuthorId, cgId6));
|
||||||
|
EXPECT_TRUE(peerNode1->createMsg("cmId6", cgId6, gxsId1, cmId6));
|
||||||
|
|
||||||
|
// Expected Results.
|
||||||
|
std::map<RsPeerId, std::map<RsGxsGroupId, uint32_t> > mExpectedPeerMsgs;
|
||||||
|
std::list<RsGxsMessageId> emptyList;
|
||||||
|
uint32_t expectedMsgCount = 0;
|
||||||
|
|
||||||
|
// First Group - everyone is subscribed. 4 msgs + 1.
|
||||||
|
expectedMsgCount = 5;
|
||||||
|
mExpectedPeerMsgs[p1][cgId1] = expectedMsgCount;
|
||||||
|
mExpectedPeerMsgs[p2][cgId1] = expectedMsgCount;
|
||||||
|
mExpectedPeerMsgs[p3][cgId1] = expectedMsgCount;
|
||||||
|
mExpectedPeerMsgs[p4][cgId1] = expectedMsgCount;
|
||||||
|
|
||||||
|
// Group 2, p1 & p2. 2 msgs + 1.
|
||||||
|
expectedMsgCount = 3;
|
||||||
|
mExpectedPeerMsgs[p1][cgId2] = expectedMsgCount;
|
||||||
|
mExpectedPeerMsgs[p2][cgId2] = expectedMsgCount;
|
||||||
|
mExpectedPeerMsgs[p3][cgId2] = 0;
|
||||||
|
mExpectedPeerMsgs[p4][cgId2] = 0;
|
||||||
|
|
||||||
|
// Group 3, circle only has p2. but p1 creates. different counts.
|
||||||
|
// i.e. orig not in circle.
|
||||||
|
mExpectedPeerMsgs[p1][cgId3] = 2; // orig + own. (shouldn't receive from p2)
|
||||||
|
mExpectedPeerMsgs[p2][cgId3] = 1; // own (shouldn't accept from p1)
|
||||||
|
mExpectedPeerMsgs[p3][cgId3] = 0;
|
||||||
|
mExpectedPeerMsgs[p4][cgId3] = 0;
|
||||||
|
|
||||||
|
// Group 4, p1,p2,p3: 3 msgs + 1
|
||||||
|
expectedMsgCount = 4;
|
||||||
|
mExpectedPeerMsgs[p1][cgId4] = expectedMsgCount;
|
||||||
|
mExpectedPeerMsgs[p2][cgId4] = expectedMsgCount;
|
||||||
|
mExpectedPeerMsgs[p3][cgId4] = expectedMsgCount;
|
||||||
|
mExpectedPeerMsgs[p4][cgId4] = 0;
|
||||||
|
|
||||||
|
// Group 5, p1 & p2. 2 msgs + 1.
|
||||||
|
expectedMsgCount = 3;
|
||||||
|
mExpectedPeerMsgs[p1][cgId5] = expectedMsgCount;
|
||||||
|
mExpectedPeerMsgs[p2][cgId5] = expectedMsgCount;
|
||||||
|
mExpectedPeerMsgs[p3][cgId5] = 0;
|
||||||
|
mExpectedPeerMsgs[p4][cgId5] = 0;
|
||||||
|
|
||||||
|
// Group 6, circle has p1,p4, but onle shared to p1,p2,p3;
|
||||||
|
// i.e p4 group has unknown circle.
|
||||||
|
//
|
||||||
|
// This is an interesting case...
|
||||||
|
// unknown group - what do we do?
|
||||||
|
mExpectedPeerMsgs[p1][cgId6] = 2; // orig + own. (shouldn't receive from p4)
|
||||||
|
mExpectedPeerMsgs[p2][cgId6] = 0;
|
||||||
|
mExpectedPeerMsgs[p3][cgId6] = 0;
|
||||||
|
mExpectedPeerMsgs[p4][cgId6] = 1; // own
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// let Group Exchange.
|
||||||
|
std::cerr << "TEST(libretroshare_services, GxsCircles1) Let Restricted Groups Exchange";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "TIME TO GET HERE: " << time(NULL) - starttime;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
counter = 0;
|
||||||
|
while(counter < 60)
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
tester.tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "TEST(libretroshare_services, GxsCircles1) Subscribe / Create Msgs.";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "TIME TO GET HERE: " << time(NULL) - starttime;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
{
|
||||||
|
std::list<RsGxsGroupId> p2GroupList;
|
||||||
|
std::list<RsGxsGroupId> p3GroupList;
|
||||||
|
std::list<RsGxsGroupId> p4GroupList;
|
||||||
|
EXPECT_TRUE(peerNode2->getGroupList(p2GroupList));
|
||||||
|
EXPECT_TRUE(peerNode3->getGroupList(p3GroupList));
|
||||||
|
EXPECT_TRUE(peerNode4->getGroupList(p4GroupList));
|
||||||
|
|
||||||
|
std::cerr << "GroupId cgId1: " << cgId1.toStdString();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "GroupId cgId2: " << cgId2.toStdString();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "GroupId cgId3: " << cgId3.toStdString();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "GroupId cgId4: " << cgId4.toStdString();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "GroupId cgId5: " << cgId5.toStdString();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "GroupId cgId6: " << cgId6.toStdString();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::map<RsPeerId, RsGxsId>::iterator nit;
|
||||||
|
for(nit = NodeIdMap.begin(); nit != NodeIdMap.end(); nit++)
|
||||||
|
{
|
||||||
|
GxsPeerNode *peerNode = tester.getGxsPeerNode(nit->first);
|
||||||
|
|
||||||
|
std::list<RsGxsGroupId> groupList;
|
||||||
|
std::list<RsGxsGroupId>::iterator it;
|
||||||
|
EXPECT_TRUE(peerNode->getGroupList(groupList));
|
||||||
|
|
||||||
|
std::cerr << "peer: " << nit->first << " has #Groups: " << groupList.size();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
for(it = groupList.begin(); it != groupList.end(); it++)
|
||||||
|
{
|
||||||
|
std::cerr << "\t groupId: " << *it;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Now we Subscribe / Create a Msg per Group that they have
|
||||||
|
for(nit = NodeIdMap.begin(); nit != NodeIdMap.end(); nit++)
|
||||||
|
{
|
||||||
|
GxsPeerNode *peerNode = tester.getGxsPeerNode(nit->first);
|
||||||
|
|
||||||
|
std::list<RsGxsGroupId> groupList;
|
||||||
|
std::list<RsGxsGroupId>::iterator it;
|
||||||
|
EXPECT_TRUE(peerNode->getGroupList(groupList));
|
||||||
|
|
||||||
|
for(it = groupList.begin(); it != groupList.end(); it++)
|
||||||
|
{
|
||||||
|
RsGxsMessageId msgId;
|
||||||
|
EXPECT_TRUE(peerNode->subscribeToGroup(*it, true));
|
||||||
|
EXPECT_TRUE(peerNode->createMsg("msg", *it, nit->second, msgId));
|
||||||
|
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "Created Msg peer: " << nit->first;
|
||||||
|
std::cerr << " GxsId: " << nit->second;
|
||||||
|
std::cerr << " GroupId: " << *it;
|
||||||
|
std::cerr << " MsgId: " << msgId;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// let Group Exchange.
|
||||||
|
std::cerr << "TEST(libretroshare_services, GxsCircles1) Exchange Restricted Group Messages";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "TIME TO GET HERE: " << time(NULL) - starttime;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
counter = 0;
|
||||||
|
while(counter < 60)
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
tester.tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
std::cerr << "TEST(libretroshare_services, GxsCircles1) Checking Msg Count";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
// Check messages.
|
||||||
|
std::map<RsPeerId, std::map<RsGxsGroupId, uint32_t> >::iterator nit;
|
||||||
|
for(nit = mExpectedPeerMsgs.begin(); nit != mExpectedPeerMsgs.end(); nit++)
|
||||||
|
{
|
||||||
|
std::cerr << "Node Id: " << nit->first;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
GxsPeerNode *peerNode = tester.getGxsPeerNode(nit->first);
|
||||||
|
|
||||||
|
std::map<RsGxsGroupId, uint32_t> &groupMap = nit->second;
|
||||||
|
std::map<RsGxsGroupId, uint32_t>::iterator git;
|
||||||
|
std::list<RsGxsGroupId> groupList;
|
||||||
|
std::list<RsGxsGroupId>::iterator lit;
|
||||||
|
EXPECT_TRUE(peerNode->getGroupList(groupList));
|
||||||
|
|
||||||
|
for(git = groupMap.begin(); git != groupMap.end(); git++)
|
||||||
|
{
|
||||||
|
if (git->second)
|
||||||
|
{
|
||||||
|
/* expect to find it in groupList */
|
||||||
|
lit = std::find(groupList.begin(), groupList.end(), git->first);
|
||||||
|
EXPECT_TRUE(lit != groupList.end());
|
||||||
|
if (lit != groupList.end())
|
||||||
|
{
|
||||||
|
/* check message count */
|
||||||
|
std::list<RsGxsMessageId> msgList;
|
||||||
|
peerNode->getMsgList(git->first, msgList);
|
||||||
|
EXPECT_TRUE(msgList.size() == git->second);
|
||||||
|
|
||||||
|
std::cerr << "\t GroupId: " << git->first;
|
||||||
|
std::cerr << " Expected Msg Count: " << git->second;
|
||||||
|
std::cerr << " Actual Msg Count: " << msgList.size();
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
std::list<RsGxsMessageId>::iterator mit;
|
||||||
|
for(mit = msgList.begin(); mit != msgList.end(); mit++)
|
||||||
|
{
|
||||||
|
std::cerr << "\t\tMsgId: " << *mit;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "\t GroupId: " << git->first;
|
||||||
|
std::cerr << " Error Expected but missing";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lit = std::find(groupList.begin(), groupList.end(), git->first);
|
||||||
|
EXPECT_TRUE(lit == groupList.end());
|
||||||
|
|
||||||
|
if (lit == groupList.end())
|
||||||
|
{
|
||||||
|
std::cerr << "\t GroupId: " << git->first;
|
||||||
|
std::cerr << " Not present - as expected";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "\t GroupId: " << git->first;
|
||||||
|
std::cerr << " ERROR - not expected";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "TIME TO GET HERE: " << time(NULL) - starttime;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
tester.PrintCapturedPackets();
|
||||||
|
}
|
||||||
|
|
@ -61,7 +61,8 @@ uint32_t GxsTestService::testAuthenPolicy(uint32_t testMode)
|
|||||||
|
|
||||||
// Edits generally need an authors signature.
|
// Edits generally need an authors signature.
|
||||||
|
|
||||||
flag = GXS_SERV::MSG_AUTHEN_ROOT_PUBLISH_SIGN | GXS_SERV::MSG_AUTHEN_CHILD_AUTHOR_SIGN;
|
//flag = GXS_SERV::MSG_AUTHEN_ROOT_PUBLISH_SIGN | GXS_SERV::MSG_AUTHEN_CHILD_AUTHOR_SIGN;
|
||||||
|
flag = GXS_SERV::MSG_AUTHEN_ROOT_AUTHOR_SIGN | GXS_SERV::MSG_AUTHEN_CHILD_AUTHOR_SIGN;
|
||||||
RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::PUBLIC_GRP_BITS);
|
RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::PUBLIC_GRP_BITS);
|
||||||
|
|
||||||
flag |= GXS_SERV::MSG_AUTHEN_CHILD_PUBLISH_SIGN;
|
flag |= GXS_SERV::MSG_AUTHEN_CHILD_PUBLISH_SIGN;
|
||||||
@ -226,6 +227,36 @@ bool GxsTestService::submitTestGroup(uint32_t &token, RsTestGroup &group)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RsGenExchange::ServiceCreate_Return GxsTestService::service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& /*keySet*/)
|
||||||
|
{
|
||||||
|
std::cerr << "GxsTestService::service_CreateGroup()";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
RsGxsTestGroupItem *item = dynamic_cast<RsGxsTestGroupItem *>(grpItem);
|
||||||
|
if (!item)
|
||||||
|
{
|
||||||
|
std::cerr << "p3GxsCircles::service_CreateGroup() ERROR invalid cast";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
return SERVICE_CREATE_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cerr << "GxsTestService::service_CreateGroup() Details:";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "GroupId: " << item->meta.mGroupId;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "AuthorId: " << item->meta.mAuthorId;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "CircleType: " << item->meta.mCircleType;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "CircleId: " << item->meta.mCircleId;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "InternalCircle: " << item->meta.mInternalCircle;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
return SERVICE_CREATE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool GxsTestService::submitTestMsg(uint32_t &token, RsTestMsg &msg)
|
bool GxsTestService::submitTestMsg(uint32_t &token, RsTestMsg &msg)
|
||||||
{
|
{
|
||||||
|
@ -75,6 +75,9 @@ virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) ;
|
|||||||
// Overloaded from RsTickEvent.
|
// Overloaded from RsTickEvent.
|
||||||
virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
||||||
|
|
||||||
|
// override for examination of data.
|
||||||
|
virtual RsGenExchange::ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& /*keySet*/);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void service_tick();
|
virtual void service_tick();
|
||||||
@ -87,6 +90,7 @@ virtual bool getRelatedMsgs(const uint32_t &token, std::vector<RsTestMsg> &msgs)
|
|||||||
virtual bool submitTestGroup(uint32_t &token, RsTestGroup &group);
|
virtual bool submitTestGroup(uint32_t &token, RsTestGroup &group);
|
||||||
virtual bool submitTestMsg(uint32_t &token, RsTestMsg &msg);
|
virtual bool submitTestMsg(uint32_t &token, RsTestMsg &msg);
|
||||||
|
|
||||||
|
|
||||||
virtual bool updateTestGroup(uint32_t &token, RsTestGroup &group);
|
virtual bool updateTestGroup(uint32_t &token, RsTestGroup &group);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
* This test is rather slow - should speed it up.
|
* This test is rather slow - should speed it up.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TEST(libretroshare_services, GXS_nxs_basic)
|
TEST(libretroshare_services, DISABLED_GXS_nxs_basic)
|
||||||
{
|
{
|
||||||
RsPeerId ownId = RsPeerId::random();
|
RsPeerId ownId = RsPeerId::random();
|
||||||
RsPeerId friendId = RsPeerId::random();
|
RsPeerId friendId = RsPeerId::random();
|
||||||
@ -88,7 +88,7 @@ TEST(libretroshare_services, GXS_nxs_basic)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TEST(libretroshare_services, GXS_nxs_basic2)
|
TEST(libretroshare_services, DISABLED_GXS_nxs_basic2)
|
||||||
{
|
{
|
||||||
RsPeerId ownId = RsPeerId::random();
|
RsPeerId ownId = RsPeerId::random();
|
||||||
RsPeerId friendId = RsPeerId::random();
|
RsPeerId friendId = RsPeerId::random();
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
// local
|
// local
|
||||||
#include "GxsPairServiceTester.h"
|
#include "GxsPairServiceTester.h"
|
||||||
|
#include "GxsPeerNode.h"
|
||||||
#include "gxstestservice.h"
|
#include "gxstestservice.h"
|
||||||
|
|
||||||
/* Here we want to test the most basic NXS interactions.
|
/* Here we want to test the most basic NXS interactions.
|
||||||
@ -21,13 +22,16 @@
|
|||||||
* This test is rather slow - should speed it up.
|
* This test is rather slow - should speed it up.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
TEST(libretroshare_services, GxsNxsPairExchange1)
|
//TEST(libretroshare_services, GxsNxsPairExchange1)
|
||||||
|
TEST(libretroshare_services, DISABLED_GxsNxsPairExchange1)
|
||||||
{
|
{
|
||||||
RsPeerId p1 = RsPeerId::random();
|
RsPeerId p1 = RsPeerId::random();
|
||||||
RsPeerId p2 = RsPeerId::random();
|
RsPeerId p2 = RsPeerId::random();
|
||||||
int testMode = 0;
|
int testMode = 0;
|
||||||
|
|
||||||
GxsPairServiceTester tester(p1, p2, testMode);
|
GxsPairServiceTester tester(p1, p2, testMode, false);
|
||||||
|
GxsPeerNode *peerNode1 = tester.getGxsPeerNode(p1);
|
||||||
|
GxsPeerNode *peerNode2 = tester.getGxsPeerNode(p2);
|
||||||
|
|
||||||
// we only care about the transaction going one way ...
|
// we only care about the transaction going one way ...
|
||||||
// so drop SyncGrp packets from p2 -> p1.
|
// so drop SyncGrp packets from p2 -> p1.
|
||||||
@ -43,8 +47,86 @@ TEST(libretroshare_services, GxsNxsPairExchange1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// these are currently slow operations.
|
// these are currently slow operations.
|
||||||
tester.createGroup(p2, "group1");
|
|
||||||
tester.createGroup(p2, "group2");
|
RsGxsGroupId p2GroupId1, p2GroupId2;
|
||||||
|
RsGxsCircleId nullCircleId;
|
||||||
|
RsGxsId nullAuthorId;
|
||||||
|
EXPECT_TRUE(peerNode2->createGroup("group1", GXS_CIRCLE_TYPE_PUBLIC, nullCircleId, nullAuthorId, p2GroupId1));
|
||||||
|
EXPECT_TRUE(peerNode2->createGroup("group2", GXS_CIRCLE_TYPE_PUBLIC, nullCircleId, nullAuthorId, p2GroupId2));
|
||||||
|
std::cerr << "p2->group1 id: " << p2GroupId1;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "p2->group2 id: " << p2GroupId2;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
int counter = 0;
|
||||||
|
while((counter < 30))
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
tester.tick();
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<RsGxsGroupId> p1GroupList;
|
||||||
|
std::list<RsGxsGroupId> p2GroupList;
|
||||||
|
EXPECT_TRUE(peerNode1->getGroupList(p1GroupList));
|
||||||
|
EXPECT_TRUE(peerNode2->getGroupList(p2GroupList));
|
||||||
|
EXPECT_TRUE(p1GroupList.size() == 2);
|
||||||
|
EXPECT_TRUE(p2GroupList.size() == 2);
|
||||||
|
EXPECT_TRUE(p1GroupList.end() != std::find(p1GroupList.begin(), p1GroupList.end(), p2GroupId1));
|
||||||
|
EXPECT_TRUE(p1GroupList.end() != std::find(p1GroupList.begin(), p1GroupList.end(), p2GroupId2));
|
||||||
|
EXPECT_TRUE(p2GroupList.end() != std::find(p2GroupList.begin(), p2GroupList.end(), p2GroupId1));
|
||||||
|
EXPECT_TRUE(p2GroupList.end() != std::find(p2GroupList.begin(), p2GroupList.end(), p2GroupId2));
|
||||||
|
|
||||||
|
std::vector<RsTestGroup> p1Groups;
|
||||||
|
std::vector<RsTestGroup> p2Groups;
|
||||||
|
EXPECT_TRUE(peerNode1->getGroups(p1Groups));
|
||||||
|
EXPECT_TRUE(peerNode2->getGroups(p2Groups));
|
||||||
|
EXPECT_TRUE(p1Groups.size() == 2);
|
||||||
|
EXPECT_TRUE(p2Groups.size() == 2);
|
||||||
|
|
||||||
|
tester.PrintCapturedPackets();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Test 2 includes ID & Circle Services.
|
||||||
|
**/
|
||||||
|
|
||||||
|
TEST(libretroshare_services, DISABLED_GxsNxsPairExchange2)
|
||||||
|
//TEST(libretroshare_services, GxsNxsPairExchange2)
|
||||||
|
{
|
||||||
|
RsPeerId p1 = RsPeerId::random();
|
||||||
|
RsPeerId p2 = RsPeerId::random();
|
||||||
|
int testMode = 0;
|
||||||
|
|
||||||
|
GxsPairServiceTester tester(p1, p2, testMode, true);
|
||||||
|
GxsPeerNode *peerNode1 = tester.getGxsPeerNode(p1);
|
||||||
|
GxsPeerNode *peerNode2 = tester.getGxsPeerNode(p2);
|
||||||
|
|
||||||
|
// we only care about the transaction going one way ...
|
||||||
|
// so drop SyncGrp packets from p2 -> p1.
|
||||||
|
|
||||||
|
SetFilter &dropFilter = tester.getDropFilter();
|
||||||
|
dropFilter.setFilterMode(SetFilter::FILTER_PARAMS);
|
||||||
|
dropFilter.setUseSource(true);
|
||||||
|
dropFilter.addSource(p2);
|
||||||
|
{
|
||||||
|
RsNxsSyncGrp *syncGrp = new RsNxsSyncGrp(RS_SERVICE_GXS_TYPE_TEST);
|
||||||
|
dropFilter.setUseFullTypes(true);
|
||||||
|
dropFilter.addFullType(syncGrp->PacketId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// these are currently slow operations.
|
||||||
|
RsGxsGroupId p2GroupId1, p2GroupId2;
|
||||||
|
RsGxsCircleId nullCircleId;
|
||||||
|
RsGxsId nullAuthorId;
|
||||||
|
EXPECT_TRUE(peerNode2->createGroup("group1", GXS_CIRCLE_TYPE_PUBLIC, nullCircleId, nullAuthorId, p2GroupId1));
|
||||||
|
EXPECT_TRUE(peerNode2->createGroup("group2", GXS_CIRCLE_TYPE_PUBLIC, nullCircleId, nullAuthorId, p2GroupId2));
|
||||||
|
std::cerr << "p2->group1 id: " << p2GroupId1;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
std::cerr << "p2->group2 id: " << p2GroupId2;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
while((counter < 60))
|
while((counter < 60))
|
||||||
@ -54,26 +136,17 @@ TEST(libretroshare_services, GxsNxsPairExchange1)
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr << "==========================================================================================";
|
std::list<RsGxsGroupId> p1GroupList;
|
||||||
std::cerr << std::endl;
|
std::list<RsGxsGroupId> p2GroupList;
|
||||||
std::cerr << "#Packets: " << tester.getPacketCount();
|
EXPECT_TRUE(peerNode1->getGroupList(p1GroupList));
|
||||||
std::cerr << std::endl;
|
EXPECT_TRUE(peerNode2->getGroupList(p2GroupList));
|
||||||
|
EXPECT_TRUE(p1GroupList.size() == 2);
|
||||||
|
EXPECT_TRUE(p2GroupList.size() == 2);
|
||||||
|
EXPECT_TRUE(p1GroupList.end() != std::find(p1GroupList.begin(), p1GroupList.end(), p2GroupId1));
|
||||||
|
EXPECT_TRUE(p1GroupList.end() != std::find(p1GroupList.begin(), p1GroupList.end(), p2GroupId2));
|
||||||
|
EXPECT_TRUE(p2GroupList.end() != std::find(p2GroupList.begin(), p2GroupList.end(), p2GroupId1));
|
||||||
|
EXPECT_TRUE(p2GroupList.end() != std::find(p2GroupList.begin(), p2GroupList.end(), p2GroupId2));
|
||||||
|
|
||||||
for(int i = 0; i < tester.getPacketCount(); i++)
|
tester.PrintCapturedPackets();
|
||||||
{
|
|
||||||
SetPacket &pkt = tester.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@ gxs {
|
|||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
TARGET = unittests
|
TARGET = unittests
|
||||||
|
|
||||||
|
OPENPGPSDK_DIR = ../../openpgpsdk/src
|
||||||
|
INCLUDEPATH *= $${OPENPGPSDK_DIR} ../openpgpsdk
|
||||||
|
|
||||||
################################# Linux ##########################################
|
################################# Linux ##########################################
|
||||||
# Put lib dir in QMAKE_LFLAGS so it appears before -L/usr/lib
|
# Put lib dir in QMAKE_LFLAGS so it appears before -L/usr/lib
|
||||||
linux-* {
|
linux-* {
|
||||||
@ -321,11 +324,14 @@ HEADERS += libretroshare/services/gxs/rsgxstestitems.h \
|
|||||||
libretroshare/services/gxs/GxsIsolatedServiceTester.h \
|
libretroshare/services/gxs/GxsIsolatedServiceTester.h \
|
||||||
libretroshare/services/gxs/GxsPeerNode.h \
|
libretroshare/services/gxs/GxsPeerNode.h \
|
||||||
libretroshare/services/gxs/GxsPairServiceTester.h \
|
libretroshare/services/gxs/GxsPairServiceTester.h \
|
||||||
|
libretroshare/services/gxs/FakePgpAuxUtils.h \
|
||||||
|
|
||||||
SOURCES += libretroshare/services/gxs/rsgxstestitems.cc \
|
SOURCES += libretroshare/services/gxs/rsgxstestitems.cc \
|
||||||
libretroshare/services/gxs/gxstestservice.cc \
|
libretroshare/services/gxs/gxstestservice.cc \
|
||||||
libretroshare/services/gxs/GxsIsolatedServiceTester.cc \
|
libretroshare/services/gxs/GxsIsolatedServiceTester.cc \
|
||||||
libretroshare/services/gxs/GxsPeerNode.cc \
|
libretroshare/services/gxs/GxsPeerNode.cc \
|
||||||
libretroshare/services/gxs/GxsPairServiceTester.cc \
|
libretroshare/services/gxs/GxsPairServiceTester.cc \
|
||||||
|
libretroshare/services/gxs/FakePgpAuxUtils.cc \
|
||||||
libretroshare/services/gxs/nxsbasic_test.cc \
|
libretroshare/services/gxs/nxsbasic_test.cc \
|
||||||
libretroshare/services/gxs/nxspair_tests.cc \
|
libretroshare/services/gxs/nxspair_tests.cc \
|
||||||
|
libretroshare/services/gxs/gxscircle_tests.cc \
|
||||||
|
Loading…
Reference in New Issue
Block a user