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

@ -933,14 +933,12 @@ void SetForegroundWindowInternal(HWND hWnd)
case Messages:
_instance->ui->stackPages->setCurrentPage( _instance->messagesDialog );
break;
#if 0
case Channels:
_instance->ui->stackPages->setCurrentPage( _instance->channelFeed );
_instance->ui->stackPages->setCurrentPage( _instance->gxschannelDialog );
return true ;
case Forums:
_instance->ui->stackPages->setCurrentPage( _instance->forumsDialog );
return true ;
#endif
_instance->ui->stackPages->setCurrentPage( _instance->gxsforumDialog );
return true ;
#ifdef BLOGS
case Blogs:
Page = _instance->blogsFeed;
@ -1029,12 +1027,10 @@ void SetForegroundWindowInternal(HWND hWnd)
case Links:
return _instance->linksDialog;
#endif
#if 0
case Channels:
return _instance->channelFeed;
return _instance->gxschannelDialog;
case Forums:
return _instance->forumsDialog;
#endif
return _instance->gxsforumDialog;
#ifdef BLOGS
case Blogs:
return _instance->blogsFeed;

View File

@ -87,8 +87,8 @@ public:
Transfers = 3, /** Transfers page. */
SharedDirectories = 4, /** Shared Directories page. */
Messages = 5, /** Messages page. */
// Channels = 6, /** Channels page. */
// Forums = 7, /** Forums page. */
Channels = 6, /** Channels page. */
Forums = 7, /** Forums page. */
Search = 8, /** Search page. */
#ifdef BLOGS
Blogs = 9, /** Blogs page. */

View File

