support for retroshare links in gxs forums

- only group can link at the moment

added more nxs tests and better cleanup
- test ability sync with a delayed circle load 

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7384 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2014-05-27 21:14:05 +00:00
parent 838e263ba3
commit 0dabe4b8a1
25 changed files with 343 additions and 126 deletions

View file

@ -10,8 +10,7 @@
rs_nxs_test::RsNxsSimpleDummyCircles::RsNxsSimpleDummyCircles(
std::list<Membership>& membership, bool cached) {
rs_nxs_test::RsNxsSimpleDummyCircles::RsNxsSimpleDummyCircles() {
}
bool rs_nxs_test::RsNxsSimpleDummyCircles::isLoaded(
@ -101,14 +100,44 @@ bool rs_nxs_test::RsNxsDelayedDummyCircles::allowed(
if(mMembershipCallCount[circleId] >= mCountBeforePresent)
{
mMembershipCallCount[circleId]++;
return true;
return true;
}
else
{
mMembershipCallCount[circleId]++;
return false;
return false;
}
}
const RsPgpId& rs_nxs_test::RsDummyPgpUtils::getPGPOwnId() {
return mOwnId;
}
RsPgpId rs_nxs_test::RsDummyPgpUtils::getPGPId(const RsPeerId& sslid) {
return RsPgpId().random();
}
bool rs_nxs_test::RsDummyPgpUtils::getGPGAllList(std::list<RsPgpId>& ids) {
return true;
}
bool rs_nxs_test::RsDummyPgpUtils::getKeyFingerprint(const RsPgpId& id,
PGPFingerprintType& fp) const {
return true;
}
bool rs_nxs_test::RsDummyPgpUtils::VerifySignBin(const void* data, uint32_t len,
unsigned char* sign, unsigned int signlen,
const PGPFingerprintType& withfingerprint) {
return true;
}
bool rs_nxs_test::RsDummyPgpUtils::askForDeferredSelfSignature(const void* data,
const uint32_t len, unsigned char* sign, unsigned int* signlen,
int& signature_result) {
return true;
}

View file

@ -14,6 +14,7 @@
#include <gxs/rsgixs.h>
#include <gxs/rsgxsnetutils.h>
#include <algorithm>
#include <pgp/pgpauxutils.h>
namespace rs_nxs_test
@ -21,23 +22,18 @@ namespace rs_nxs_test
/*!
* This dummy circles implementation
* allow instantiation with simple membership
* list for a given circle
* This is a dummy circles implementation
*/
class RsNxsSimpleDummyCircles : public RsGcxs
{
public:
typedef std::map<RsGxsCircleId, std::list<RsPgpId> > Membership;
/*!
*
* @param membership
* @param cached
*/
RsNxsSimpleDummyCircles(std::list<Membership>& membership, bool cached);
RsNxsSimpleDummyCircles();
/* GXS Interface - for working out who can receive */
bool isLoaded(const RsGxsCircleId &circleId);
@ -47,9 +43,6 @@ namespace rs_nxs_test
int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id);
bool recipients(const RsGxsCircleId &circleId, std::list<RsPgpId> &friendlist);
private:
std::list<Membership> mMembership;
};
/*!
@ -146,6 +139,24 @@ namespace rs_nxs_test
};
class RsDummyPgpUtils : public PgpAuxUtils
{
public:
virtual ~RsDummyPgpUtils(){}
const RsPgpId &getPGPOwnId() ;
RsPgpId getPGPId(const RsPeerId& sslid) ;
bool getGPGAllList(std::list<RsPgpId> &ids) ;
bool getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const;
bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint);
bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result );
private:
RsPgpId mOwnId;
};
}

View file

@ -15,7 +15,7 @@ using namespace rs_nxs_test;
NxsGrpSync::NxsGrpSync()
NxsGrpSync::NxsGrpSync(RsGcxs* circle, RsGixsReputation* reputation)
{
int numPeers = 2;
@ -42,11 +42,24 @@ NxsGrpSync::NxsGrpSync()
}
RsNxsSimpleDummyReputation::RepMap reMap;
std::list<RsNxsSimpleDummyCircles::Membership> membership;
// now reputation service
mRep = new RsNxsSimpleDummyReputation(reMap, true);
mCircles = new RsNxsSimpleDummyCircles(membership, true);
if(!reputation)
mRep = new RsNxsSimpleDummyReputation(reMap, true);
else
{
mRep = reputation;
}
if(!circle)
mCircles = new RsNxsSimpleDummyCircles();
else
{
mCircles = circle;
}
mPgpUtils = new RsDummyPgpUtils();
// lets create some a group each for all peers
DataMap::iterator mit = mDataServices.begin();
@ -60,7 +73,13 @@ NxsGrpSync::NxsGrpSync()
grp->metaData = meta;
meta->mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED;
RsGxsGroupId grpId = grp->grpId;
if(circle)
{
meta->mCircleType = GXS_CIRCLE_TYPE_EXTERNAL;
meta->mCircleId.random();
}
RsGxsGroupId grpId = grp->grpId;
RsGeneralDataService::GrpStoreMap gsp;
gsp.insert(std::make_pair(grp, meta));
@ -69,8 +88,8 @@ NxsGrpSync::NxsGrpSync()
// 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);
{
mExpectedResult[*it].push_back(grpId);
}
}
@ -126,6 +145,11 @@ RsServiceInfo rs_nxs_test::NxsGrpSync::getServiceInfo() {
return mServInfo;
}
PgpAuxUtils* rs_nxs_test::NxsGrpSync::getDummyPgpUtils()
{
return mPgpUtils;
}
const NxsGrpTestScenario::ExpectedMap& rs_nxs_test::NxsGrpSync::getExpectedMap() {
return mExpectedResult;
}

View file

@ -17,7 +17,7 @@ namespace rs_nxs_test
{
public:
NxsGrpSync();
NxsGrpSync(RsGcxs* circle = NULL, RsGixsReputation* reputation = NULL);
~NxsGrpSync();
void getPeers(std::list<RsPeerId>& peerIds);
@ -27,6 +27,7 @@ namespace rs_nxs_test
RsGixsReputation* getDummyReputations(const RsPeerId& peerId);
uint16_t getServiceType();
RsServiceInfo getServiceInfo();
PgpAuxUtils* getDummyPgpUtils();
protected:
@ -42,6 +43,7 @@ namespace rs_nxs_test
RsGixsReputation* mRep;
RsGcxs* mCircles;
RsServiceInfo mServInfo;
PgpAuxUtils* mPgpUtils;
ExpectedMap mExpectedResult;

View file

@ -0,0 +1,23 @@
/*
* NxsGrpSyncDelayed.cpp
*
* Created on: 19 May 2014
* Author: crispy
*/
#include "nxsgrpsyncdelayed.h"
#include "nxsdummyservices.h"
namespace rs_nxs_test {
NxsGrpSyncDelayed::NxsGrpSyncDelayed()
: NxsGrpSync(new rs_nxs_test::RsNxsDelayedDummyCircles(4), NULL) {
}
NxsGrpSyncDelayed::~NxsGrpSyncDelayed() {
// TODO Auto-generated destructor stub
}
} /* namespace rs_nxs_test */

View file

@ -0,0 +1,22 @@
/*
* NxsGrpSyncDelayed.h
*
* Created on: 19 May 2014
* Author: crispy
*/
#ifndef NXSGRPSYNCDELAYED_H_
#define NXSGRPSYNCDELAYED_H_
#include "nxsgrpsync_test.h"
namespace rs_nxs_test {
class NxsGrpSyncDelayed : public NxsGrpSync {
public:
NxsGrpSyncDelayed();
virtual ~NxsGrpSyncDelayed();
};
} /* namespace rs_nxs_test */
#endif /* NXSGRPSYNCDELAYED_H_ */

View file

@ -35,7 +35,7 @@ bool NxsGrpTestScenario::checkTestPassed()
RsGxsGroupId::std_vector result(expGrpIds.size()+grpIds.size());
std::sort(grpIds.begin(), grpIds.end());
std::sort(expGrpIds.begin(), expGrpIds.end());
RsGxsGroupId::std_vector::iterator it = std::set_difference(grpIds.begin(), grpIds.end(),
RsGxsGroupId::std_vector::iterator it = std::set_symmetric_difference(grpIds.begin(), grpIds.end(),
expGrpIds.begin(), expGrpIds.end(), result.begin());
result.resize(it - result.begin());

View file

@ -17,7 +17,7 @@
using namespace rs_nxs_test;
rs_nxs_test::NxsMsgSync::NxsMsgSync()
{
: mPgpUtils(NULL) {
int numPeers = 2;
// create 2 peers
@ -43,10 +43,9 @@ rs_nxs_test::NxsMsgSync::NxsMsgSync()
}
RsNxsSimpleDummyReputation::RepMap reMap;
std::list<RsNxsSimpleDummyCircles::Membership> membership;
// now reputation service
mRep = new RsNxsSimpleDummyReputation(reMap, true);
mCircles = new RsNxsSimpleDummyCircles(membership, true);
mCircles = new RsNxsSimpleDummyCircles();
// lets create 2 groups and all peers will have them
int nGrps = 2;
@ -146,6 +145,11 @@ RsServiceInfo rs_nxs_test::NxsMsgSync::getServiceInfo() {
return mServInfo;
}
PgpAuxUtils* rs_nxs_test::NxsMsgSync::getDummyPgpUtils()
{
return mPgpUtils;
}
const NxsMsgTestScenario::ExpectedMap& rs_nxs_test::NxsMsgSync::getExpectedMap() {
return mExpectedResult;
}

View file

@ -24,6 +24,7 @@ namespace rs_nxs_test {
RsGixsReputation* getDummyReputations(const RsPeerId& peerId);
uint16_t getServiceType();
RsServiceInfo getServiceInfo();
PgpAuxUtils* getDummyPgpUtils();
protected:
@ -39,6 +40,7 @@ namespace rs_nxs_test {
RsGixsReputation* mRep;
RsGcxs* mCircles;
RsServiceInfo mServInfo;
PgpAuxUtils* mPgpUtils;
NxsMsgTestScenario::ExpectedMap mExpectedResult;

View file

@ -70,7 +70,9 @@ rs_nxs_test::NxsTestHub::NxsTestHub(NxsTestScenario::pointer testScenario)
new NotifyWithPeerId(*cit, *this),
mTestScenario->getServiceInfo(),
mTestScenario->getDummyReputations(*cit),
mTestScenario->getDummyCircles(*cit), NULL, true
mTestScenario->getDummyCircles(*cit),
mTestScenario->getDummyPgpUtils(),
true
)
);
@ -137,8 +139,6 @@ void rs_nxs_test::NxsTestHub::EndTest()
{
mit->second->join();
}
mTestScenario->cleanTestScenario();
}
void rs_nxs_test::NxsTestHub::notifyNewMessages(const RsPeerId& pid,
@ -194,6 +194,11 @@ bool rs_nxs_test::NxsTestHub::recvItem(RsRawItem* item, const RsPeerId& peerFrom
return true;
}
void rs_nxs_test::NxsTestHub::CleanUpTest()
{
mTestScenario->cleanTestScenario();
}
void rs_nxs_test::NxsTestHub::tick()
{
// for each nxs instance pull out all items from each and then move to destination peer

View file

@ -74,6 +74,10 @@ namespace rs_nxs_test
*/
void EndTest();
/*!
* Clean up test environment
*/
void CleanUpTest();
/*!
* @param messages messages are deleted after function returns
*/

View file

@ -37,6 +37,7 @@ namespace rs_nxs_test
virtual RsGixsReputation* getDummyReputations(const RsPeerId& peerId) = 0;
virtual uint16_t getServiceType() = 0;
virtual RsServiceInfo getServiceInfo() = 0;
virtual PgpAuxUtils* getDummyPgpUtils() = 0;
virtual void cleanTestScenario() = 0;

View file

@ -10,6 +10,7 @@
#include "nxsgrpsync_test.h"
#include "nxsmsgsync_test.h"
#include "nxstesthub.h"
#include "nxsgrpsyncdelayed.h"
TEST(libretroshare_gxs, gxs_grp_sync)
{
@ -25,6 +26,25 @@ TEST(libretroshare_gxs, gxs_grp_sync)
ASSERT_TRUE(tHub.testsPassed());
tHub.CleanUpTest();
}
TEST(libretroshare_gxs, gxs_grp_sync_delayed)
{
rs_nxs_test::NxsTestScenario::pointer gsync_test = rs_nxs_test::NxsTestScenario::pointer(
new rs_nxs_test::NxsGrpSyncDelayed());
rs_nxs_test::NxsTestHub tHub(gsync_test);
tHub.StartTest();
// wait for ten seconds
rs_nxs_test::NxsTestHub::Wait(20);
tHub.EndTest();
ASSERT_TRUE(tHub.testsPassed());
tHub.CleanUpTest();
}
TEST(libretroshare_gxs, gxs_msg_sync)
@ -40,4 +60,12 @@ TEST(libretroshare_gxs, gxs_msg_sync)
tHub.EndTest();
ASSERT_TRUE(tHub.testsPassed());
tHub.CleanUpTest();
}
TEST(libretroshare_gxs, gxs_msg_sync_delayed)
{
}