From 4907d291561aa08815d520503a860f5fd846a6c3 Mon Sep 17 00:00:00 2001 From: chrisparker126 Date: Sat, 19 Apr 2014 10:20:07 +0000 Subject: [PATCH] group sync unit test now working added to .pro file git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7280 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- .../gxs/nxs_test/nxsdummyservices.cc | 1 + .../gxs/nxs_test/nxsgrpsync_test.cc | 1 + .../libretroshare/gxs/nxs_test/nxstesthub.cc | 20 ++++++++++++++++--- .../libretroshare/gxs/nxs_test/nxstesthub.h | 4 ++++ tests/unittests/unittests.pro | 17 ++++++++++------ 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxsdummyservices.cc b/tests/unittests/libretroshare/gxs/nxs_test/nxsdummyservices.cc index 6066b0a8a..3650e5afb 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxsdummyservices.cc +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxsdummyservices.cc @@ -55,5 +55,6 @@ bool rs_nxs_test::RsNxsSimpleDummyReputation::loadReputation(const RsGxsId& id, bool rs_nxs_test::RsNxsSimpleDummyReputation::getReputation(const RsGxsId& id, GixsReputation& rep) { + rep.score = 5; return true; } diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsync_test.cc b/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsync_test.cc index 2c577b8fb..b908fe6f9 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsync_test.cc +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxsgrpsync_test.cc @@ -67,6 +67,7 @@ NxsGrpSync::NxsGrpSync() RsGxsGrpMetaData* meta = new RsGxsGrpMetaData(); init_item(meta); grp->metaData = meta; + meta->mSubscribeFlags = GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED; RsNxsGrp* grp_copy = grp->clone(); diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.cc b/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.cc index 9d996f7a7..c4f5537a4 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.cc +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.cc @@ -188,9 +188,9 @@ void rs_nxs_test::NxsTestHub::Wait(int seconds) { bool rs_nxs_test::NxsTestHub::recvItem(RsRawItem* item, const RsPeerId& peerFrom) { - RsPeerId id = item->PeerId(); - item->PeerId(peerFrom); - return mPeerNxsMap[id]->recv(item); // + PayLoad p(peerFrom, item); + mPayLoad.push(p); + return true; } void rs_nxs_test::NxsTestHub::tick() @@ -199,6 +199,20 @@ void rs_nxs_test::NxsTestHub::tick() PeerNxsMap::iterator it = mPeerNxsMap.begin(); + // deliver payloads to peer's net services + while(!mPayLoad.empty()) + { + PayLoad& p = mPayLoad.front(); + + RsRawItem* item = p.second; + RsPeerId peerFrom = p.first; + RsPeerId peerTo = item->PeerId(); + item->PeerId(peerFrom); + mPeerNxsMap[peerTo]->recv(item); // + mPayLoad.pop(); + } + + // then tick net services for(; it != mPeerNxsMap.end(); it++) { RsGxsNetService::pointer s = it->second; diff --git a/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.h b/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.h index c78fddec6..3c459554f 100644 --- a/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.h +++ b/tests/unittests/libretroshare/gxs/nxs_test/nxstesthub.h @@ -4,6 +4,7 @@ #include "util/rsthreads.h" #include "gxs/rsgxsnetservice.h" #include "nxstestscenario.h" +#include // it would probably be useful if the test scenario // provided the net dummy managers @@ -96,9 +97,12 @@ namespace rs_nxs_test private: + typedef std::pair PayLoad; + typedef std::map PeerNxsMap ; PeerNxsMap mPeerNxsMap; NxsTestScenario::pointer mTestScenario; + std::queue mPayLoad; }; } diff --git a/tests/unittests/unittests.pro b/tests/unittests/unittests.pro index 22344af0b..fc74b9d93 100644 --- a/tests/unittests/unittests.pro +++ b/tests/unittests/unittests.pro @@ -260,12 +260,17 @@ HEADERS += libretroshare/gxs/common/data_support.h \ SOURCES += libretroshare/gxs/common/data_support.cc \ -#HEADERS += libretroshare/gxs/nxs_test/nxstesthub.h \ -# libretroshare/gxs/nxs_test/nxstestscenario.h \ -# -#SOURCES += libretroshare/gxs/nxs_test/nxstesthub.cc \ -# libretroshare/gxs/nxs_test/nxstestscenario.cc \ -# libretroshare/gxs/nxs_test/rsgxsnetservice_test.cc \ +HEADERS += libretroshare/gxs/nxs_test/nxsdummyservices.h \ + libretroshare/gxs/nxs_test/nxsgrpsync_test.h \ + libretroshare/gxs/nxs_test/nxsmsgsync_test.h \ + libretroshare/gxs/nxs_test/nxstesthub.h \ + libretroshare/gxs/nxs_test/nxstestscenario.h + +SOURCES += libretroshare/gxs/nxs_test/nxsdummyservices.cc \ + libretroshare/gxs/nxs_test/nxsgrpsync_test.cc \ + libretroshare/gxs/nxs_test/nxsmsgsync_test.cc \ + libretroshare/gxs/nxs_test/nxstesthub.cc \ + libretroshare/gxs/nxs_test/rsgxsnetservice_test.cc HEADERS += libretroshare/gxs/gen_exchange/genexchangetester.h \ libretroshare/gxs/gen_exchange/gxspublishmsgtest.h \