@ -36,8 +36,7 @@
#include "RetroShareLink.h"
#include "MainWindow.h"
//#include "ForumsDialog.h"
//#include "ChannelFeed.h"
#include "gui/gxsforums/GxsForumsDialog.h"
#include "SearchDialog.h"
#include "msgs/MessageComposer.h"
#include "util/misc.h"
@ -51,7 +50,7 @@
#include <retroshare/rsmsgs.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsidentity.h>
//#include <retroshare/rschannels.h>
#include <retroshare/rsgxsforums.h>
//#define DEBUG_RSLINK 1
@ -543,6 +542,33 @@ bool RetroShareLink::createChannel(const std::string &id, const std::string &msg
return valid();
}
bool RetroShareLink::createGxsLink(const RsGxsGroupId &id, const RsGxsMessageId &msgId,
const std::string& groupName, const std::string& msgSubject,
const RetroShareLink::enumType &linkType)
{
clear();
if (!id.isNull()) {
_hash = QString::fromStdString(id.toStdString());
if(!msgId.isNull())
_msgId = QString::fromStdString(msgId.toStdString());
_type = linkType;
if (msgId.isNull()) {
_name = QString::fromStdString(groupName);
} else {
_name = QString::fromStdString(msgSubject);
}
}
check();
return valid();
}
bool RetroShareLink::createSearch(const QString& keywords)
{
clear();
@ -1402,38 +1428,21 @@ static void processList(const QStringList &list, const QString &textSingular, co
break;
}
#if 0
case TYPE_FORUM:
{
#ifdef DEBUG_RSLINK
std::cerr << " RetroShareLink::process ForumRequest : name : " << link.name().toStdString() << ". id : " << link.hash().toStdString() << ". msgId : " << link.msgId().toStdString() << std::endl;
#endif
ForumInfo fi;
if (!rsForums->getForumInfo(link.id().toStdString(), fi)) {
if (link.msgId().isEmpty()) {
forumUnknown.append(link.name());
} else {
forumMsgUnknown.append(link.name());
}
break;
}
ForumMsgInfo msg;
if (!link.msgId().isEmpty()) {
if (!rsForums->getForumMessage(fi.forumId, link.msgId().toStdString(), msg)) {
forumMsgUnknown.append(link.name());
break;
}
}
MainWindow::showWindow(MainWindow::Forums);
ForumsDialog *forumsDialog = dynamic_cast<ForumsDialog*>(MainWindow::getPage(MainWindow::Forums));
MainWindow::showWindow(MainWindow::Forums);
GxsForumsDialog *forumsDialog = dynamic_cast<GxsForumsDialog*>(MainWindow::getPage(MainWindow::Forums));
if (!forumsDialog) {
return false;
}
if (forumsDialog->navigate(fi.forumId, msg.msgId)) {
if (forumsDialog->navigate(RsGxsGroupId(link.id().toStdString()), RsGxsMessageId(link.msgId().toStdString()))) {
if (link.msgId().isEmpty()) {
forumFound.append(link.name());
} else {
@ -1448,7 +1457,7 @@ static void processList(const QStringList &list, const QString &textSingular, co
}
break;
}
#if 0
case TYPE_CHANNEL:
{
#ifdef DEBUG_RSLINK

View File

@ -66,7 +66,7 @@ class RetroShareLink
TYPE_CERTIFICATE = 0x07,
TYPE_EXTRAFILE = 0x08,
TYPE_PRIVATE_CHAT = 0x09,
TYPE_PUBLIC_MSG = 0x0a
TYPE_PUBLIC_MSG = 0x0a
};
public:
@ -79,6 +79,9 @@ class RetroShareLink
bool createPerson(const RsPgpId &id);
bool createForum(const std::string& id, const std::string& msgId);
bool createChannel(const std::string& id, const std::string& msgId);
bool createGxsLink(const RsGxsGroupId &id, const RsGxsMessageId &msgId,
const std::string& groupName, const std::string& msgSubject,
const RetroShareLink::enumType &linkType);
bool createSearch(const QString& keywords);
bool createMessage(const RsPeerId &peerId, const QString& subject);
bool createMessage(const RsGxsId &peerId, const QString& subject);
@ -99,13 +102,13 @@ class RetroShareLink
const QString& SSLId() const { return _SSLid ; }
const QString& GPGId() const { return _GPGid ; }
const QString& localIPAndPort() const { return _loc_ip_port ; }
const QString& externalIPAndPort() const { return _ext_ip_port ; }
const QString& dyndns() const { return _dyndns_name ; }
const QString& location() const { return _location ; }
const QString& radix() const { return _radix ; }
time_t timeStamp() const { return _time_stamp ; }
const QString& encryptedPrivateChatInfo() const { return _encrypted_chat_info ; }
QString title() const;
const QString& externalIPAndPort() const { return _ext_ip_port ; }
const QString& dyndns() const { return _dyndns_name ; }
const QString& location() const { return _location ; }
const QString& radix() const { return _radix ; }
time_t timeStamp() const { return _time_stamp ; }
const QString& encryptedPrivateChatInfo() const { return _encrypted_chat_info ; }
QString title() const;
unsigned int subType() const { return _subType; }
void setSubType(unsigned int subType) { _subType = subType; }
@ -157,13 +160,13 @@ class RetroShareLink
QString _GPGBase64String ; // GPG Cert
QString _GPGBase64CheckSum ; // GPG Cert
QString _location ; // location
QString _ext_ip_port ;
QString _loc_ip_port ;
QString _dyndns_name ;
QString _radix ;
QString _encrypted_chat_info ; // encrypted data string for the recipient of a chat invite
time_t _time_stamp ; // time stamp at which the link will expire.
QString _ext_ip_port ;
QString _loc_ip_port ;
QString _dyndns_name ;
QString _radix ;
QString _encrypted_chat_info ; // encrypted data string for the recipient of a chat invite
time_t _time_stamp ; // time stamp at which the link will expire.
unsigned int _subType; // for general use as sub type for _type (RSLINK_SUBTYPE_...)
};

View File

@ -457,6 +457,21 @@ RSTreeWidget *GroupTreeWidget::treeWidget()
return ui->treeWidget;
}
bool GroupTreeWidget::getGroupName(QString id, QTreeWidgetItem* categoryItem, QString& name)
{
int childCount = categoryItem->childCount();
for (int child = 0; child < childCount; child++) {
QTreeWidgetItem *childItem = categoryItem->child(child);
if (childItem->data(COLUMN_DATA, ROLE_ID).toString() == id) {
/* Found child */
name = childItem->text(COLUMN_NAME);
return true;
}
}
return false;
}
int GroupTreeWidget::subscribeFlags(const QString &id)
{
QTreeWidgetItem *item = getItemFromId(id);

View File

@ -98,6 +98,7 @@ public:
void setTextColorCategory(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_CATEGORY] = color; }
void setTextColorPrivateKey(QColor color) { mTextColor[GROUPTREEWIDGET_COLOR_PRIVATEKEY] = color; }
bool getGroupName(QString id, QTreeWidgetItem* item, QString& name);
int subscribeFlags(const QString &id);

View File

@ -26,6 +26,7 @@
#include "gui/gxs/RsGxsUpdateBroadcastBase.h"
#include <iostream>
#include <algorithm>
/**
* #define DEBUG_ITEM 1

View File

@ -351,25 +351,48 @@ void GxsGroupFrameDialog::copyGroupLink()
return;
}
// THIS CODE CALLS getForumInfo() to verify that the Ids are valid.
// As we are switching to Request/Response this is now harder to do...
// So not bothering any more - shouldn't be necessary.
// IF we get errors - fix them, rather than patching here.
#if 0
ForumInfo fi;
if (rsGxsForums->getForumInfo(mCurrForumId, fi)) {
RetroShareLink link;
if (link.createForum(fi.forumId, "")) {
QList<RetroShareLink> urls;
urls.push_back(link);
RSLinkClipboard::copyLinks(urls);
}
}
#endif
RetroShareLink link;
QMessageBox::warning(this, "RetroShare", "ToDo");
QString name;
if(!getCurrentGroupName(name)) return;
if (link.createGxsLink(mGroupId, RsGxsMessageId(), name.toStdString(), "", getLinkType())) {
QList<RetroShareLink> urls;
urls.push_back(link);
RSLinkClipboard::copyLinks(urls);
}
}
bool GxsGroupFrameDialog::getCurrentGroupName(QString& name)
{
GroupTreeWidget* gtw = ui->groupTreeWidget;
QString id = QString::fromStdString(mGroupId.toStdString());
if(gtw->getGroupName(id, mYourGroups, name))
{
return true;
}
else if(gtw->getGroupName(id, mSubscribedGroups, name))
{
return true;
}
else if(gtw->getGroupName(id, mYourGroups, name))
{
return true;
}
else if(gtw->getGroupName(id, mOtherGroups, name))
{
return true;
}
return false;
}
void GxsGroupFrameDialog::markMsgAsRead()
{
GxsMessageFrameWidget *msgWidget = messageWidget(mGroupId, false);
@ -429,44 +452,44 @@ void GxsGroupFrameDialog::loadComment(const RsGxsGroupId &grpId, const RsGxsMess
ui->messageTabWidget->setCurrentWidget(commentDialog);
}
bool GxsGroupFrameDialog::navigate(const RsGxsGroupId groupId, const std::string& msgId)
bool GxsGroupFrameDialog::navigate(const RsGxsGroupId groupId, const RsGxsMessageId& msgId)
{
if (groupId.isNull()) {
return false;
}
if (ui->groupTreeWidget->activateId(QString::fromStdString(groupId.toStdString()), msgId.empty()) == NULL) {
if (ui->groupTreeWidget->activateId(QString::fromStdString(groupId.toStdString()), msgId.isNull()) == NULL) {
return false;
}
if (mGroupId != groupId) {
return false;
}
if (msgId.empty()) {
return true;
}
//#TODO
// if (mThreadLoading) {
// mThreadLoad.FocusMsgId = msgId;
}
// if (mGroupId == groupId) {
// return false;
// }
//
// if (msgId.isNull()) {
// return true;
// }
/* Search exisiting item */
// QTreeWidgetItemIterator itemIterator(ui->threadTreeWidget);
// QTreeWidgetItem *item = NULL;
// while ((item = *itemIterator) != NULL) {
// itemIterator++;
// if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == msgId) {
// ui->threadTreeWidget->setCurrentItem(item);
// ui->threadTreeWidget->setFocus();
// return true;
// }
// }
//#TODO
// if (mThreadLoading) {
// mThreadLoad.FocusMsgId = msgId;
// return true;
// }
return false;
/* Search exisiting item */
// QTreeWidgetItemIterator itemIterator(ui->threadTreeWidget);
// QTreeWidgetItem *item = NULL;
// while ((item = *itemIterator) != NULL) {
// itemIterator++;
//
// if (item->data(COLUMN_THREAD_DATA, ROLE_THREAD_MSGID).toString().toStdString() == msgId) {
// ui->threadTreeWidget->setCurrentItem(item);
// ui->threadTreeWidget->setFocus();
// return true;
// }
// }
return true;
}
GxsMessageFrameWidget *GxsGroupFrameDialog::messageWidget(const RsGxsGroupId &groupId, bool ownTab)

View File

@ -24,6 +24,7 @@
#include "gui/gxs/RsGxsUpdateBroadcastPage.h"
#include "RsAutoUpdatePage.h"
#include "gui/RetroShareLink.h"
#include <inttypes.h>
@ -71,7 +72,7 @@ public:
GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent = 0);
~GxsGroupFrameDialog();
bool navigate(const RsGxsGroupId groupId, const std::string& msgId);
bool navigate(const RsGxsGroupId groupId, const RsGxsMessageId& msgId);
// Callback for all Loads.
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
@ -81,8 +82,10 @@ protected:
virtual void updateDisplay(bool complete);
RsGxsGroupId groupId() { return mGroupId; }
void setSingleTab(bool singleTab);
bool getCurrentGroupName(QString& name);
virtual RetroShareLink::enumType getLinkType() = 0;
private slots:
void todo();
@ -119,6 +122,7 @@ private:
virtual QString text(TextType type) = 0;
virtual QString icon(IconType type) = 0;
virtual QString settingsGroupName() = 0;
virtual GxsGroupDialog *createNewGroupDialog(TokenQueue *tokenQueue) = 0;
virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId) = 0;
virtual int shareKeyType() = 0;

View File

@ -41,7 +41,8 @@ public:
virtual QString helpText() const { return ""; } //MainPage
// virtual UserNotify *getUserNotify(QObject *parent);
protected:
RetroShareLink::enumType getLinkType() { return RetroShareLink::TYPE_CHANNEL; }
private slots:
void settingsChanged();
void toggleAutoDownload();

View File

@ -80,6 +80,11 @@ QString GxsForumsDialog::text(TextType type)
return "";
}
RetroShareLink::enumType GxsForumsDialog::getLinkType()
{
return RetroShareLink::TYPE_FORUM;
}
QString GxsForumsDialog::icon(IconType type)
{
switch (type) {

View File

@ -40,6 +40,10 @@ public:
// virtual UserNotify *getUserNotify(QObject *parent);
protected:
RetroShareLink::enumType getLinkType();
private slots:
void settingsChanged();

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)
{
}