mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-21 23:40:26 -04:00
Merged branch v0.5-gxs-b1 into trunk (from -r 5351 -> 5995)
This brings a huge amount of goodness into the trunk, but there is still a big chunk todo before it can be released. * GXS Backend. * GXS Services: - Identities. - Circles - Photos - Wiki - GxsForums - Posted. * SSH no-gui server. See branch commits for more info. To switch on GXS stuff, enable CONFIG += gxs in both libretroshare.pro and retroshare-gui.pro git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5996 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
commit
069b72e0b2
549 changed files with 111171 additions and 25579 deletions
|
@ -62,9 +62,8 @@ void init_item(RsGxsGrpMetaData* metaGrp)
|
|||
randString(SHORT_STR, metaGrp->mAuthorId);
|
||||
randString(SHORT_STR, metaGrp->mGroupName);
|
||||
|
||||
init_item(metaGrp->adminSign);
|
||||
init_item(metaGrp->signSet);
|
||||
init_item(metaGrp->keys);
|
||||
init_item(metaGrp->idSign);
|
||||
|
||||
metaGrp->mPublishTs = rand()%3452;
|
||||
metaGrp->mGroupFlags = rand()%43;
|
||||
|
@ -87,8 +86,7 @@ void init_item(RsGxsMsgMetaData* metaMsg)
|
|||
randString(SHORT_STR, metaMsg->mOrigMsgId);
|
||||
randString(SHORT_STR, metaMsg->mMsgName);
|
||||
|
||||
init_item(metaMsg->pubSign);
|
||||
init_item(metaMsg->idSign);
|
||||
init_item(metaMsg->signSet);
|
||||
|
||||
metaMsg->mPublishTs = rand()%313;
|
||||
metaMsg->mMsgFlags = rand()%224;
|
||||
|
|
1965
libretroshare/src/tests/gxs/genexchangetester.cpp
Normal file
1965
libretroshare/src/tests/gxs/genexchangetester.cpp
Normal file
File diff suppressed because it is too large
Load diff
123
libretroshare/src/tests/gxs/genexchangetester.h
Normal file
123
libretroshare/src/tests/gxs/genexchangetester.h
Normal file
|
@ -0,0 +1,123 @@
|
|||
#ifndef GENEXCHANGETESTER_H
|
||||
#define GENEXCHANGETESTER_H
|
||||
|
||||
#include "genexchangetestservice.h"
|
||||
#include "gxs/rsgds.h"
|
||||
#include "gxs/rsnxs.h"
|
||||
#include "gxs/gxscoreserver.h"
|
||||
|
||||
bool operator ==(const RsMsgMetaData& lMeta, const RsMsgMetaData& rMeta);
|
||||
bool operator ==(const RsDummyMsg& lMsg, const RsDummyMsg& rMsg);
|
||||
|
||||
bool operator ==(const RsGroupMetaData& lMeta, const RsGroupMetaData& rMeta);
|
||||
bool operator ==(const RsDummyGrp& lMsg, const RsDummyGrp& rMsg);
|
||||
|
||||
/*!
|
||||
* The job of the service tester is to send dummy msg items to the GenExchange service
|
||||
* and then retrieve them (ignoring ackowledge message)
|
||||
* Also it modifies local meta items and check if it worked out
|
||||
*/
|
||||
class GenExchangeTester
|
||||
{
|
||||
public:
|
||||
|
||||
void pollForToken(uint32_t, const RsTokReqOptions& opts);
|
||||
|
||||
GenExchangeTester();
|
||||
|
||||
// message tests
|
||||
bool testMsgSubmissionRetrieval();
|
||||
bool testMsgIdRetrieval();
|
||||
bool testMsgIdRetrieval_OptParents();
|
||||
bool testMsgIdRetrieval_OptOrigMsgId();
|
||||
bool testMsgIdRetrieval_OptLatest();
|
||||
bool testSpecificMsgMetaRetrieval();
|
||||
|
||||
// request msg related tests
|
||||
bool testMsgRelatedChildIdRetrieval();
|
||||
bool testMsgRelatedChildDataRetrieval();
|
||||
bool testMsgRelatedChildDataRetrieval_Multi();
|
||||
bool testMsgAllVersions();
|
||||
|
||||
|
||||
// group tests
|
||||
bool testGrpSubmissionRetrieval();
|
||||
bool testSpecificGrpRetrieval();
|
||||
bool testGrpIdRetrieval();
|
||||
bool testGrpMetaRetrieval();
|
||||
|
||||
bool testGrpMetaModRequest();
|
||||
bool testMsgMetaModRequest();
|
||||
|
||||
|
||||
// testing verification (publish).
|
||||
// Strategy is
|
||||
// inject a group which you only have the public signature for
|
||||
// The injection can be done via
|
||||
|
||||
private:
|
||||
|
||||
// to be called at start
|
||||
void setUp();
|
||||
|
||||
// and at end of test routines, resets db and clears out maps
|
||||
void breakDown();
|
||||
|
||||
|
||||
void setUpGrps(uint32_t grpFlag=0); // to be called at start of msg tests
|
||||
|
||||
/*!
|
||||
* Can be called at start grpId or grpMeta test
|
||||
* to help out
|
||||
* ids are store is mGrpIdsOut
|
||||
*/
|
||||
void setUpLargeGrps(uint32_t nGrps);
|
||||
|
||||
void storeMsgData(GxsMsgDataMap& msgData);
|
||||
void storeMsgMeta(GxsMsgMetaMap& msgMetaData);
|
||||
void storeMsgIds(GxsMsgIdResult& msgIds);
|
||||
|
||||
void storeGrpData(std::vector<RsGxsGrpItem*>& grpData);
|
||||
void storeGrpMeta(std::list<RsGroupMetaData>& grpMetaData);
|
||||
void storeGrpId(std::list<RsGxsGroupId>& grpIds);
|
||||
|
||||
void init(RsDummyGrp* grpItem) const;
|
||||
void init(RsGroupMetaData&) const;
|
||||
void init(RsDummyMsg* msgItem) const;
|
||||
void init(RsMsgMetaData&) const;
|
||||
|
||||
uint32_t randNum() const;
|
||||
private:
|
||||
|
||||
void createMsgs(std::vector<RsDummyMsg*>& msgs, int nMsgs) const;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
RsMutex mGenTestMutex;
|
||||
|
||||
std::vector<RsGxsGrpItem*> mGrpDataOut, mGrpDataIn;
|
||||
std::list<RsGroupMetaData> mGrpMetaDataOut, mGrpMetaDataIn;
|
||||
std::list<RsGxsGroupId> mGrpIdsOut, mGrpIdsIn;
|
||||
|
||||
GxsMsgDataMap mMsgDataOut, mMsgDataIn;
|
||||
GxsMsgMetaMap mMsgMetaDataOut, mMsgMetaDataIn;
|
||||
GxsMsgIdResult mMsgIdsOut, mMsgIdsIn;
|
||||
|
||||
MsgRelatedIdResult mMsgRelatedIdsOut, mMsgRelatedIdsIn;
|
||||
GxsMsgRelatedDataMap mMsgRelatedDataMapOut, mMsgRelatedDataMapIn;
|
||||
|
||||
std::vector<RsGxsGroupId> mRandGrpIds; // ids that exist to help group testing
|
||||
|
||||
private:
|
||||
|
||||
GenExchangeTestService* mTestService;
|
||||
RsTokenService* mTokenService;
|
||||
|
||||
RsNetworkExchangeService* mNxs;
|
||||
RsGeneralDataService* mDataStore;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // GENEXCHANGETESTER_H
|
93
libretroshare/src/tests/gxs/genexchangetestservice.cpp
Normal file
93
libretroshare/src/tests/gxs/genexchangetestservice.cpp
Normal file
|
@ -0,0 +1,93 @@
|
|||
#include "genexchangetestservice.h"
|
||||
|
||||
GenExchangeTestService::GenExchangeTestService(RsGeneralDataService *dataServ, RsNetworkExchangeService * netService,
|
||||
RsGixs* gixs, uint32_t authenPolicy)
|
||||
: RsGenExchange(dataServ, netService, new RsDummySerialiser(), RS_SERVICE_TYPE_DUMMY, gixs, authenPolicy)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void GenExchangeTestService::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void GenExchangeTestService::publishDummyGrp(uint32_t &token, RsDummyGrp *grp)
|
||||
{
|
||||
publishGroup(token, grp);
|
||||
}
|
||||
|
||||
void GenExchangeTestService::publishDummyMsg(uint32_t &token, RsDummyMsg *msg)
|
||||
{
|
||||
publishMsg(token, msg);
|
||||
}
|
||||
|
||||
bool GenExchangeTestService::getGroupListTS(const uint32_t &token, std::list<RsGxsGroupId> &groupIds)
|
||||
{
|
||||
return getGroupList(token, groupIds);
|
||||
}
|
||||
|
||||
bool GenExchangeTestService::getGroupMetaTS(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo)
|
||||
{
|
||||
return getGroupMeta(token, groupInfo);
|
||||
}
|
||||
|
||||
bool GenExchangeTestService::getGroupDataTS(const uint32_t &token, std::vector<RsGxsGrpItem *> &grpItem)
|
||||
{
|
||||
return getGroupData(token, grpItem);
|
||||
}
|
||||
|
||||
bool GenExchangeTestService::getMsgDataTS(const uint32_t &token, GxsMsgDataMap &msgItems)
|
||||
{
|
||||
return getMsgData(token, msgItems);
|
||||
}
|
||||
|
||||
bool GenExchangeTestService::getMsgRelatedDataTS(const uint32_t &token, GxsMsgRelatedDataMap &msgItems)
|
||||
{
|
||||
return getMsgRelatedData(token, msgItems);
|
||||
}
|
||||
|
||||
bool GenExchangeTestService::getMsgMetaTS(const uint32_t &token, GxsMsgMetaMap &msgInfo)
|
||||
{
|
||||
return getMsgMeta(token, msgInfo);
|
||||
}
|
||||
|
||||
bool GenExchangeTestService::getMsgListTS(const uint32_t &token, GxsMsgIdResult &msgIds)
|
||||
{
|
||||
return getMsgList(token, msgIds);
|
||||
}
|
||||
|
||||
bool GenExchangeTestService::getMsgRelatedListTS(const uint32_t &token, MsgRelatedIdResult &msgIds)
|
||||
{
|
||||
return getMsgRelatedList(token, msgIds);
|
||||
}
|
||||
|
||||
void GenExchangeTestService::setGroupServiceStringTS(uint32_t &token, const RsGxsGroupId &grpId, const std::string &servString)
|
||||
{
|
||||
RsGenExchange::setGroupServiceString(token, grpId, servString);
|
||||
}
|
||||
|
||||
void GenExchangeTestService::setGroupStatusFlagTS(uint32_t &token, const RsGxsGroupId &grpId, const uint32_t &status, const uint32_t& mask)
|
||||
{
|
||||
RsGenExchange::setGroupStatusFlags(token, grpId, status, mask);
|
||||
}
|
||||
|
||||
void GenExchangeTestService::setGroupSubscribeFlagTS(uint32_t &token, const RsGxsGroupId &grpId, const uint32_t &status, const uint32_t& mask)
|
||||
{
|
||||
RsGenExchange::setGroupSubscribeFlags(token, grpId, status, mask);
|
||||
}
|
||||
|
||||
void GenExchangeTestService::setMsgServiceStringTS(uint32_t &token, const RsGxsGrpMsgIdPair &msgId, const std::string &servString)
|
||||
{
|
||||
RsGenExchange::setMsgServiceString(token, msgId, servString);
|
||||
}
|
||||
|
||||
void GenExchangeTestService::setMsgStatusFlagTS(uint32_t &token, const RsGxsGrpMsgIdPair &msgId, const uint32_t &status, const uint32_t& mask)
|
||||
{
|
||||
RsGenExchange::setMsgStatusFlags(token, msgId, status, mask);
|
||||
}
|
||||
|
||||
void GenExchangeTestService::service_tick()
|
||||
{
|
||||
|
||||
}
|
93
libretroshare/src/tests/gxs/genexchangetestservice.h
Normal file
93
libretroshare/src/tests/gxs/genexchangetestservice.h
Normal file
|
@ -0,0 +1,93 @@
|
|||
#ifndef GENEXCHANGETESTSERVICE_H
|
||||
#define GENEXCHANGETESTSERVICE_H
|
||||
|
||||
#include "gxs/rsgenexchange.h"
|
||||
#include "gxs/rsgxsifaceimpl.h"
|
||||
#include "rsdummyservices.h"
|
||||
|
||||
class GenExchangeTestService : public RsGenExchange
|
||||
{
|
||||
public:
|
||||
GenExchangeTestService(RsGeneralDataService* dataServ, RsNetworkExchangeService*, RsGixs* gixs, uint32_t authenPolicy);
|
||||
|
||||
void notifyChanges(std::vector<RsGxsNotify*>& changes);
|
||||
|
||||
void publishDummyGrp(uint32_t& token, RsDummyGrp* grp);
|
||||
void publishDummyMsg(uint32_t& token, RsDummyMsg* msg);
|
||||
|
||||
|
||||
/*!
|
||||
* Retrieve group list for a given token
|
||||
* @param token
|
||||
* @param groupIds
|
||||
* @return false if token cannot be redeemed, if false you may have tried to redeem when not ready
|
||||
*/
|
||||
bool getGroupListTS(const uint32_t &token, std::list<RsGxsGroupId> &groupIds);
|
||||
|
||||
/*!
|
||||
* Retrieve msg list for a given token sectioned by group Ids
|
||||
* @param token token to be redeemed
|
||||
* @param msgIds a map of grpId -> msgList (vector)
|
||||
*/
|
||||
bool getMsgListTS(const uint32_t &token, GxsMsgIdResult &msgIds);
|
||||
|
||||
|
||||
/*!
|
||||
* retrieve group meta data associated to a request token
|
||||
* @param token
|
||||
* @param groupInfo
|
||||
*/
|
||||
bool getGroupMetaTS(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo);
|
||||
|
||||
/*!
|
||||
* retrieves message meta data associated to a request token
|
||||
* @param token token to be redeemed
|
||||
* @param msgInfo the meta data to be retrieved for token store here
|
||||
*/
|
||||
bool getMsgMetaTS(const uint32_t &token, GxsMsgMetaMap &msgInfo);
|
||||
|
||||
/*!
|
||||
* retrieves group data associated to a request token
|
||||
* @param token token to be redeemed for grpitem retrieval
|
||||
* @param grpItem the items to be retrieved for token are stored here
|
||||
*/
|
||||
bool getGroupDataTS(const uint32_t &token, std::vector<RsGxsGrpItem*>& grpItem);
|
||||
|
||||
/*!
|
||||
* retrieves message data associated to a request token
|
||||
* @param token token to be redeemed for message item retrieval
|
||||
* @param msgItems
|
||||
*/
|
||||
bool getMsgDataTS(const uint32_t &token, GxsMsgDataMap& msgItems);
|
||||
|
||||
/*!
|
||||
* Retrieve msg related list for a given token sectioned by group Ids
|
||||
* @param token token to be redeemed
|
||||
* @param msgIds a map of grpMsgIdPair -> msgList (vector)
|
||||
*/
|
||||
bool getMsgRelatedListTS(const uint32_t &token, MsgRelatedIdResult &msgIds);
|
||||
|
||||
/*!
|
||||
* retrieves msg related data msgItems as a map of msg-grpID pair to vector
|
||||
* of items
|
||||
* @param token token to be redeemed
|
||||
* @param msgItems map of msg items
|
||||
*/
|
||||
bool getMsgRelatedDataTS(const uint32_t &token, GxsMsgRelatedDataMap& msgItems);
|
||||
|
||||
|
||||
void setGroupSubscribeFlagTS(uint32_t& token, const RsGxsGroupId& grpId, const uint32_t& status, const uint32_t& mask);
|
||||
|
||||
void setGroupStatusFlagTS(uint32_t& token, const RsGxsGroupId& grpId, const uint32_t& status, const uint32_t& mask);
|
||||
|
||||
void setGroupServiceStringTS(uint32_t& token, const RsGxsGroupId& grpId, const std::string& servString);
|
||||
|
||||
void setMsgStatusFlagTS(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, const uint32_t& status, const uint32_t& mask);
|
||||
|
||||
void setMsgServiceStringTS(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, const std::string& servString );
|
||||
|
||||
void service_tick();
|
||||
|
||||
};
|
||||
|
||||
#endif // GENEXCHANGETESTSERVICE_H
|
194
libretroshare/src/tests/gxs/nxs_tests.pro
Normal file
194
libretroshare/src/tests/gxs/nxs_tests.pro
Normal file
|
@ -0,0 +1,194 @@
|
|||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2012-05-06T09:19:26
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
|
||||
#
|
||||
QT += core network
|
||||
|
||||
QT -= gui
|
||||
|
||||
CONFIG += gen_exchange_target
|
||||
#CONFIG += nxs_net_test
|
||||
#CONFIG += dstore_target
|
||||
#CONFIG += gxsdata_target
|
||||
|
||||
CONFIG += bitdht
|
||||
|
||||
|
||||
|
||||
gen_exchange_target {
|
||||
|
||||
#TARGET = gen_exchange_test
|
||||
|
||||
}
|
||||
|
||||
nxs_net_test {
|
||||
|
||||
TARGET = nxs_net_test
|
||||
|
||||
}
|
||||
|
||||
gxsdata_target {
|
||||
|
||||
#TARGET = gxsdata_test
|
||||
|
||||
}
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += debug
|
||||
|
||||
debug {
|
||||
# DEFINES *= DEBUG
|
||||
# DEFINES *= OPENDHT_DEBUG DHT_DEBUG CONN_DEBUG DEBUG_UDP_SORTER P3DISC_DEBUG DEBUG_UDP_LAYER FT_DEBUG EXTADDRSEARCH_DEBUG
|
||||
# DEFINES *= CONTROL_DEBUG FT_DEBUG DEBUG_FTCHUNK P3TURTLE_DEBUG
|
||||
# DEFINES *= P3TURTLE_DEBUG
|
||||
# DEFINES *= NET_DEBUG
|
||||
# DEFINES *= DISTRIB_DEBUG
|
||||
# DEFINES *= P3TURTLE_DEBUG FT_DEBUG DEBUG_FTCHUNK MPLEX_DEBUG
|
||||
# DEFINES *= STATUS_DEBUG SERV_DEBUG RSSERIAL_DEBUG #CONN_DEBUG
|
||||
|
||||
QMAKE_CXXFLAGS -= -O2 -fomit-frame-pointer
|
||||
QMAKE_CXXFLAGS *= -g -fno-omit-frame-pointer
|
||||
}
|
||||
################################# Linux ##########################################
|
||||
# Put lib dir in QMAKE_LFLAGS so it appears before -L/usr/lib
|
||||
linux-* {
|
||||
#CONFIG += version_detail_bash_script
|
||||
QMAKE_CXXFLAGS *= -D_FILE_OFFSET_BITS=64
|
||||
|
||||
system(which gpgme-config >/dev/null 2>&1) {
|
||||
INCLUDEPATH += $$system(gpgme-config --cflags | sed -e "s/-I//g")
|
||||
} else {
|
||||
message(Could not find gpgme-config on your system, assuming gpgme.h is in /usr/include)
|
||||
}
|
||||
|
||||
PRE_TARGETDEPS *= ../../lib/libretroshare.a
|
||||
|
||||
LIBS += ../../lib/libretroshare.a
|
||||
LIBS += ../../../../libbitdht/src/lib/libbitdht.a
|
||||
LIBS += ../../../../openpgpsdk/src/lib/libops.a
|
||||
LIBS += -lssl -lgpgme -lupnp -lixml -lgnome-keyring -lsqlite3 -lbz2
|
||||
LIBS *= -rdynamic -frtti
|
||||
DEFINES *= HAVE_XSS # for idle time, libx screensaver extensions
|
||||
DEFINES *= UBUNTU
|
||||
}
|
||||
|
||||
linux-g++ {
|
||||
OBJECTS_DIR = temp/linux-g++/obj
|
||||
}
|
||||
|
||||
linux-g++-64 {
|
||||
OBJECTS_DIR = temp/linux-g++-64/obj
|
||||
}
|
||||
|
||||
#################################### Windows #####################################
|
||||
|
||||
win32 {
|
||||
|
||||
DEFINES *= WINDOWS_SYS \
|
||||
WIN32 \
|
||||
STATICLIB \
|
||||
MINGW
|
||||
# Switch on extra warnings
|
||||
QMAKE_CFLAGS += -Wextra
|
||||
QMAKE_CXXFLAGS += -Wextra
|
||||
|
||||
# Switch off optimization for release version
|
||||
QMAKE_CXXFLAGS_RELEASE -= -O2
|
||||
QMAKE_CXXFLAGS_RELEASE += -O0
|
||||
QMAKE_CFLAGS_RELEASE -= -O2
|
||||
QMAKE_CFLAGS_RELEASE += -O0
|
||||
|
||||
# Switch on optimization for debug version
|
||||
#QMAKE_CXXFLAGS_DEBUG += -O2
|
||||
#QMAKE_CFLAGS_DEBUG += -O2
|
||||
|
||||
# PRE_TARGETDEPS += ../../libretroshare/src/lib/libretroshare.a
|
||||
PRE_TARGETDEPS += ../../../../libretroshare/libretroshare-build-desktop/lib/libretroshare.a
|
||||
|
||||
LIBS += ../../../../libretroshare/libretroshare-build-desktop/lib/libretroshare.a
|
||||
LIBS += C:\Development\Rs\v0.5-gxs-b1\openpgpsdk\openpgpsdk-build-desktop\lib\libops.a
|
||||
LIBS += C:\Development\Libraries\sqlite\sqlite-autoconf-3070900\lib\libsqlite3.a
|
||||
LIBS += -L"../../../../../lib"
|
||||
LIBS += -lssl -lcrypto -lgpgme -lpthreadGC2d -lminiupnpc -lz -lbz2
|
||||
# added after bitdht
|
||||
# LIBS += -lws2_32
|
||||
LIBS += -luuid -lole32 -liphlpapi -lcrypt32-cygwin -lgdi32
|
||||
LIBS += -lole32 -lwinmm
|
||||
|
||||
# export symbols for the plugins
|
||||
#LIBS += -Wl,--export-all-symbols,--out-implib,lib/libretroshare-gui.a
|
||||
|
||||
GPG_ERROR_DIR = ../../../../libgpg-error-1.7
|
||||
GPGME_DIR = ../../../../gpgme-1.1.8
|
||||
GPG_ERROR_DIR = ../../../../lib/libgpg-error-1.7
|
||||
GPGME_DIR = ../../../../lib/gpgme-1.1.8
|
||||
SSL_DIR = ../../../../../OpenSSL
|
||||
OPENPGPSDK_DIR = ../../../../openpgpsdk/src
|
||||
INCLUDEPATH += . $${SSL_DIR}/include $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src \
|
||||
$${OPENPGPSDK_DIR}
|
||||
|
||||
SQLITE_DIR = ../../../../../../Libraries/sqlite/sqlite-autoconf-3070900
|
||||
INCLUDEPATH += . \
|
||||
$${SQLITE_DIR}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
bitdht {
|
||||
LIBS += C:\Development\Rs\v0.5-gxs-b1\libbitdht\libbitdht-build-desktop\lib\libbitdht.a
|
||||
PRE_TARGETDEPS *= C:\Development\Rs\v0.5-gxs-b1\libbitdht\libbitdht-build-desktop\lib\libbitdht.a
|
||||
|
||||
# Chris version.
|
||||
#LIBS += ../../libbitdht/libbitdht-build-desktop/lib/libbitdht.a
|
||||
#PRE_TARGETDEPS *= ../../libbitdht/libbitdht-build-desktop/lib/libbitdht.a
|
||||
}
|
||||
|
||||
win32 {
|
||||
# must be added after bitdht
|
||||
LIBS += -lws2_32
|
||||
}
|
||||
|
||||
version_detail_bash_script {
|
||||
DEFINES += ADD_LIBRETROSHARE_VERSION_INFO
|
||||
QMAKE_EXTRA_TARGETS += write_version_detail
|
||||
PRE_TARGETDEPS = write_version_detail
|
||||
write_version_detail.commands = ./version_detail.sh
|
||||
}
|
||||
|
||||
install_rs {
|
||||
INSTALLS += binary_rs
|
||||
binary_rs.path = $$(PREFIX)/usr/bin
|
||||
binary_rs.files = ./RetroShare
|
||||
}
|
||||
|
||||
|
||||
gen_exchange_target {
|
||||
|
||||
SOURCES += \
|
||||
support.cc \
|
||||
genexchangetester.cpp \
|
||||
genexchangetestservice.cpp \
|
||||
rsdummyservices.cc \
|
||||
rsgenexchange_test.cc
|
||||
|
||||
HEADERS += support.h \
|
||||
rsdataservice_test.h \
|
||||
rsdummyservices.h \
|
||||
data_support.h
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
INCLUDEPATH += ../../
|
92
libretroshare/src/tests/gxs/nxsnet_test.pro
Normal file
92
libretroshare/src/tests/gxs/nxsnet_test.pro
Normal file
|
@ -0,0 +1,92 @@
|
|||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2012-05-06T09:19:26
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core network
|
||||
|
||||
QT -= gui
|
||||
|
||||
TARGET = rs_test
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += debug
|
||||
|
||||
debug {
|
||||
# DEFINES *= DEBUG
|
||||
# DEFINES *= OPENDHT_DEBUG DHT_DEBUG CONN_DEBUG DEBUG_UDP_SORTER P3DISC_DEBUG DEBUG_UDP_LAYER FT_DEBUG EXTADDRSEARCH_DEBUG
|
||||
# DEFINES *= CONTROL_DEBUG FT_DEBUG DEBUG_FTCHUNK P3TURTLE_DEBUG
|
||||
# DEFINES *= P3TURTLE_DEBUG
|
||||
# DEFINES *= NET_DEBUG
|
||||
# DEFINES *= DISTRIB_DEBUG
|
||||
# DEFINES *= P3TURTLE_DEBUG FT_DEBUG DEBUG_FTCHUNK MPLEX_DEBUG
|
||||
# DEFINES *= STATUS_DEBUG SERV_DEBUG RSSERIAL_DEBUG #CONN_DEBUG
|
||||
|
||||
QMAKE_CXXFLAGS -= -O2 -fomit-frame-pointer
|
||||
QMAKE_CXXFLAGS *= -g -fno-omit-frame-pointer
|
||||
}
|
||||
################################# Linux ##########################################
|
||||
# Put lib dir in QMAKE_LFLAGS so it appears before -L/usr/lib
|
||||
linux-* {
|
||||
#CONFIG += version_detail_bash_script
|
||||
QMAKE_CXXFLAGS *= -D_FILE_OFFSET_BITS=64
|
||||
|
||||
system(which gpgme-config >/dev/null 2>&1) {
|
||||
INCLUDEPATH += $$system(gpgme-config --cflags | sed -e "s/-I//g")
|
||||
} else {
|
||||
message(Could not find gpgme-config on your system, assuming gpgme.h is in /usr/include)
|
||||
}
|
||||
|
||||
PRE_TARGETDEPS *= /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/lib/libretroshare.a
|
||||
|
||||
LIBS += /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/lib/libretroshare.a
|
||||
LIBS += /home/crispy/workspace/v0.5-gxs-b1/libbitdht/src/lib/libbitdht.a
|
||||
LIBS += /home/crispy/workspace/v0.5-gxs-b1/openpgpsdk/src/lib/libops.a
|
||||
LIBS += -lssl -lgpgme -lupnp -lixml -lgnome-keyring -lsqlite3 -lbz2
|
||||
LIBS *= -rdynamic -frtti
|
||||
DEFINES *= HAVE_XSS # for idle time, libx screensaver extensions
|
||||
DEFINES *= UBUNTU
|
||||
}
|
||||
|
||||
linux-g++ {
|
||||
OBJECTS_DIR = temp/linux-g++/obj
|
||||
}
|
||||
|
||||
linux-g++-64 {
|
||||
OBJECTS_DIR = temp/linux-g++-64/obj
|
||||
}
|
||||
|
||||
version_detail_bash_script {
|
||||
DEFINES += ADD_LIBRETROSHARE_VERSION_INFO
|
||||
QMAKE_EXTRA_TARGETS += write_version_detail
|
||||
PRE_TARGETDEPS = write_version_detail
|
||||
write_version_detail.commands = ./version_detail.sh
|
||||
}
|
||||
|
||||
install_rs {
|
||||
INSTALLS += binary_rs
|
||||
binary_rs.path = $$(PREFIX)/usr/bin
|
||||
binary_rs.files = ./RetroShare
|
||||
}
|
||||
|
||||
|
||||
SOURCES += \
|
||||
/home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/data_support.cc \
|
||||
/home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/nxstesthub.cc \
|
||||
/home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/nxstestscenario.cc \
|
||||
/home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/rsgxsnetservice_test.cc \
|
||||
/home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/support.cc
|
||||
|
||||
|
||||
HEADERS += \
|
||||
/home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/data_support.h \
|
||||
/home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/nxstesthub.h \
|
||||
/home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/nxstestscenario.h \
|
||||
/home/crispy/workspace/v0.5-gxs-b1/libretroshare/src/tests/gxs/support.h
|
||||
|
||||
INCLUDEPATH += /home/crispy/workspace/v0.5-gxs-b1/libretroshare/src
|
||||
|
|
@ -1,78 +1,126 @@
|
|||
#include "nxstesthub.h"
|
||||
|
||||
NxsTestHub::NxsTestHub(NxsTestScenario* nts) : mTestScenario(nts)
|
||||
NxsTestHub::NxsTestHub(NxsTestScenario * nts, std::set<std::string> &peers) : mTestScenario(nts)
|
||||
{
|
||||
|
||||
netServicePairs.first = new RsGxsNetService(mTestScenario->getServiceType(),
|
||||
mTestScenario->dummyDataService1(), &netMgr1, mTestScenario);
|
||||
netServicePairs.second = new RsGxsNetService(mTestScenario->getServiceType(),
|
||||
mTestScenario->dummyDataService2(), &netMgr2, mTestScenario);
|
||||
std::set<std::string>::iterator sit = peers.begin();
|
||||
|
||||
mServicePairs.first = netServicePairs.first;
|
||||
mServicePairs.second = netServicePairs.second;
|
||||
for(; sit != peers.end(); sit++)
|
||||
{
|
||||
std::set<std::string> msgPeers = peers;
|
||||
|
||||
createThread(*(netServicePairs.first));
|
||||
createThread(*(netServicePairs.second));
|
||||
// add peers all peers except one iterator currently points to
|
||||
msgPeers.erase(*sit);
|
||||
NxsNetDummyMgr* dummyMgr = new NxsNetDummyMgr(*sit, msgPeers);
|
||||
RsGeneralDataService* ds = mTestScenario->getDataService(*sit);
|
||||
NxsMessageTestObserver* obs = new NxsMessageTestObserver(ds);
|
||||
|
||||
RsGxsNetService* netService =
|
||||
new RsGxsNetService(mTestScenario->getServiceType(),
|
||||
ds, dummyMgr, obs);
|
||||
|
||||
|
||||
mNetServices.insert(std::make_pair(*sit, netService));
|
||||
mObservers.insert(std::make_pair(*sit, obs));
|
||||
}
|
||||
|
||||
sit = peers.begin();
|
||||
|
||||
// launch net services
|
||||
for(; sit != peers.end(); sit++)
|
||||
{
|
||||
RsGxsNetService* n = mNetServices[*sit];
|
||||
createThread(*n);
|
||||
mServices.insert(std::make_pair(*sit, n));
|
||||
}
|
||||
}
|
||||
|
||||
NxsTestHub::~NxsTestHub()
|
||||
{
|
||||
delete netServicePairs.first;
|
||||
delete netServicePairs.second;
|
||||
std::map<std::string, RsGxsNetService*>::iterator mit = mNetServices.begin();
|
||||
|
||||
for(; mit != mNetServices.end(); mit++)
|
||||
delete mit->second;
|
||||
}
|
||||
|
||||
|
||||
void NxsTestHub::run()
|
||||
{
|
||||
|
||||
std::list<RsItem*> send_queue_s1, send_queue_s2;
|
||||
double timeDelta = .2;
|
||||
|
||||
while(isRunning()){
|
||||
|
||||
// make thread sleep for a couple secs
|
||||
usleep(3000);
|
||||
// make thread sleep for a bit
|
||||
#ifndef WINDOWS_SYS
|
||||
usleep((int) (timeDelta * 1000000));
|
||||
#else
|
||||
Sleep((int) (timeDelta * 1000));
|
||||
#endif
|
||||
|
||||
p3Service* s1 = mServicePairs.first;
|
||||
p3Service* s2 = mServicePairs.second;
|
||||
|
||||
RsItem* item = NULL;
|
||||
while((item = s1->send()) != NULL)
|
||||
{
|
||||
item->PeerId("PeerB");
|
||||
send_queue_s1.push_back(item);
|
||||
}
|
||||
std::map<std::string, p3Service*>::iterator mit = mServices.begin();
|
||||
|
||||
while((item = s2->send()) != NULL)
|
||||
{
|
||||
item->PeerId("PeerA");
|
||||
send_queue_s2.push_back(item);
|
||||
}
|
||||
for(; mit != mServices.end(); mit++)
|
||||
{
|
||||
p3Service* s = mit->second;
|
||||
s->tick();
|
||||
}
|
||||
|
||||
while(!send_queue_s1.empty()){
|
||||
item = send_queue_s1.front();
|
||||
s2->receive(dynamic_cast<RsRawItem*>(item));
|
||||
send_queue_s1.pop_front();
|
||||
}
|
||||
mit = mServices.begin();
|
||||
|
||||
while(!send_queue_s2.empty()){
|
||||
item = send_queue_s2.front();
|
||||
s1->receive(dynamic_cast<RsRawItem*>(item));
|
||||
send_queue_s2.pop_front();
|
||||
}
|
||||
// collect msgs to send to peers from peers
|
||||
for(; mit != mServices.end(); mit++)
|
||||
{
|
||||
const std::string& peer = mit->first;
|
||||
p3Service* s = mit->second;
|
||||
|
||||
// tick services so nxs net services process items
|
||||
s1->tick();
|
||||
s2->tick();
|
||||
// first store all the sends from all services
|
||||
RsItem* item = NULL;
|
||||
|
||||
while((item = s->send()) != NULL){
|
||||
|
||||
const std::string peerToReceive = item->PeerId();
|
||||
|
||||
// set the peer this item comes from
|
||||
item->PeerId(peer);
|
||||
mPeerQueues[peerToReceive].push_back(item);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// now route items to peers
|
||||
std::map<std::string, std::vector<RsItem*> >::iterator mit_queue = mPeerQueues.begin();
|
||||
|
||||
for(; mit_queue != mPeerQueues.end(); mit_queue++)
|
||||
{
|
||||
std::vector<RsItem*>& queueV = mit_queue->second;
|
||||
std::vector<RsItem*>::iterator vit = queueV.begin();
|
||||
const std::string peerToReceive = mit_queue->first;
|
||||
for(; vit != queueV.end(); vit++)
|
||||
{
|
||||
|
||||
RsItem* item = *vit;
|
||||
p3Service* service = mServices[peerToReceive];
|
||||
|
||||
service->receive(dynamic_cast<RsRawItem*>(item));
|
||||
}
|
||||
queueV.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// also shut down this net service peers if this goes down
|
||||
netServicePairs.first->join();
|
||||
netServicePairs.second->join();
|
||||
}
|
||||
|
||||
void NxsTestHub::cleanUp()
|
||||
{
|
||||
mTestScenario->cleanUp();
|
||||
std::map<std::string, RsGxsNetService*>::iterator mit = mNetServices.begin();
|
||||
for(; mit != mNetServices.end(); mit++)
|
||||
{
|
||||
RsGxsNetService* n = mit->second;
|
||||
n->join();
|
||||
}
|
||||
|
||||
// also shut down this net service peers if this goes down
|
||||
mTestScenario->cleanUp();
|
||||
}
|
||||
|
||||
bool NxsTestHub::testsPassed()
|
||||
|
|
|
@ -11,14 +11,13 @@
|
|||
// of peers
|
||||
|
||||
|
||||
class NxsNetDummyMgr1 : public RsNxsNetMgr
|
||||
class NxsNetDummyMgr : public RsNxsNetMgr
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
NxsNetDummyMgr1() : mOwnId("peerA") {
|
||||
NxsNetDummyMgr(std::string ownId, std::set<std::string> peers) : mOwnId(ownId), mPeers(peers) {
|
||||
|
||||
mPeers.insert("peerB");
|
||||
}
|
||||
|
||||
std::string getOwnId() { return mOwnId; }
|
||||
|
@ -31,26 +30,6 @@ private:
|
|||
|
||||
};
|
||||
|
||||
class NxsNetDummyMgr2 : public RsNxsNetMgr
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
NxsNetDummyMgr2() : mOwnId("peerB") {
|
||||
|
||||
mPeers.insert("peerA");
|
||||
|
||||
}
|
||||
|
||||
std::string getOwnId() { return mOwnId; }
|
||||
void getOnlineList(std::set<std::string>& ssl_peers) { ssl_peers = mPeers; }
|
||||
|
||||
private:
|
||||
|
||||
std::string mOwnId;
|
||||
std::set<std::string> mPeers;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* Testing of nxs services occurs through use of two services
|
||||
|
@ -73,7 +52,7 @@ public:
|
|||
* This construct the test hub
|
||||
* for a give scenario in mind
|
||||
*/
|
||||
NxsTestHub(NxsTestScenario*);
|
||||
NxsTestHub(NxsTestScenario*, std::set<std::string>& peers);
|
||||
|
||||
|
||||
/*!
|
||||
|
@ -97,12 +76,13 @@ public:
|
|||
void cleanUp();
|
||||
private:
|
||||
|
||||
std::pair<p3Service*, p3Service*> mServicePairs;
|
||||
std::pair<RsGxsNetService*, RsGxsNetService*> netServicePairs;
|
||||
NxsTestScenario *mTestScenario;
|
||||
std::map<std::string, p3Service*> mServices;
|
||||
std::map<std::string, RsGxsNetService*> mNetServices;
|
||||
std::map<std::string, NxsMessageTestObserver*> mObservers;
|
||||
|
||||
NxsNetDummyMgr1 netMgr1;
|
||||
NxsNetDummyMgr2 netMgr2;
|
||||
std::map<std::string, std::vector<RsItem*> > mPeerQueues;
|
||||
|
||||
NxsTestScenario *mTestScenario;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -7,15 +7,14 @@
|
|||
|
||||
#include "nxstestscenario.h"
|
||||
#include "gxs/rsdataservice.h"
|
||||
#include "gxs/rsgxsflags.h"
|
||||
#include "data_support.h"
|
||||
#include <stdio.h>
|
||||
|
||||
NxsMessageTest::NxsMessageTest(uint16_t servtype)
|
||||
: mServType(servtype)
|
||||
: mServType(servtype), mMsgTestMtx("mMsgTestMtx")
|
||||
{
|
||||
mStorePair.first = new RsDataService(".", "dStore1", mServType);
|
||||
mStorePair.second = new RsDataService(".", "dStore2", mServType);
|
||||
|
||||
setUpDataBases();
|
||||
}
|
||||
|
||||
std::string NxsMessageTest::getTestName()
|
||||
|
@ -24,21 +23,33 @@ std::string NxsMessageTest::getTestName()
|
|||
}
|
||||
|
||||
NxsMessageTest::~NxsMessageTest(){
|
||||
delete mStorePair.first;
|
||||
delete mStorePair.second;
|
||||
|
||||
std::map<std::string, RsGeneralDataService*>::iterator mit = mPeerStoreMap.begin();
|
||||
|
||||
for(; mit != mPeerStoreMap.end(); mit++)
|
||||
{
|
||||
delete mit->second;
|
||||
}
|
||||
|
||||
std::set<std::string>::iterator sit = mStoreNames.begin();
|
||||
|
||||
// remove db file
|
||||
for(; sit != mStoreNames.end(); sit++)
|
||||
{
|
||||
const std::string& name = *sit;
|
||||
remove(name.c_str());
|
||||
}
|
||||
}
|
||||
void NxsMessageTest::setUpDataBases()
|
||||
RsGeneralDataService* NxsMessageTest::getDataService(const std::string& peer)
|
||||
{
|
||||
// create several groups and then messages of that
|
||||
// group for both second and first of pair
|
||||
RsDataService* dStore = dynamic_cast<RsDataService*>(mStorePair.first);
|
||||
populateStore(dStore);
|
||||
if(mPeerStoreMap.find(peer) != mPeerStoreMap.end()) return NULL;
|
||||
|
||||
dStore = dynamic_cast<RsDataService*>(mStorePair.second);
|
||||
populateStore(dStore);
|
||||
RsDataService* dStore = new RsDataService("./", peer, mServType);
|
||||
mStoreNames.insert(peer);
|
||||
mPeerStoreMap.insert(std::make_pair(peer, dStore));
|
||||
populateStore(dStore);
|
||||
|
||||
dStore = NULL;
|
||||
return;
|
||||
return dStore;
|
||||
}
|
||||
|
||||
uint16_t NxsMessageTest::getServiceType()
|
||||
|
@ -49,7 +60,7 @@ uint16_t NxsMessageTest::getServiceType()
|
|||
void NxsMessageTest::populateStore(RsGeneralDataService* dStore)
|
||||
{
|
||||
|
||||
int nGrp = rand()%7;
|
||||
int nGrp = (rand()%2)+1;
|
||||
std::vector<std::string> grpIdList;
|
||||
std::map<RsNxsGrp*, RsGxsGrpMetaData*> grps;
|
||||
RsNxsGrp* grp = NULL;
|
||||
|
@ -72,16 +83,6 @@ void NxsMessageTest::populateStore(RsGeneralDataService* dStore)
|
|||
|
||||
dStore->storeGroup(grps);
|
||||
|
||||
|
||||
std::map<RsNxsGrp*, RsGxsGrpMetaData*>::iterator grp_it
|
||||
= grps.begin();
|
||||
for(; grp_it != grps.end(); grp_it++)
|
||||
{
|
||||
delete grp_it->first;
|
||||
delete grp_it->second;
|
||||
}
|
||||
|
||||
|
||||
int nMsgs = rand()%23;
|
||||
std::map<RsNxsMsg*, RsGxsMsgMetaData*> msgs;
|
||||
RsNxsMsg* msg = NULL;
|
||||
|
@ -109,53 +110,68 @@ void NxsMessageTest::populateStore(RsGeneralDataService* dStore)
|
|||
|
||||
dStore->storeMessage(msgs);
|
||||
|
||||
// clean up
|
||||
std::map<RsNxsMsg*, RsGxsMsgMetaData*>::iterator msg_it
|
||||
= msgs.begin();
|
||||
return;
|
||||
}
|
||||
|
||||
for(; msg_it != msgs.end(); msg_it++)
|
||||
void NxsMessageTest::cleanUp()
|
||||
{
|
||||
|
||||
std::map<std::string, RsGeneralDataService*>::iterator mit = mPeerStoreMap.begin();
|
||||
|
||||
for(; mit != mPeerStoreMap.end(); mit++)
|
||||
{
|
||||
delete msg_it->first;
|
||||
delete msg_it->second;
|
||||
RsGeneralDataService* d = mit->second;
|
||||
d->resetDataStore();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void NxsMessageTest::notifyNewMessages(std::vector<RsNxsMsg*>& messages)
|
||||
bool NxsMessageTest::testPassed(){
|
||||
return false;
|
||||
}
|
||||
|
||||
/*******************************/
|
||||
|
||||
NxsMessageTestObserver::NxsMessageTestObserver(RsGeneralDataService *dStore)
|
||||
:mStore(dStore)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void NxsMessageTestObserver::notifyNewGroups(std::vector<RsNxsGrp *> &groups)
|
||||
{
|
||||
std::vector<RsNxsGrp*>::iterator vit = groups.begin();
|
||||
std::map<RsNxsGrp*, RsGxsGrpMetaData*> grps;
|
||||
|
||||
for(; vit != groups.end(); vit++)
|
||||
{
|
||||
RsNxsGrp* grp = *vit;
|
||||
RsGxsGrpMetaData* meta = new RsGxsGrpMetaData();
|
||||
meta->deserialise(grp->meta.bin_data, grp->meta.bin_len);
|
||||
meta->mSubscribeFlags |= GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED;
|
||||
meta->mGroupId = grp->grpId;
|
||||
grps.insert(std::make_pair(grp, meta));
|
||||
}
|
||||
|
||||
mStore->storeGroup(grps);
|
||||
}
|
||||
|
||||
void NxsMessageTestObserver::notifyNewMessages(std::vector<RsNxsMsg *> &messages)
|
||||
{
|
||||
|
||||
std::vector<RsNxsMsg*>::iterator vit = messages.begin();
|
||||
std::map<RsNxsMsg*, RsGxsMsgMetaData*> msgs;
|
||||
|
||||
for(; vit != messages.end(); vit++)
|
||||
{
|
||||
mPeerMsgs[(*vit)->PeerId()].push_back(*vit);
|
||||
RsNxsMsg* msg = *vit;
|
||||
RsGxsMsgMetaData* meta = new RsGxsMsgMetaData();
|
||||
meta->mGroupId = msg->grpId;
|
||||
meta->mMsgId = msg->msgId;
|
||||
msgs.insert(std::make_pair(msg, meta));
|
||||
}
|
||||
|
||||
mStore->storeMessage(msgs);
|
||||
}
|
||||
|
||||
void NxsMessageTest::notifyNewGroups(std::vector<RsNxsGrp*>& groups)
|
||||
{
|
||||
std::vector<RsNxsGrp*>::iterator vit = groups.begin();
|
||||
|
||||
for(; vit != groups.end(); vit++)
|
||||
{
|
||||
mPeerGrps[(*vit)->PeerId()].push_back(*vit);
|
||||
}
|
||||
}
|
||||
|
||||
RsGeneralDataService* NxsMessageTest::dummyDataService1()
|
||||
{
|
||||
return mStorePair.first;
|
||||
}
|
||||
|
||||
RsGeneralDataService* NxsMessageTest::dummyDataService2()
|
||||
{
|
||||
return mStorePair.second;
|
||||
}
|
||||
|
||||
void NxsMessageTest::cleanUp()
|
||||
{
|
||||
mStorePair.first->resetDataStore();
|
||||
mStorePair.second->resetDataStore();
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -15,14 +15,26 @@
|
|||
/*!
|
||||
* This scenario module provides data resources
|
||||
*/
|
||||
class NxsTestScenario : public RsNxsObserver
|
||||
class NxsTestScenario
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual std::string getTestName() = 0;
|
||||
virtual RsGeneralDataService* dummyDataService1() = 0;
|
||||
virtual RsGeneralDataService* dummyDataService2() = 0;
|
||||
|
||||
/*!
|
||||
* @param peer
|
||||
* @param namePath
|
||||
* @return data service with populated with random grp/msg data, null if peer or pathname exists
|
||||
*/
|
||||
virtual RsGeneralDataService* getDataService(const std::string& peer) = 0;
|
||||
|
||||
|
||||
virtual bool testPassed() = 0;
|
||||
/*!
|
||||
* Service type for this test
|
||||
* should correspond to serialiser service type
|
||||
*/
|
||||
virtual uint16_t getServiceType() = 0;
|
||||
|
||||
/*!
|
||||
|
@ -34,25 +46,11 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class NxsMessageTest : public NxsTestScenario
|
||||
class NxsMessageTestObserver : public RsNxsObserver
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
NxsMessageTest(uint16_t servtype);
|
||||
virtual ~NxsMessageTest();
|
||||
std::string getTestName();
|
||||
uint16_t getServiceType();
|
||||
RsGeneralDataService* dummyDataService1();
|
||||
RsGeneralDataService* dummyDataService2();
|
||||
|
||||
/*!
|
||||
* Call to remove files created
|
||||
* in the test directory
|
||||
*/
|
||||
void cleanUp();
|
||||
|
||||
public:
|
||||
NxsMessageTestObserver(RsGeneralDataService* dStore);
|
||||
|
||||
/*!
|
||||
* @param messages messages are deleted after function returns
|
||||
|
@ -64,6 +62,30 @@ public:
|
|||
*/
|
||||
void notifyNewGroups(std::vector<RsNxsGrp*>& groups);
|
||||
|
||||
private:
|
||||
|
||||
RsGeneralDataService* mStore;
|
||||
|
||||
};
|
||||
|
||||
class NxsMessageTest : public NxsTestScenario
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
NxsMessageTest(uint16_t servtype);
|
||||
virtual ~NxsMessageTest();
|
||||
std::string getTestName();
|
||||
uint16_t getServiceType();
|
||||
RsGeneralDataService* getDataService(const std::string& peer);
|
||||
|
||||
/*!
|
||||
* Call to remove files created
|
||||
* in the test directory
|
||||
*/
|
||||
void cleanUp();
|
||||
|
||||
bool testPassed();
|
||||
|
||||
private:
|
||||
void setUpDataBases();
|
||||
|
@ -72,11 +94,12 @@ private:
|
|||
private:
|
||||
|
||||
std::string mTestName;
|
||||
std::pair<RsGeneralDataService*, RsGeneralDataService*> mStorePair;
|
||||
std::map<std::string, std::vector<RsNxsMsg*> > mPeerMsgs;
|
||||
std::map<std::string, std::vector<RsNxsGrp*> > mPeerGrps;
|
||||
std::map<std::string, RsGeneralDataService*> mPeerStoreMap;
|
||||
std::set<std::string> mStoreNames;
|
||||
uint16_t mServType;
|
||||
|
||||
RsMutex mMsgTestMtx;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "support.h"
|
||||
#include "data_support.h"
|
||||
#include "rsdataservice_test.h"
|
||||
#include "gxs/rsgds.h"
|
||||
#include "gxs/rsdataservice.h"
|
||||
|
||||
#define DATA_BASE_NAME "msg_grp_Store"
|
||||
|
@ -37,7 +38,7 @@ void test_groupStoreAndRetrieve(){
|
|||
setUp();
|
||||
|
||||
int nGrp = rand()%32;
|
||||
std::map<RsNxsGrp*, RsGxsGrpMetaData*> grps;
|
||||
std::map<RsNxsGrp*, RsGxsGrpMetaData*> grps, grps_copy;
|
||||
RsNxsGrp* grp;
|
||||
RsGxsGrpMetaData* grpMeta;
|
||||
for(int i = 0; i < nGrp; i++){
|
||||
|
@ -50,16 +51,24 @@ void test_groupStoreAndRetrieve(){
|
|||
init_item(grpMeta);
|
||||
grpMeta->mGroupId = grp->grpId;
|
||||
grps.insert(p);
|
||||
|
||||
RsNxsGrp* grp_copy = new RsNxsGrp(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
*grp_copy = *grp;
|
||||
RsGxsGrpMetaData* grpMeta_copy = new RsGxsGrpMetaData();
|
||||
*grpMeta_copy = *grpMeta;
|
||||
grps_copy.insert(std::make_pair(grp_copy, grpMeta_copy ));
|
||||
grpMeta = NULL;
|
||||
grp = NULL;
|
||||
}
|
||||
|
||||
dStore->storeGroup(grps);
|
||||
|
||||
std::map<std::string, RsNxsGrp*> gR;
|
||||
std::map<std::string, RsGxsGrpMetaData*> grpMetaR;
|
||||
dStore->retrieveNxsGrps(gR, false);
|
||||
//use copy, a grps are deleted in store
|
||||
grps.clear();
|
||||
grps = grps_copy;
|
||||
|
||||
std::map<RsGxsGroupId, RsNxsGrp*> gR;
|
||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMetaR;
|
||||
dStore->retrieveNxsGrps(gR, false, false);
|
||||
dStore->retrieveGxsGrpMetaData(grpMetaR);
|
||||
|
||||
std::map<RsNxsGrp*, RsGxsGrpMetaData*>::iterator mit = grps.begin();
|
||||
|
@ -140,6 +149,7 @@ void test_messageStoresAndRetrieve()
|
|||
grpV.push_back(grpId1);
|
||||
|
||||
std::map<RsNxsMsg*, RsGxsMsgMetaData*> msgs;
|
||||
std::map<RsNxsMsg*, RsGxsMsgMetaData*> msgs_copy;
|
||||
RsNxsMsg* msg = NULL;
|
||||
RsGxsMsgMetaData* msgMeta = NULL;
|
||||
int nMsgs = rand()%120;
|
||||
|
@ -164,14 +174,20 @@ void test_messageStoresAndRetrieve()
|
|||
const std::string& grpId = grpV[chosen];
|
||||
|
||||
if(chosen)
|
||||
req[grpId].insert(msg->msgId);
|
||||
req[grpId].push_back(msg->msgId);
|
||||
|
||||
msgMeta->mMsgId = msg->msgId;
|
||||
msgMeta->mGroupId = msg->grpId = grpId;
|
||||
|
||||
RsNxsMsg* msg_copy = new RsNxsMsg(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
RsGxsMsgMetaData* msgMeta_copy = new RsGxsMsgMetaData();
|
||||
|
||||
*msg_copy = *msg;
|
||||
*msgMeta_copy = *msgMeta;
|
||||
|
||||
// store msgs in map to use for verification
|
||||
std::pair<std::string, RsNxsMsg*> vP(msg->msgId, msg);
|
||||
std::pair<std::string, RsGxsMsgMetaData*> vPmeta(msg->msgId, msgMeta);
|
||||
std::pair<std::string, RsNxsMsg*> vP(msg->msgId, msg_copy);
|
||||
std::pair<std::string, RsGxsMsgMetaData*> vPmeta(msg->msgId, msgMeta_copy);
|
||||
|
||||
if(!chosen)
|
||||
{
|
||||
|
@ -183,15 +199,21 @@ void test_messageStoresAndRetrieve()
|
|||
VergrpId1.insert(vP);
|
||||
VerMetagrpId0.insert(vPmeta);
|
||||
}
|
||||
|
||||
|
||||
|
||||
msg = NULL;
|
||||
msgMeta = NULL;
|
||||
|
||||
msgs.insert(p);
|
||||
msgs_copy.insert(std::make_pair(msg_copy, msgMeta_copy));
|
||||
}
|
||||
|
||||
req[grpV[0]] = std::set<std::string>(); // assign empty list for other
|
||||
req[grpV[0]] = std::vector<RsGxsMessageId>(); // assign empty list for other
|
||||
|
||||
dStore->storeMessage(msgs);
|
||||
msgs.clear();
|
||||
msgs = msgs_copy;
|
||||
|
||||
// now retrieve msgs for comparison
|
||||
// first selective retrieval
|
||||
|
@ -199,7 +221,8 @@ void test_messageStoresAndRetrieve()
|
|||
GxsMsgResult msgResult;
|
||||
GxsMsgMetaResult msgMetaResult;
|
||||
dStore->retrieveNxsMsgs(req, msgResult, false);
|
||||
dStore->retrieveGxsMsgMetaData(grpV, msgMetaResult);
|
||||
|
||||
dStore->retrieveGxsMsgMetaData(req, msgMetaResult);
|
||||
|
||||
// now look at result for grpId 1
|
||||
std::vector<RsNxsMsg*>& result0 = msgResult[grpId0];
|
||||
|
@ -316,8 +339,7 @@ void tearDown(){
|
|||
|
||||
bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r)
|
||||
{
|
||||
if(!(l.adminSign == r.adminSign)) return false;
|
||||
if(!(l.idSign == r.idSign)) return false;
|
||||
if(!(l.signSet == r.signSet)) return false;
|
||||
if(!(l.keys == r.keys)) return false;
|
||||
if(l.mGroupFlags != r.mGroupFlags) return false;
|
||||
if(l.mPublishTs != r.mPublishTs) return false;
|
||||
|
@ -335,8 +357,7 @@ bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r)
|
|||
bool operator ==(const RsGxsMsgMetaData& l, const RsGxsMsgMetaData& r)
|
||||
{
|
||||
|
||||
if(!(l.idSign == r.idSign)) return false;
|
||||
if(!(l.pubSign == r.pubSign)) return false;
|
||||
if(!(l.signSet == r.signSet)) return false;
|
||||
if(l.mGroupId != r.mGroupId) return false;
|
||||
if(l.mAuthorId != r.mAuthorId) return false;
|
||||
if(l.mParentId != r.mParentId) return false;
|
||||
|
|
226
libretroshare/src/tests/gxs/rsdummyservices.cc
Normal file
226
libretroshare/src/tests/gxs/rsdummyservices.cc
Normal file
|
@ -0,0 +1,226 @@
|
|||
|
||||
|
||||
#include "rsdummyservices.h"
|
||||
|
||||
|
||||
uint32_t RsDummySerialiser::size(RsItem *item)
|
||||
{
|
||||
RsDummyMsg* msg;
|
||||
RsDummyGrp* grp;
|
||||
|
||||
if( (msg = dynamic_cast<RsDummyMsg*>(item)) != NULL )
|
||||
{
|
||||
return sizeDummyMsgItem(msg);
|
||||
}else if( (grp = dynamic_cast<RsDummyGrp*>(item)) != NULL )
|
||||
{
|
||||
return sizeDummyGrpItem(grp);
|
||||
}else
|
||||
{
|
||||
std::cerr << "RsDummySerialiser::size(RsItem *item) Error with dummy cast!\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool RsDummySerialiser::serialise(RsItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
RsDummyMsg* msg;
|
||||
RsDummyGrp* grp;
|
||||
|
||||
if( (msg = dynamic_cast<RsDummyMsg*>(item)) != NULL )
|
||||
{
|
||||
return serialiseDummyMsgItem(msg, data, size);
|
||||
}else if( (grp = dynamic_cast<RsDummyGrp*>(item)) != NULL )
|
||||
{
|
||||
return serialiseDummyGrpItem(grp, data, size);
|
||||
}else
|
||||
{
|
||||
std::cerr << "RsDummySerialiser::size(RsItem *item) Error with dummy cast!\n";
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
RsItem* RsDummySerialiser::deserialise(void *data, uint32_t *size)
|
||||
{
|
||||
/* get the type and size */
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
||||
(RS_SERVICE_TYPE_DUMMY != getRsItemService(rstype)))
|
||||
{
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
switch(getRsItemSubType(rstype))
|
||||
{
|
||||
case RS_PKT_SUBTYPE_DUMMY_MSG:
|
||||
return deserialiseDummyMsgItem(data, size);
|
||||
case RS_PKT_SUBTYPE_DUMMY_GRP:
|
||||
return deserialiseDummyGrpItem(data, size);
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
uint32_t RsDummySerialiser::sizeDummyMsgItem(RsDummyMsg *item)
|
||||
{
|
||||
uint32_t s = 8; // header
|
||||
s += GetTlvStringSize(item->msgData);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
bool RsDummySerialiser::serialiseDummyMsgItem (RsDummyMsg *item, void *data, uint32_t *size)
|
||||
{
|
||||
uint32_t tlvsize = sizeDummyMsgItem(item);
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (*size < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
*size = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* RsDistribMsg first */
|
||||
|
||||
ok &= SetTlvString(data, *size, &offset, 1, item->msgData);
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
std::cerr << "RsDummySerialiser::serialiseDummyMsgItem Size Error! " << std::endl;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
RsDummyMsg * RsDummySerialiser::deserialiseDummyMsgItem(void *data, uint32_t *size)
|
||||
{
|
||||
/* get the type and size */
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
|
||||
uint32_t offset = 0;
|
||||
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
||||
(RS_SERVICE_TYPE_DUMMY != getRsItemService(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_DUMMY_MSG != getRsItemSubType(rstype)))
|
||||
{
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
if (*size < rssize) /* check size */
|
||||
return NULL; /* not enough data */
|
||||
|
||||
/* set the packet length */
|
||||
*size = rssize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
/* ready to load */
|
||||
RsDummyMsg *item = new RsDummyMsg();
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
ok &= GetTlvString(data, *size, &offset, 1, item->msgData);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
uint32_t RsDummySerialiser::sizeDummyGrpItem(RsDummyGrp *item)
|
||||
{
|
||||
uint32_t s = 8;
|
||||
s += GetTlvStringSize(item->grpData);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
bool RsDummySerialiser::serialiseDummyGrpItem (RsDummyGrp *item, void *data, uint32_t *size)
|
||||
{
|
||||
uint32_t tlvsize = sizeDummyGrpItem(item);
|
||||
uint32_t offset = 0;
|
||||
|
||||
if (*size < tlvsize)
|
||||
return false; /* not enough space */
|
||||
|
||||
*size = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
ok &= SetTlvString(data, *size, &offset, 1, item->grpData);
|
||||
|
||||
if (offset != tlvsize)
|
||||
{
|
||||
ok = false;
|
||||
std::cerr << "RsDummySerialiser::serialiseDummyGrpItem Size Error! " << std::endl;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
RsDummyGrp * RsDummySerialiser::deserialiseDummyGrpItem(void *data, uint32_t *size)
|
||||
{
|
||||
/* get the type and size */
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
|
||||
uint32_t offset = 0;
|
||||
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
||||
(RS_SERVICE_TYPE_DUMMY != getRsItemService(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_DUMMY_GRP != getRsItemSubType(rstype)))
|
||||
{
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
if (*size < rssize) /* check size */
|
||||
return NULL; /* not enough data */
|
||||
|
||||
/* set the packet length */
|
||||
*size = rssize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
/* ready to load */
|
||||
RsDummyGrp *item = new RsDummyGrp();
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
ok &= GetTlvString(data, *size, &offset, 1, item->grpData);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
165
libretroshare/src/tests/gxs/rsdummyservices.h
Normal file
165
libretroshare/src/tests/gxs/rsdummyservices.h
Normal file
|
@ -0,0 +1,165 @@
|
|||
#ifndef RSDUMMYSERVICES_H
|
||||
#define RSDUMMYSERVICES_H
|
||||
|
||||
|
||||
// dummy services to make
|
||||
|
||||
#include "gxs/rsnxs.h"
|
||||
#include "gxs/rsgixs.h"
|
||||
#include "serialiser/rsgxsitems.h"
|
||||
|
||||
class RsDummyNetService: public RsNetworkExchangeService
|
||||
{
|
||||
public:
|
||||
|
||||
RsDummyNetService(){ return;}
|
||||
|
||||
void setSyncAge(uint32_t age){}
|
||||
|
||||
void requestGroupsOfPeer(const std::string& peerId){}
|
||||
|
||||
void requestMessagesOfPeer(const std::string& peerId, const std::string& grpId){}
|
||||
|
||||
void pauseSynchronisation(bool enabled) {}
|
||||
|
||||
int requestMsg(const std::string& msgId, uint8_t hops){ return 0;}
|
||||
|
||||
int requestGrp(const std::list<std::string>& grpId, uint8_t hops) { return 0;}
|
||||
};
|
||||
|
||||
|
||||
|
||||
const uint16_t RS_SERVICE_TYPE_DUMMY = 0x01;
|
||||
const uint8_t RS_PKT_SUBTYPE_DUMMY_MSG = 0x02;
|
||||
const uint8_t RS_PKT_SUBTYPE_DUMMY_GRP = 0x03;
|
||||
|
||||
|
||||
class RsDummyMsg : public RsGxsMsgItem
|
||||
{
|
||||
public:
|
||||
RsDummyMsg() : RsGxsMsgItem(RS_SERVICE_TYPE_DUMMY, RS_PKT_SUBTYPE_DUMMY_MSG) { return; }
|
||||
virtual ~RsDummyMsg() { return; }
|
||||
|
||||
std::string msgData;
|
||||
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0){ return out; }
|
||||
void clear() { msgData.clear(); }
|
||||
|
||||
};
|
||||
|
||||
class RsDummyGrp : public RsGxsGrpItem
|
||||
{
|
||||
public:
|
||||
|
||||
RsDummyGrp() : RsGxsGrpItem(RS_SERVICE_TYPE_DUMMY, RS_PKT_SUBTYPE_DUMMY_GRP) { return; }
|
||||
virtual ~RsDummyGrp() { return; }
|
||||
|
||||
|
||||
|
||||
std::string grpData;
|
||||
void clear() { grpData.clear(); }
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0){ return out; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
class RsDummySerialiser : public RsSerialType
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
RsDummySerialiser()
|
||||
: RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_DUMMY)
|
||||
{ return; }
|
||||
virtual ~RsDummySerialiser() { return; }
|
||||
|
||||
uint32_t size(RsItem *item);
|
||||
bool serialise (RsItem *item, void *data, uint32_t *size);
|
||||
RsItem * deserialise(void *data, uint32_t *size);
|
||||
|
||||
private:
|
||||
|
||||
uint32_t sizeDummyMsgItem(RsDummyMsg *item);
|
||||
bool serialiseDummyMsgItem (RsDummyMsg *item, void *data, uint32_t *size);
|
||||
RsDummyMsg * deserialiseDummyMsgItem(void *data, uint32_t *size);
|
||||
|
||||
uint32_t sizeDummyGrpItem(RsDummyGrp *item);
|
||||
bool serialiseDummyGrpItem (RsDummyGrp *item, void *data, uint32_t *size);
|
||||
RsDummyGrp * deserialiseDummyGrpItem(void *data, uint32_t *size);
|
||||
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
* Dummy implementation of Gixs service for
|
||||
* testing
|
||||
* Limited to creating two ids upon construction which can be used
|
||||
* for signing data
|
||||
*/
|
||||
class RsGixsDummy : public RsGixs
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/*!
|
||||
* constructs keys for both incoming and outgoing id (no private keys for incoming id)
|
||||
* @param
|
||||
* @param dummyId This is is the only id thats exists in this dummy interface
|
||||
*/
|
||||
RsGixsDummy(const RsGxsId& incomingId, const RsGxsId& outgoingId){}
|
||||
|
||||
/*!
|
||||
*
|
||||
* @return id used for signing incoming data (should have both public and private components)
|
||||
*/
|
||||
const RsGxsId& getOutgoing(){ return mOutgoingId; }
|
||||
|
||||
/*!
|
||||
*
|
||||
* @return id used for signing outgoing data(only have public parts)
|
||||
*/
|
||||
const RsGxsId& getIncoming(){ return mIncomingId; }
|
||||
|
||||
// Key related interface - used for validating msgs and groups.
|
||||
/*!
|
||||
* Use to query a whether given key is available by its key reference
|
||||
* @param keyref the keyref of key that is being checked for
|
||||
* @return true if available, false otherwise
|
||||
*/
|
||||
bool haveKey(const RsGxsId &id){ return false;}
|
||||
|
||||
/*!
|
||||
* Use to query whether private key member of the given key reference is available
|
||||
* @param keyref the KeyRef of the key being checked for
|
||||
* @return true if private key is held here, false otherwise
|
||||
*/
|
||||
bool havePrivateKey(const RsGxsId &id){ return false; }
|
||||
|
||||
// The fetchKey has an optional peerList.. this is people that had the msg with the signature.
|
||||
// These same people should have the identity - so we ask them first.
|
||||
/*!
|
||||
* Use to request a given key reference
|
||||
* @param keyref the KeyRef of the key being requested
|
||||
* @return will
|
||||
*/
|
||||
bool requestKey(const RsGxsId &id, const std::list<PeerId> &peers){ return false ;}
|
||||
bool requestPrivateKey(const RsGxsId &id){ return false;}
|
||||
|
||||
|
||||
/*!
|
||||
* Retrieves a key identity
|
||||
* @param keyref
|
||||
* @return a pointer to a valid profile if successful, otherwise NULL
|
||||
*
|
||||
*/
|
||||
int getKey(const RsGxsId &id, RsTlvSecurityKey &key){ return false; }
|
||||
int getPrivateKey(const RsGxsId &id, RsTlvSecurityKey &key){ return false; } // For signing outgoing messages.
|
||||
|
||||
private:
|
||||
|
||||
RsGxsId mIncomingId, mOutgoingId;
|
||||
};
|
||||
|
||||
|
||||
#endif // RSDUMMYSERVICES_H
|
36
libretroshare/src/tests/gxs/rsgenexchange_test.cc
Normal file
36
libretroshare/src/tests/gxs/rsgenexchange_test.cc
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
|
||||
#include "genexchangetester.h"
|
||||
#include "genexchangetestservice.h"
|
||||
#include "util/utest.h"
|
||||
#include "gxs/gxscoreserver.h"
|
||||
#include "gxs/rsdataservice.h"
|
||||
#include "rsdummyservices.h"
|
||||
|
||||
INITTEST();
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
GenExchangeTester tester;
|
||||
|
||||
CHECK(tester.testMsgSubmissionRetrieval()); REPORT("testMsgSubmissionRetrieval()");
|
||||
CHECK(tester.testSpecificMsgMetaRetrieval()); REPORT("testSpecificMsgMetaRetrieval()");
|
||||
CHECK(tester.testMsgIdRetrieval()); REPORT("tester.testMsgIdRetrieval()");
|
||||
CHECK(tester.testMsgIdRetrieval_OptParents()); REPORT("tester.testRelatedMsgIdRetrieval_Parents()");
|
||||
CHECK(tester.testMsgIdRetrieval_OptOrigMsgId()); REPORT("tester.testRelatedMsgIdRetrieval_OrigMsgId()");
|
||||
CHECK(tester.testMsgIdRetrieval_OptLatest()); REPORT("tester.testRelatedMsgIdRetrieval_Latest()");
|
||||
CHECK(tester.testMsgMetaModRequest()); REPORT("tester.testMsgMetaModRequest()");
|
||||
CHECK(tester.testMsgRelatedChildDataRetrieval()); REPORT("tester.testMsgRelatedChildDataRetrieval()");
|
||||
CHECK(tester.testMsgRelatedChildDataRetrieval_Multi()); REPORT("tester.testMsgRelatedChildDataRetrieval_Multi()");
|
||||
CHECK(tester.testMsgAllVersions()); REPORT("tester.testMsgAllVersions()");
|
||||
|
||||
CHECK(tester.testGrpSubmissionRetrieval()); REPORT("tester.testGrpSubmissionRetrieval()");
|
||||
CHECK(tester.testGrpMetaRetrieval()); REPORT("tester.testGrpMetaRetrieval()");
|
||||
CHECK(tester.testGrpIdRetrieval()); REPORT("tester.testGrpIdRetrieval()");
|
||||
CHECK(tester.testGrpMetaModRequest()); REPORT("tester.testGrpMetaModRequest()");
|
||||
|
||||
FINALREPORT("RsGenExchangeTest");
|
||||
|
||||
return 0;
|
||||
}
|
71
libretroshare/src/tests/gxs/rsgenexhchange_test.pro
Normal file
71
libretroshare/src/tests/gxs/rsgenexhchange_test.pro
Normal file
|
@ -0,0 +1,71 @@
|
|||
|
||||
TEMPLATE = app
|
||||
TARGET = rsgenexcahnge_test
|
||||
CONFIG += debug
|
||||
|
||||
win32 {
|
||||
|
||||
DEFINES *= WINDOWS_SYS \
|
||||
WIN32 \
|
||||
STATICLIB \
|
||||
MINGW
|
||||
|
||||
# Switch on extra warnings
|
||||
QMAKE_CFLAGS += -Wextra
|
||||
QMAKE_CXXFLAGS += -Wextra
|
||||
|
||||
# Switch off optimization for release version
|
||||
QMAKE_CXXFLAGS_RELEASE -= -O2
|
||||
QMAKE_CXXFLAGS_RELEASE += -O0
|
||||
QMAKE_CFLAGS_RELEASE -= -O2
|
||||
QMAKE_CFLAGS_RELEASE += -O0
|
||||
|
||||
# Switch on optimization for debug version
|
||||
#QMAKE_CXXFLAGS_DEBUG += -O2
|
||||
#QMAKE_CFLAGS_DEBUG += -O2
|
||||
|
||||
# PRE_TARGETDEPS += ../../libretroshare/src/lib/libretroshare.a
|
||||
PRE_TARGETDEPS += C:\Development\Rs\v0.5-gxs-b1/libretroshare/libretroshare-build-desktop/lib/libretroshare.a
|
||||
|
||||
LIBS += C:\Development\Rs\v0.5-gxs-b1/libretroshare/libretroshare-build-desktop/lib/libretroshare.a
|
||||
LIBS += C:\Development\Rs\v0.5-gxs-b1\openpgpsdk\openpgpsdk-build-desktop\lib\libops.a
|
||||
LIBS += C:\Development\Libraries\sqlite\sqlite-autoconf-3070900\lib\libsqlite3.a
|
||||
LIBS += -L"../lib"
|
||||
LIBS += -lssl -lcrypto -lgpgme -lpthreadGC2d -lminiupnpc -lz -lbz2
|
||||
# added after bitdht
|
||||
# LIBS += -lws2_32
|
||||
LIBS += -luuid -lole32 -liphlpapi -lcrypt32-cygwin -lgdi32
|
||||
LIBS += -lole32 -lwinmm
|
||||
|
||||
# export symbols for the plugins
|
||||
#LIBS += -Wl,--export-all-symbols,--out-implib,lib/libretroshare-gui.a
|
||||
|
||||
GPG_ERROR_DIR = ../../../../libgpg-error-1.7
|
||||
GPGME_DIR = ../../../../gpgme-1.1.8
|
||||
GPG_ERROR_DIR = ../../../../lib/libgpg-error-1.7
|
||||
GPGME_DIR = ../../../../lib/gpgme-1.1.8
|
||||
INCLUDEPATH += . $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src
|
||||
SQLITE_DIR = ../../Libraries/sqlite/sqlite-autoconf-3070900
|
||||
INCLUDEPATH += . \
|
||||
$${SQLITE_DIR}
|
||||
|
||||
LIBS += -lws2_32
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
INCLUDEPATH += C:\Development\Rs\v0.5-gxs-b1\libretroshare\src
|
||||
|
||||
HEADERS += \
|
||||
genexchangetestservice.h \
|
||||
genexchangetester.h \
|
||||
rsdummyservices.h \
|
||||
support.h
|
||||
|
||||
SOURCES += \
|
||||
genexchangetestservice.cpp \
|
||||
genexchangetester.cpp \
|
||||
rsgenexchange_test.cc \
|
||||
support.cc \
|
||||
rsdummyservices.cc
|
|
@ -49,8 +49,7 @@ int main()
|
|||
|
||||
bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r)
|
||||
{
|
||||
if(!(l.adminSign == r.adminSign)) return false;
|
||||
if(!(l.idSign == r.idSign)) return false;
|
||||
if(!(l.signSet == r.signSet)) return false;
|
||||
if(!(l.keys == r.keys)) return false;
|
||||
if(l.mGroupFlags != r.mGroupFlags) return false;
|
||||
if(l.mPublishTs != r.mPublishTs) return false;
|
||||
|
@ -64,8 +63,7 @@ bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r)
|
|||
bool operator ==(const RsGxsMsgMetaData& l, const RsGxsMsgMetaData& r)
|
||||
{
|
||||
|
||||
if(!(l.idSign == r.idSign)) return false;
|
||||
if(!(l.pubSign == r.pubSign)) return false;
|
||||
if(!(l.signSet == r.signSet)) return false;
|
||||
if(l.mGroupId != r.mGroupId) return false;
|
||||
if(l.mAuthorId != r.mAuthorId) return false;
|
||||
if(l.mParentId != r.mParentId) return false;
|
||||
|
|
|
@ -17,13 +17,23 @@ int main()
|
|||
|
||||
// first setup
|
||||
NxsMessageTest msgTest(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
NxsTestHub hub(&msgTest);
|
||||
std::set<std::string> peers;
|
||||
peers.insert("PeerA");
|
||||
peers.insert("PeerB");
|
||||
NxsTestHub hub(&msgTest, peers);
|
||||
|
||||
// now get things started
|
||||
createThread(hub);
|
||||
|
||||
double timeDelta = 50;
|
||||
|
||||
// put this thread to sleep for 10 secs
|
||||
sleep(10);
|
||||
// make thread sleep for a bit
|
||||
#ifndef WINDOWS_SYS
|
||||
usleep((int) (timeDelta * 1000000));
|
||||
#else
|
||||
Sleep((int) (timeDelta * 1000));
|
||||
#endif
|
||||
|
||||
hub.join();
|
||||
CHECK(hub.testsPassed());
|
||||
|
|
|
@ -103,6 +103,30 @@ bool operator==(const RsTlvSecurityKey& sk1, const RsTlvSecurityKey& sk2)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const RsTlvKeySignatureSet& kss1, const RsTlvKeySignatureSet& kss2)
|
||||
{
|
||||
const std::map<SignType, RsTlvKeySignature>& set1 = kss1.keySignSet,
|
||||
&set2 = kss2.keySignSet;
|
||||
|
||||
if(set1.size() != set2.size()) return false;
|
||||
|
||||
std::map<SignType, RsTlvKeySignature>::const_iterator it1 = set1.begin(), it2;
|
||||
|
||||
for(; it1 != set1.end(); it1++)
|
||||
{
|
||||
SignType st1 = it1->first;
|
||||
|
||||
if( (it2 =set2.find(st1)) == set2.end())
|
||||
return false;
|
||||
|
||||
if(!(it1->second == it2->second))
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const RsTlvKeySignature& ks1, const RsTlvKeySignature& ks2)
|
||||
{
|
||||
|
||||
|
@ -138,6 +162,19 @@ void init_item(RsTlvImage& im)
|
|||
return;
|
||||
}
|
||||
|
||||
void init_item(RsTlvKeySignatureSet &kss)
|
||||
{
|
||||
int numSign = rand()%21;
|
||||
|
||||
for(int i=0; i < numSign; i++)
|
||||
{
|
||||
RsTlvKeySignature sign;
|
||||
SignType sType = rand()%2452;
|
||||
init_item(sign);
|
||||
kss.keySignSet.insert(std::make_pair(sType, sign));
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const RsTlvBinaryData& bd1, const RsTlvBinaryData& bd2)
|
||||
{
|
||||
if(bd1.tlvtype != bd2.tlvtype) return false;
|
||||
|
|
|
@ -56,6 +56,7 @@ void randString(const uint32_t, std::wstring&);
|
|||
|
||||
void init_item(RsTlvSecurityKey&);
|
||||
void init_item(RsTlvKeySignature&);
|
||||
void init_item(RsTlvKeySignatureSet&);
|
||||
void init_item(RsTlvBinaryData&);
|
||||
void init_item(RsTlvFileItem&);
|
||||
void init_item(RsTlvFileSet&);
|
||||
|
@ -74,6 +75,7 @@ bool operator==(const RsTlvHashSet&, const RsTlvHashSet&);
|
|||
bool operator==(const RsTlvImage&, const RsTlvImage& );
|
||||
bool operator==(const RsTlvPeerIdSet& , const RsTlvPeerIdSet& );
|
||||
bool operator==(const RsTlvSecurityKeySet& , const RsTlvSecurityKeySet& );
|
||||
bool operator==(const RsTlvKeySignatureSet& , const RsTlvKeySignatureSet& );
|
||||
|
||||
|
||||
|
||||
|
|
139
libretroshare/src/tests/serialiser/rsphotoitem_test.cc
Normal file
139
libretroshare/src/tests/serialiser/rsphotoitem_test.cc
Normal file
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* libretroshare/src/test rsphotoitem_test.cc
|
||||
*
|
||||
* Test for photo item serialisation
|
||||
*
|
||||
* Copyright 2012-2012 by Christopher Evi-Parker
|
||||
*
|
||||
* 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 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 "rsphotoitem_test.h"
|
||||
|
||||
|
||||
RsSerialType* init_item(RsGxsPhotoAlbumItem &album)
|
||||
{
|
||||
RsPhotoAlbum& a = album.album;
|
||||
|
||||
randString(SHORT_STR, a.mCaption);
|
||||
randString(SHORT_STR, a.mCategory);
|
||||
randString(SHORT_STR, a.mDescription);
|
||||
randString(SHORT_STR, a.mHashTags);
|
||||
randString(SHORT_STR, a.mOther);
|
||||
randString(SHORT_STR, a.mPhotoPath);
|
||||
randString(SHORT_STR, a.mPhotographer);
|
||||
randString(SHORT_STR, a.mWhen);
|
||||
randString(SHORT_STR, a.mWhere);
|
||||
randString(SHORT_STR, a.mThumbnail.type);
|
||||
std::string rStr;
|
||||
randString(SHORT_STR, rStr);
|
||||
|
||||
a.mThumbnail.data = new uint8_t[SHORT_STR];
|
||||
memcpy(a.mThumbnail.data, rStr.data(), SHORT_STR);
|
||||
a.mThumbnail.size = SHORT_STR;
|
||||
|
||||
return new RsGxsPhotoSerialiser();
|
||||
}
|
||||
|
||||
RsSerialType* init_item(RsGxsPhotoPhotoItem &photo)
|
||||
{
|
||||
|
||||
RsPhotoPhoto& p = photo.photo;
|
||||
|
||||
randString(SHORT_STR, p.mCaption);
|
||||
randString(SHORT_STR, p.mCategory);
|
||||
randString(SHORT_STR, p.mDescription);
|
||||
randString(SHORT_STR, p.mHashTags);
|
||||
randString(SHORT_STR, p.mOther);
|
||||
randString(SHORT_STR, p.mPhotographer);
|
||||
randString(SHORT_STR, p.mWhen);
|
||||
randString(SHORT_STR, p.mWhere);
|
||||
randString(SHORT_STR, p.mThumbnail.type);
|
||||
std::string rStr;
|
||||
randString(SHORT_STR, rStr);
|
||||
|
||||
p.mThumbnail.data = new uint8_t[SHORT_STR];
|
||||
memcpy(p.mThumbnail.data, rStr.data(), SHORT_STR);
|
||||
p.mThumbnail.size = SHORT_STR;
|
||||
|
||||
return new RsGxsPhotoSerialiser();
|
||||
}
|
||||
|
||||
|
||||
bool operator == (RsGxsPhotoAlbumItem& l, RsGxsPhotoAlbumItem& r)
|
||||
{
|
||||
RsPhotoAlbum& la = l.album;
|
||||
RsPhotoAlbum& ra = r.album;
|
||||
|
||||
if(la.mCaption != ra.mCaption) return false;
|
||||
if(la.mCategory != ra.mCategory) return false;
|
||||
if(la.mDescription != ra.mDescription) return false;
|
||||
if(la.mHashTags != ra.mHashTags) return false;
|
||||
if(la.mOther != ra.mOther) return false;
|
||||
if(la.mPhotographer!= ra.mPhotographer) return false;
|
||||
if(la.mPhotoPath != ra.mPhotoPath) return false;
|
||||
if(la.mWhere != ra.mWhere) return false;
|
||||
if(la.mWhen != ra.mWhen) return false;
|
||||
if(!(la.mThumbnail == ra.mThumbnail)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool operator == (RsGxsPhotoPhotoItem& l, RsGxsPhotoPhotoItem& r)
|
||||
{
|
||||
RsPhotoPhoto& la = l.photo;
|
||||
RsPhotoPhoto& ra = r.photo;
|
||||
|
||||
if(la.mCaption != ra.mCaption) return false;
|
||||
if(la.mCategory != ra.mCategory) return false;
|
||||
if(la.mDescription != ra.mDescription) return false;
|
||||
if(la.mHashTags != ra.mHashTags) return false;
|
||||
if(la.mOther != ra.mOther) return false;
|
||||
if(la.mPhotographer!= ra.mPhotographer) return false;
|
||||
if(la.mWhere != ra.mWhere) return false;
|
||||
if(la.mWhen != ra.mWhen) return false;
|
||||
if(!(la.mThumbnail == ra.mThumbnail)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator == (RsPhotoThumbnail& l, RsPhotoThumbnail& r)
|
||||
{
|
||||
if(l.size != r.size) return false;
|
||||
if(l.type != r.type) return false;
|
||||
if(memcmp(l.data, r.data,l.size) != 0) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
INITTEST()
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cerr << "RsPhotoItem Tests" << std::endl;
|
||||
|
||||
test_RsItem<RsGxsPhotoAlbumItem>(); REPORT("Serialise/Deserialise RsGxsPhotoAlbumItem");
|
||||
test_RsItem<RsGxsPhotoPhotoItem>(); REPORT("Serialise/Deserialise RsGxsPhotoPhotoItem");
|
||||
|
||||
FINALREPORT("RsPhotoItem Tests");
|
||||
|
||||
return TESTRESULT();
|
||||
}
|
41
libretroshare/src/tests/serialiser/rsphotoitem_test.h
Normal file
41
libretroshare/src/tests/serialiser/rsphotoitem_test.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* libretroshare/src/test rsphotoitem_test.h
|
||||
*
|
||||
* Test for photo item serialisation
|
||||
*
|
||||
* Copyright 2012-2012 by Christopher Evi-Parker
|
||||
*
|
||||
* 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 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".
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef RSPHOTOITEM_TEST_H_
|
||||
#define RSPHOTOITEM_TEST_H_
|
||||
|
||||
#include "serialiser/rsphotov2items.h"
|
||||
#include "support.h"
|
||||
|
||||
|
||||
|
||||
RsSerialType* init_item(RsGxsPhotoAlbumItem& album);
|
||||
RsSerialType* init_item(RsGxsPhotoPhotoItem& photo);
|
||||
|
||||
bool operator == (RsGxsPhotoAlbumItem& l, RsGxsPhotoAlbumItem& r);
|
||||
bool operator == (RsGxsPhotoPhotoItem& l, RsGxsPhotoPhotoItem& r);
|
||||
bool operator == (RsPhotoThumbnail& l, RsPhotoThumbnail& r);
|
||||
|
||||
#endif /* RSPHOTOITEM_TEST_H_ */
|
|
@ -81,6 +81,30 @@ bool operator==(const RsTlvKeySignature& ks1, const RsTlvKeySignature& ks2)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const RsTlvKeySignatureSet& kss1, const RsTlvKeySignatureSet& kss2)
|
||||
{
|
||||
const std::map<SignType, RsTlvKeySignature>& set1 = kss1.keySignSet,
|
||||
&set2 = kss2.keySignSet;
|
||||
|
||||
if(set1.size() != set2.size()) return false;
|
||||
|
||||
std::map<SignType, RsTlvKeySignature>::const_iterator it1 = set1.begin(), it2;
|
||||
|
||||
for(; it1 != set1.end(); it1++)
|
||||
{
|
||||
SignType st1 = it1->first;
|
||||
|
||||
if( (it2 =set2.find(st1)) == set2.end())
|
||||
return false;
|
||||
|
||||
if(!(it1->second == it2->second))
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const RsTlvPeerIdSet& pids1, const RsTlvPeerIdSet& pids2)
|
||||
{
|
||||
std::list<std::string>::const_iterator it1 = pids1.ids.begin(),
|
||||
|
@ -153,6 +177,18 @@ void init_item(RsTlvKeySignature& ks)
|
|||
|
||||
return;
|
||||
}
|
||||
void init_item(RsTlvKeySignatureSet &kss)
|
||||
{
|
||||
int numSign = rand()%21;
|
||||
|
||||
for(int i=0; i < numSign; i++)
|
||||
{
|
||||
RsTlvKeySignature sign;
|
||||
SignType sType = rand()%2452;
|
||||
init_item(sign);
|
||||
kss.keySignSet.insert(std::make_pair(sType, sign));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool operator==(const RsTlvImage& img1, const RsTlvImage& img2)
|
||||
|
|
|
@ -56,6 +56,7 @@ void randString(const uint32_t, std::wstring&);
|
|||
|
||||
void init_item(RsTlvSecurityKey&);
|
||||
void init_item(RsTlvKeySignature&);
|
||||
void init_item(RsTlvKeySignatureSet&);
|
||||
void init_item(RsTlvBinaryData&);
|
||||
void init_item(RsTlvFileItem&);
|
||||
void init_item(RsTlvFileSet&);
|
||||
|
@ -72,6 +73,7 @@ bool operator==(const RsTlvFileSet&, const RsTlvFileSet& );
|
|||
bool operator==(const RsTlvHashSet&, const RsTlvHashSet&);
|
||||
bool operator==(const RsTlvImage&, const RsTlvImage& );
|
||||
bool operator==(const RsTlvPeerIdSet& , const RsTlvPeerIdSet& );
|
||||
bool operator==(const RsTlvKeySignatureSet& , const RsTlvKeySignatureSet& );
|
||||
|
||||
|
||||
|
||||
|
|
36
libretroshare/src/tests/serialiser/tlvkey_test.cc
Normal file
36
libretroshare/src/tests/serialiser/tlvkey_test.cc
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
|
||||
#include "support.h"
|
||||
#include "serialiser/rstlvkeys.h"
|
||||
|
||||
INITTEST();
|
||||
|
||||
bool test_RsTlvKeySignatureSet();
|
||||
|
||||
int main()
|
||||
{
|
||||
test_RsTlvKeySignatureSet(); REPORT("test_RsTlvKeySignatureSet()");
|
||||
|
||||
FINALREPORT("RsTlvKey Test");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool test_RsTlvKeySignatureSet()
|
||||
{
|
||||
RsTlvKeySignatureSet set;
|
||||
|
||||
init_item(set);
|
||||
|
||||
char data[set.TlvSize()];
|
||||
uint32_t offset = 0;
|
||||
set.SetTlv(data, set.TlvSize(), &offset);
|
||||
|
||||
RsTlvKeySignatureSet setConfirm;
|
||||
|
||||
offset = 0;
|
||||
setConfirm.GetTlv(data, set.TlvSize(), &offset);
|
||||
|
||||
CHECK(setConfirm == set);
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue