mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
c6059906d0
- not passing yet but almost, more tweaking needed TODO: identity and circle vet test - added retrieve msg id for convenience - updated .pro file git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7303 b45a01b8-16f6-495d-af2f-9b41ad6348cc
136 lines
2.9 KiB
C++
136 lines
2.9 KiB
C++
/*
|
|
* nxsgrpsync_test.cc
|
|
*
|
|
* Created on: 13 Apr 2014
|
|
* Author: crispy
|
|
*/
|
|
|
|
#include "nxsgrpsync_test.h"
|
|
#include "retroshare/rstypes.h"
|
|
#include "gxs/rsdataservice.h"
|
|
#include "nxsdummyservices.h"
|
|
#include "../common/data_support.h"
|
|
|
|
using namespace rs_nxs_test;
|
|
|
|
|
|
|
|
NxsGrpSync::NxsGrpSync()
|
|
{
|
|
|
|
int numPeers = 2;
|
|
|
|
for(int i =0; i < numPeers; i++)
|
|
{
|
|
RsPeerId id = RsPeerId::random();
|
|
mPeerIds.push_back(id);
|
|
}
|
|
|
|
|
|
std::list<RsPeerId>::iterator it = mPeerIds.begin();
|
|
for(; it != mPeerIds.end(); it++)
|
|
{
|
|
// data stores
|
|
RsGeneralDataService* ds = new RsDataService("./", "grp_store_" +
|
|
it->toStdString(), mServType, NULL, "key");
|
|
mDataServices.insert(std::make_pair(*it, ds));
|
|
|
|
// net managers
|
|
std::list<RsPeerId> otherPeers;
|
|
copy_all_but<RsPeerId>(*it, mPeerIds, otherPeers);
|
|
RsNxsNetMgr* mgr = new rs_nxs_test::RsNxsNetDummyMgr(*it, otherPeers);
|
|
mNxsNetMgrs.insert(std::make_pair(*it, mgr));
|
|
|
|
}
|
|
|
|
RsNxsSimpleDummyReputation::RepMap reMap;
|
|
std::list<RsNxsSimpleDummyCircles::Membership> membership;
|
|
// now reputation service
|
|
mRep = new RsNxsSimpleDummyReputation(reMap, true);
|
|
mCircles = new RsNxsSimpleDummyCircles(membership, true);
|
|
|
|
|
|
// lets create some a group each for all peers
|
|
DataMap::iterator mit = mDataServices.begin();
|
|
for(; mit != mDataServices.end(); mit++)
|
|
{
|
|
RsNxsGrp* grp = new RsNxsGrp(mServType);
|
|
|
|
init_item(*grp);
|
|
RsGxsGrpMetaData* meta = new RsGxsGrpMetaData();
|
|
init_item(meta);
|
|
grp->metaData = meta;
|
|
meta->mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED;
|
|
|
|
RsGxsGroupId grpId = grp->grpId;
|
|
|
|
RsGeneralDataService::GrpStoreMap gsp;
|
|
gsp.insert(std::make_pair(grp, meta));
|
|
mit->second->storeGroup(gsp);
|
|
|
|
// the expected result is that each peer has the group of the others
|
|
it = mPeerIds.begin();
|
|
for(; it != mPeerIds.end(); it++)
|
|
{
|
|
mExpectedResult[*it].push_back(grpId);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void NxsGrpSync::getPeers(std::list<RsPeerId>& peerIds)
|
|
{
|
|
peerIds = mPeerIds;
|
|
}
|
|
|
|
|
|
|
|
RsGeneralDataService* NxsGrpSync::getDataService(const RsPeerId& peerId)
|
|
{
|
|
return mDataServices[peerId];
|
|
}
|
|
|
|
RsNxsNetMgr* NxsGrpSync::getDummyNetManager(const RsPeerId& peerId)
|
|
{
|
|
return mNxsNetMgrs[peerId];
|
|
}
|
|
|
|
RsGcxs* NxsGrpSync::getDummyCircles(const RsPeerId& peerId)
|
|
{
|
|
return mCircles;
|
|
}
|
|
|
|
RsGixsReputation* NxsGrpSync::getDummyReputations(const RsPeerId& peerId)
|
|
{
|
|
return mRep;
|
|
}
|
|
|
|
uint16_t NxsGrpSync::getServiceType()
|
|
{
|
|
return mServType;
|
|
}
|
|
|
|
rs_nxs_test::NxsGrpSync::~NxsGrpSync()
|
|
{
|
|
// clean up data stores
|
|
DataMap::iterator mit = mDataServices.begin();
|
|
for(; mit != mDataServices.end(); mit++)
|
|
{
|
|
RsGxsGroupId::std_vector grpIds;
|
|
mit->second->resetDataStore();
|
|
std::string dbFile = "grp_store_" + mit->first.toStdString();
|
|
remove(dbFile.c_str());
|
|
}
|
|
}
|
|
|
|
RsServiceInfo rs_nxs_test::NxsGrpSync::getServiceInfo() {
|
|
return mServInfo;
|
|
}
|
|
|
|
const NxsGrpTestScenario::ExpectedMap& rs_nxs_test::NxsGrpSync::getExpectedMap() {
|
|
return mExpectedResult;
|
|
}
|
|
|
|
|