mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-11 07:29:38 -05:00
Added Gxs Service tests
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7267 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
df4cf6030e
commit
181dc9111b
@ -0,0 +1,88 @@
|
||||
|
||||
// from librssimulator
|
||||
#include "testing/IsolatedServiceTester.h"
|
||||
#include "peer/PeerNode.h"
|
||||
|
||||
// from libretroshare
|
||||
#include "services/p3statusservice.h"
|
||||
#include "serialiser/rsstatusitems.h"
|
||||
#include "gxs/rsgixs.h"
|
||||
#include "gxs/rsdataservice.h"
|
||||
#include "gxs/rsgxsnetservice.h"
|
||||
#include "util/rsdir.h"
|
||||
|
||||
// local
|
||||
#include "GxsIsolatedServiceTester.h"
|
||||
#include "gxstestservice.h"
|
||||
|
||||
GxsIsolatedServiceTester::GxsIsolatedServiceTester(const RsPeerId &ownId, const RsPeerId &friendId,
|
||||
std::list<RsPeerId> peers, int testMode)
|
||||
:IsolatedServiceTester(ownId, peers),
|
||||
mTestMode(testMode),
|
||||
mGxsDir("./gxs_unittest/"),
|
||||
mGxsIdService(NULL),
|
||||
mGxsCircles(NULL),
|
||||
mTestService(NULL),
|
||||
mTestDs(NULL),
|
||||
mTestNs(NULL)
|
||||
{
|
||||
// extract bits we need.
|
||||
PeerNode *node = getPeerNode();
|
||||
p3PeerMgr *peerMgr = node->getPeerMgr();
|
||||
p3LinkMgr *linkMgr = node->getLinkMgr();
|
||||
p3NetMgr *netMgr = node->getNetMgr();
|
||||
RsNxsNetMgr *nxsMgr = node->getNxsNetMgr();
|
||||
p3ServiceControl *serviceCtrl = node->getServiceControl();
|
||||
|
||||
// Create Service for Testing.
|
||||
// Specific Testing service here.
|
||||
RsDirUtil::checkCreateDirectory(mGxsDir);
|
||||
|
||||
std::set<std::string> filesToKeep;
|
||||
RsDirUtil::cleanupDirectory(mGxsDir, filesToKeep);
|
||||
|
||||
mTestDs = new RsDataService(mGxsDir, "test_db",
|
||||
RS_SERVICE_GXS_TYPE_TEST,
|
||||
NULL, "testPasswd");
|
||||
|
||||
mTestService = new GxsTestService(mTestDs, NULL, mGxsIdService, testMode);
|
||||
|
||||
mTestNs = new RsGxsNetService(
|
||||
RS_SERVICE_GXS_TYPE_TEST, mTestDs, nxsMgr,
|
||||
mTestService, mTestService->getServiceInfo(),
|
||||
mGxsIdService, mGxsCircles);
|
||||
|
||||
node->AddService(mTestNs);
|
||||
|
||||
//mConfigMgr->addConfiguration("posted.cfg", posted_ns);
|
||||
createThread(*mTestService);
|
||||
createThread(*mTestNs);
|
||||
|
||||
//node->AddPqiServiceMonitor(status);
|
||||
addSerialType(new RsNxsSerialiser(RS_SERVICE_GXS_TYPE_TEST));
|
||||
|
||||
startup();
|
||||
tick();
|
||||
|
||||
std::list<RsPeerId> onlineList;
|
||||
onlineList.push_back(friendId);
|
||||
node->bringOnline(onlineList);
|
||||
}
|
||||
|
||||
|
||||
GxsIsolatedServiceTester::~GxsIsolatedServiceTester()
|
||||
{
|
||||
mTestService->join();
|
||||
mTestNs->join();
|
||||
|
||||
delete mTestNs;
|
||||
delete mTestService;
|
||||
// this is deleted somewhere else?
|
||||
//delete mTestDs;
|
||||
|
||||
std::set<std::string> filesToKeep;
|
||||
RsDirUtil::cleanupDirectory(mGxsDir, filesToKeep);
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
// from librssimulator
|
||||
#include "testing/IsolatedServiceTester.h"
|
||||
|
||||
class RsGxsIdExchange;
|
||||
class RsGxsCircleExchange;
|
||||
class GxsTestService;
|
||||
class RsGeneralDataService;
|
||||
class RsGxsNetService;
|
||||
|
||||
class GxsIsolatedServiceTester: public IsolatedServiceTester
|
||||
{
|
||||
public:
|
||||
|
||||
GxsIsolatedServiceTester(const RsPeerId &ownId, const RsPeerId &friendId, std::list<RsPeerId> peers, int testMode);
|
||||
~GxsIsolatedServiceTester();
|
||||
|
||||
uint32_t mTestMode;
|
||||
std::string mGxsDir;
|
||||
|
||||
// Id and Circle Interfaces. (NULL for now).
|
||||
RsGxsIdExchange *mGxsIdService;
|
||||
RsGxsCircleExchange *mGxsCircles;
|
||||
|
||||
GxsTestService *mTestService;
|
||||
RsGeneralDataService* mTestDs;
|
||||
RsGxsNetService* mTestNs;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
292
tests/unittests/libretroshare/services/gxs/gxstestservice.cc
Normal file
292
tests/unittests/libretroshare/services/gxs/gxstestservice.cc
Normal file
@ -0,0 +1,292 @@
|
||||
/*
|
||||
* libretroshare/src/services p3wiki.cc
|
||||
*
|
||||
* Wiki interface for RetroShare.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie.
|
||||
*
|
||||
* 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.1 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 "gxstestservice.h"
|
||||
#include "retroshare/rsgxsflags.h"
|
||||
#include "rsgxstestitems.h"
|
||||
|
||||
#include "util/rsrandom.h"
|
||||
|
||||
GxsTestService::GxsTestService(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs *gixs, uint32_t testMode)
|
||||
:RsGenExchange(gds, nes, new RsGxsTestSerialiser(), RS_SERVICE_GXS_TYPE_TEST, gixs, testAuthenPolicy(testMode)),
|
||||
RsGxsIfaceHelper(this),
|
||||
mTestMode(testMode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const std::string GXS_TEST_APP_NAME = "gxstest";
|
||||
const uint16_t GXS_TEST_APP_MAJOR_VERSION = 1;
|
||||
const uint16_t GXS_TEST_APP_MINOR_VERSION = 0;
|
||||
const uint16_t GXS_TEST_MIN_MAJOR_VERSION = 1;
|
||||
const uint16_t GXS_TEST_MIN_MINOR_VERSION = 0;
|
||||
|
||||
RsServiceInfo GxsTestService::getServiceInfo()
|
||||
{
|
||||
return RsServiceInfo(RS_SERVICE_GXS_TYPE_TEST,
|
||||
GXS_TEST_APP_NAME,
|
||||
GXS_TEST_APP_MAJOR_VERSION,
|
||||
GXS_TEST_APP_MINOR_VERSION,
|
||||
GXS_TEST_MIN_MAJOR_VERSION,
|
||||
GXS_TEST_MIN_MINOR_VERSION);
|
||||
}
|
||||
|
||||
|
||||
uint32_t GxsTestService::testAuthenPolicy(uint32_t testMode)
|
||||
{
|
||||
uint32_t policy = 0;
|
||||
uint8_t flag = 0;
|
||||
|
||||
// Edits generally need an authors signature.
|
||||
|
||||
flag = GXS_SERV::MSG_AUTHEN_ROOT_PUBLISH_SIGN | GXS_SERV::MSG_AUTHEN_CHILD_AUTHOR_SIGN;
|
||||
RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::PUBLIC_GRP_BITS);
|
||||
|
||||
flag |= GXS_SERV::MSG_AUTHEN_CHILD_PUBLISH_SIGN;
|
||||
RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::RESTRICTED_GRP_BITS);
|
||||
RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::PRIVATE_GRP_BITS);
|
||||
|
||||
flag = 0;
|
||||
RsGenExchange::setAuthenPolicyFlag(flag, policy, RsGenExchange::GRP_OPTION_BITS);
|
||||
|
||||
return policy;
|
||||
}
|
||||
|
||||
|
||||
void GxsTestService::service_tick()
|
||||
{
|
||||
RsTickEvent::tick_events();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void GxsTestService::notifyChanges(std::vector<RsGxsNotify*>& changes)
|
||||
{
|
||||
std::cerr << "GxsTestService::notifyChanges() New stuff";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsGxsIfaceHelper::receiveChanges(changes);
|
||||
}
|
||||
|
||||
/* Specific Service Data */
|
||||
bool GxsTestService::getTestGroups(const uint32_t &token, std::vector<RsTestGroup> &groups)
|
||||
{
|
||||
std::cerr << "GxsTestService::getTestGroups()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::vector<RsGxsGrpItem*> grpData;
|
||||
bool ok = RsGenExchange::getGroupData(token, grpData);
|
||||
|
||||
if(ok)
|
||||
{
|
||||
std::vector<RsGxsGrpItem*>::iterator vit = grpData.begin();
|
||||
|
||||
for(; vit != grpData.end(); vit++)
|
||||
{
|
||||
RsGxsTestGroupItem* item = dynamic_cast<RsGxsTestGroupItem*>(*vit);
|
||||
|
||||
if (item)
|
||||
{
|
||||
RsTestGroup group = item->group;
|
||||
group.mMeta = item->meta;
|
||||
delete item;
|
||||
groups.push_back(group);
|
||||
|
||||
std::cerr << "GxsTestService::getTestGroups() Adding Group to Vector: ";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << group;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Not a TestGroupItem, deleting!" << std::endl;
|
||||
delete *vit;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool GxsTestService::getTestMsgs(const uint32_t &token, std::vector<RsTestMsg> &msgs)
|
||||
{
|
||||
GxsMsgDataMap msgData;
|
||||
bool ok = RsGenExchange::getMsgData(token, msgData);
|
||||
|
||||
if(ok)
|
||||
{
|
||||
GxsMsgDataMap::iterator mit = msgData.begin();
|
||||
|
||||
for(; mit != msgData.end(); mit++)
|
||||
{
|
||||
RsGxsGroupId grpId = mit->first;
|
||||
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
||||
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
||||
|
||||
for(; vit != msgItems.end(); vit++)
|
||||
{
|
||||
RsGxsTestMsgItem* item = dynamic_cast<RsGxsTestMsgItem*>(*vit);
|
||||
|
||||
if(item)
|
||||
{
|
||||
RsTestMsg msg = item->msg;
|
||||
msg.mMeta = item->meta;
|
||||
msgs.push_back(msg);
|
||||
delete item;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Not a TestMsg Item, deleting!" << std::endl;
|
||||
delete *vit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool GxsTestService::getRelatedMsgs(const uint32_t &token, std::vector<RsTestMsg> &msgs)
|
||||
{
|
||||
GxsMsgRelatedDataMap msgData;
|
||||
bool ok = RsGenExchange::getMsgRelatedData(token, msgData);
|
||||
|
||||
if(ok)
|
||||
{
|
||||
GxsMsgRelatedDataMap::iterator mit = msgData.begin();
|
||||
|
||||
for(; mit != msgData.end(); mit++)
|
||||
{
|
||||
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
|
||||
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
|
||||
|
||||
for(; vit != msgItems.end(); vit++)
|
||||
{
|
||||
RsGxsTestMsgItem* item = dynamic_cast<RsGxsTestMsgItem*>(*vit);
|
||||
|
||||
if(item)
|
||||
{
|
||||
RsTestMsg msg = item->msg;
|
||||
msg.mMeta = item->meta;
|
||||
msgs.push_back(msg);
|
||||
delete item;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Not a TestMsg Item, deleting!" << std::endl;
|
||||
delete *vit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool GxsTestService::submitTestGroup(uint32_t &token, RsTestGroup &group)
|
||||
{
|
||||
RsGxsTestGroupItem* groupItem = new RsGxsTestGroupItem();
|
||||
groupItem->group = group;
|
||||
groupItem->meta = group.mMeta;
|
||||
|
||||
std::cerr << "GxsTestService::submitTestGroup(): ";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << group;
|
||||
std::cerr << std::endl;
|
||||
|
||||
std::cerr << "GxsTestService::submitTestGroup() pushing to RsGenExchange";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsGenExchange::publishGroup(token, groupItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool GxsTestService::submitTestMsg(uint32_t &token, RsTestMsg &msg)
|
||||
{
|
||||
std::cerr << "GxsTestService::submitTestMsg(): " << msg;
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsGxsTestMsgItem* msgItem = new RsGxsTestMsgItem();
|
||||
msgItem->msg = msg;
|
||||
msgItem->meta = msg.mMeta;
|
||||
|
||||
RsGenExchange::publishMsg(token, msgItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GxsTestService::updateTestGroup(uint32_t &token, RsTestGroup &group)
|
||||
{
|
||||
std::cerr << "GxsTestService::updateTestGroup()" << std::endl;
|
||||
|
||||
RsGxsTestGroupItem* grpItem = new RsGxsTestGroupItem();
|
||||
grpItem->group = group;
|
||||
grpItem->meta = group.mMeta;
|
||||
|
||||
RsGenExchange::updateGroup(token, grpItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsTestGroup &group)
|
||||
{
|
||||
out << "RsTestGroup [ ";
|
||||
out << " Name: " << group.mMeta.mGroupName;
|
||||
out << " TestString: " << group.mTestString;
|
||||
out << " ]";
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsTestMsg &msg)
|
||||
{
|
||||
out << "RsTestMsg [ ";
|
||||
out << " Name: " << msg.mMeta.mMsgName;
|
||||
out << " TestString: " << msg.mTestString;
|
||||
out << "]";
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
// Overloaded from RsTickEvent for Event callbacks.
|
||||
void GxsTestService::handle_event(uint32_t event_type, const std::string &elabel)
|
||||
{
|
||||
std::cerr << "GxsTestService::handle_event(" << event_type << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
// stuff.
|
||||
switch(event_type)
|
||||
{
|
||||
default:
|
||||
/* error */
|
||||
std::cerr << "GxsTestService::handle_event() Unknown Event Type: " << event_type;
|
||||
std::cerr << std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
96
tests/unittests/libretroshare/services/gxs/gxstestservice.h
Normal file
96
tests/unittests/libretroshare/services/gxs/gxstestservice.h
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* libretroshare/src/services: p3wikiservice.h
|
||||
*
|
||||
* Wiki interface for RetroShare.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie.
|
||||
*
|
||||
* 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.1 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".
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gxs/rsgenexchange.h"
|
||||
#include "util/rstickevent.h"
|
||||
|
||||
#include "retroshare/rstokenservice.h"
|
||||
#include "retroshare/rsgxsifacehelper.h"
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
/*
|
||||
* Test Service.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#define RS_SERVICE_GXS_TYPE_TEST 0x123
|
||||
|
||||
class RsTestGroup
|
||||
{
|
||||
public:
|
||||
RsGroupMetaData mMeta;
|
||||
std::string mTestString;
|
||||
};
|
||||
|
||||
class RsTestMsg
|
||||
{
|
||||
public:
|
||||
RsMsgMetaData mMeta;
|
||||
std::string mTestString;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsTestGroup &group);
|
||||
std::ostream &operator<<(std::ostream &out, const RsTestMsg &msg);
|
||||
|
||||
|
||||
class GxsTestService: public RsGenExchange, public RsTickEvent, public RsGxsIfaceHelper
|
||||
{
|
||||
public:
|
||||
GxsTestService(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs *gixs, uint32_t testMode);
|
||||
virtual RsServiceInfo getServiceInfo();
|
||||
static uint32_t testAuthenPolicy(uint32_t testMode);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) ;
|
||||
|
||||
// Overloaded from RsTickEvent.
|
||||
virtual void handle_event(uint32_t event_type, const std::string &elabel);
|
||||
|
||||
public:
|
||||
|
||||
virtual void service_tick();
|
||||
|
||||
/* Specific Service Data */
|
||||
virtual bool getTestGroups(const uint32_t &token, std::vector<RsTestGroup> &groups);
|
||||
virtual bool getTestMsgs(const uint32_t &token, std::vector<RsTestMsg> &msgs);
|
||||
virtual bool getRelatedMsgs(const uint32_t &token, std::vector<RsTestMsg> &msgs);
|
||||
|
||||
virtual bool submitTestGroup(uint32_t &token, RsTestGroup &group);
|
||||
virtual bool submitTestMsg(uint32_t &token, RsTestMsg &msg);
|
||||
|
||||
virtual bool updateTestGroup(uint32_t &token, RsTestGroup &group);
|
||||
|
||||
private:
|
||||
|
||||
uint32_t mTestMode;
|
||||
};
|
||||
|
195
tests/unittests/libretroshare/services/gxs/nxsbasic_test.cc
Normal file
195
tests/unittests/libretroshare/services/gxs/nxsbasic_test.cc
Normal file
@ -0,0 +1,195 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
// from librssimulator
|
||||
//#include "peer/PeerNode.h"
|
||||
|
||||
// from libretroshare
|
||||
//#include "gxs/rsgixs.h"
|
||||
//#include "gxs/rsdataservice.h"
|
||||
//#include "gxs/rsgxsnetservice.h"
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
|
||||
// local
|
||||
#include "GxsIsolatedServiceTester.h"
|
||||
#include "gxstestservice.h"
|
||||
|
||||
#define N_PEERS 10
|
||||
#define MAX_COUNT 5
|
||||
|
||||
/* Here we want to test the most basic NXS interactions.
|
||||
* we have a GXS service, with no AuthorIDs or Circles.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test 1: nothing in Groups.... only sync packets.
|
||||
*
|
||||
* This test is rather slow - should speed it up.
|
||||
*/
|
||||
|
||||
TEST(libretroshare_services, GXS_nxs_basic)
|
||||
{
|
||||
RsPeerId ownId = RsPeerId::random();
|
||||
RsPeerId friendId = RsPeerId::random();
|
||||
|
||||
std::list<RsPeerId> peers;
|
||||
peers.push_back(friendId);
|
||||
for(int i = 0; i < N_PEERS; i++)
|
||||
{
|
||||
peers.push_back(RsPeerId::random());
|
||||
}
|
||||
|
||||
int testMode = 0;
|
||||
GxsIsolatedServiceTester tester(ownId, friendId, peers, testMode);
|
||||
|
||||
int counter = 0;
|
||||
int syncGroupCount = 0;
|
||||
while((syncGroupCount < 2) && (counter < 30))
|
||||
{
|
||||
counter++;
|
||||
|
||||
// Send in Lots of SyncGrp packets
|
||||
// Expect nothing back - as its empty.
|
||||
std::cerr << "Sending in SyncGrp";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsNxsSyncGrp *syncGrp = new RsNxsSyncGrp(RS_SERVICE_GXS_TYPE_TEST);
|
||||
syncGrp->flag = 0; //RsNxsSyncGrp::FLAG_USE_SYNC_HASH;
|
||||
syncGrp->PeerId(friendId);
|
||||
tester.sendPacket(syncGrp);
|
||||
|
||||
// Expect only RsNxsSyncGrp messages.
|
||||
if (tester.tickUntilPacket(1))
|
||||
{
|
||||
RsItem *item = tester.getPacket();
|
||||
ASSERT_TRUE(item != NULL);
|
||||
item->print(std::cerr);
|
||||
|
||||
std::cerr << "Recved in SyncGrp";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsNxsSyncGrp *grp = dynamic_cast<RsNxsSyncGrp *>(item);
|
||||
ASSERT_TRUE(grp);
|
||||
delete grp;
|
||||
|
||||
syncGroupCount++;
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
ASSERT_TRUE(syncGroupCount >= 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Test 2: Create a Group ... should a response with Group List.
|
||||
* should test a full exchange.
|
||||
*
|
||||
*/
|
||||
|
||||
TEST(libretroshare_services, GXS_nxs_basic2)
|
||||
{
|
||||
RsPeerId ownId = RsPeerId::random();
|
||||
RsPeerId friendId = RsPeerId::random();
|
||||
|
||||
std::list<RsPeerId> peers;
|
||||
peers.push_back(friendId);
|
||||
for(int i = 0; i < N_PEERS; i++)
|
||||
{
|
||||
peers.push_back(RsPeerId::random());
|
||||
}
|
||||
|
||||
int testMode = 0;
|
||||
GxsIsolatedServiceTester tester(ownId, friendId, peers, testMode);
|
||||
|
||||
/* create a couple of groups */
|
||||
GxsTestService *testService = tester.mTestService;
|
||||
RsTokenService *tokenService = testService->RsGenExchange::getTokenService();
|
||||
|
||||
RsTestGroup grp1;
|
||||
grp1.mMeta.mGroupName = "grp1";
|
||||
grp1.mTestString = "test";
|
||||
uint32_t token1;
|
||||
|
||||
RsTestGroup grp2;
|
||||
grp2.mMeta.mGroupName = "grp2";
|
||||
grp2.mTestString = "test2";
|
||||
uint32_t token2;
|
||||
|
||||
ASSERT_TRUE(testService->submitTestGroup(token1, grp1));
|
||||
while(tokenService->requestStatus(token1) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
{
|
||||
tester.tick();
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
ASSERT_TRUE(testService->submitTestGroup(token2, grp2));
|
||||
while(tokenService->requestStatus(token2) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE)
|
||||
{
|
||||
tester.tick();
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
std::cerr << "Created Groups.";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsNxsSyncGrp *syncGrp = new RsNxsSyncGrp(RS_SERVICE_GXS_TYPE_TEST);
|
||||
syncGrp->flag = 0; //RsNxsSyncGrp::FLAG_USE_SYNC_HASH;
|
||||
syncGrp->PeerId(friendId);
|
||||
tester.sendPacket(syncGrp);
|
||||
|
||||
|
||||
// expect RsNxsTransac
|
||||
int counter = 0;
|
||||
bool recvedTransaction = false;
|
||||
|
||||
while((!recvedTransaction) && (counter < MAX_COUNT))
|
||||
{
|
||||
counter++;
|
||||
|
||||
// Expect only RsNxsSyncGrp messages.
|
||||
if (tester.tickUntilPacket(1))
|
||||
{
|
||||
RsItem *item = tester.getPacket();
|
||||
ASSERT_TRUE(item != NULL);
|
||||
|
||||
std::cerr << "Recved in Packet";
|
||||
std::cerr << std::endl;
|
||||
item->print(std::cerr);
|
||||
|
||||
// ignore NxsSyncGrp.
|
||||
RsNxsSyncGrp *grp = dynamic_cast<RsNxsSyncGrp *>(item);
|
||||
RsNxsTransac *trans = dynamic_cast<RsNxsTransac *>(item);
|
||||
if (grp)
|
||||
{
|
||||
std::cerr << "Recved in SyncGrp - ignoring";
|
||||
std::cerr << std::endl;
|
||||
delete grp;
|
||||
}
|
||||
else if (trans)
|
||||
{
|
||||
// Real expected packet.
|
||||
std::cerr << "Recved in RsNxsTransac";
|
||||
std::cerr << std::endl;
|
||||
recvedTransaction = true;
|
||||
|
||||
// Generate Next Step.
|
||||
}
|
||||
else
|
||||
{
|
||||
// ERROR.
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
}
|
||||
sleep(1);
|
||||
}
|
||||
ASSERT_TRUE(recvedTransaction);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
400
tests/unittests/libretroshare/services/gxs/rsgxstestitems.cc
Normal file
400
tests/unittests/libretroshare/services/gxs/rsgxstestitems.cc
Normal file
@ -0,0 +1,400 @@
|
||||
/*
|
||||
* libretroshare/src/serialiser: rsgxstestserviceitems.cc
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie
|
||||
*
|
||||
* 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.1 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 <iostream>
|
||||
|
||||
#include "rsgxstestitems.h"
|
||||
#include "serialiser/rstlvbase.h"
|
||||
#include "serialiser/rsbaseserial.h"
|
||||
|
||||
#define TEST_DEBUG 1
|
||||
|
||||
|
||||
uint32_t RsGxsTestSerialiser::size(RsItem *item)
|
||||
{
|
||||
RsGxsTestGroupItem* grp_item = NULL;
|
||||
RsGxsTestMsgItem* msg_item = NULL;
|
||||
|
||||
if((grp_item = dynamic_cast<RsGxsTestGroupItem*>(item)) != NULL)
|
||||
{
|
||||
return sizeGxsTestGroupItem(grp_item);
|
||||
}
|
||||
else if((msg_item = dynamic_cast<RsGxsTestMsgItem*>(item)) != NULL)
|
||||
{
|
||||
return sizeGxsTestMsgItem(msg_item);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool RsGxsTestSerialiser::serialise(RsItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
RsGxsTestGroupItem* grp_item = NULL;
|
||||
RsGxsTestMsgItem* msg_item = NULL;
|
||||
|
||||
if((grp_item = dynamic_cast<RsGxsTestGroupItem*>(item)) != NULL)
|
||||
{
|
||||
return serialiseGxsTestGroupItem(grp_item, data, size);
|
||||
}
|
||||
else if((msg_item = dynamic_cast<RsGxsTestMsgItem*>(item)) != NULL)
|
||||
{
|
||||
return serialiseGxsTestMsgItem(msg_item, data, size);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
RsItem* RsGxsTestSerialiser::deserialise(void* data, uint32_t* size)
|
||||
{
|
||||
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::deserialise()" << std::endl;
|
||||
#endif
|
||||
/* get the type and size */
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
|
||||
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
||||
(RS_SERVICE_GXS_TYPE_TEST != getRsItemService(rstype)))
|
||||
{
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
switch(getRsItemSubType(rstype))
|
||||
{
|
||||
|
||||
case RS_PKT_SUBTYPE_TEST_GROUP_ITEM:
|
||||
return deserialiseGxsTestGroupItem(data, size);
|
||||
break;
|
||||
case RS_PKT_SUBTYPE_TEST_MSG_ITEM:
|
||||
return deserialiseGxsTestMsgItem(data, size);
|
||||
break;
|
||||
default:
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::deserialise(): unknown subtype";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
|
||||
|
||||
void RsGxsTestGroupItem::clear()
|
||||
{
|
||||
group.mTestString.clear();
|
||||
}
|
||||
|
||||
std::ostream& RsGxsTestGroupItem::print(std::ostream& out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsGxsTestGroupItem", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "TestString: " << group.mTestString << std::endl;
|
||||
|
||||
printRsItemEnd(out ,"RsGxsTestGroupItem", indent);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
uint32_t RsGxsTestSerialiser::sizeGxsTestGroupItem(RsGxsTestGroupItem *item)
|
||||
{
|
||||
|
||||
const RsTestGroup& group = item->group;
|
||||
uint32_t s = 8; // header
|
||||
|
||||
s += GetTlvStringSize(group.mTestString);
|
||||
return s;
|
||||
}
|
||||
|
||||
bool RsGxsTestSerialiser::serialiseGxsTestGroupItem(RsGxsTestGroupItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::serialiseGxsTestGroupItem()" << std::endl;
|
||||
#endif
|
||||
|
||||
uint32_t tlvsize = sizeGxsTestGroupItem(item);
|
||||
uint32_t offset = 0;
|
||||
|
||||
if(*size < tlvsize)
|
||||
{
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::serialiseGxsTestGroupItem()" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
*size = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* GxsTestGroupItem */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_DESCR, item->group.mTestString);
|
||||
|
||||
if(offset != tlvsize)
|
||||
{
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::serialiseGxsTestGroupItem() FAIL Size Error! " << std::endl;
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
#ifdef TEST_DEBUG
|
||||
if (!ok)
|
||||
{
|
||||
std::cerr << "RsGxsTestSerialiser::serialiseGxsTestGroupItem() NOK" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
RsGxsTestGroupItem* RsGxsTestSerialiser::deserialiseGxsTestGroupItem(void *data, uint32_t *size)
|
||||
{
|
||||
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::deserialiseGxsTestGroupItem()" << std::endl;
|
||||
#endif
|
||||
/* 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_GXS_TYPE_TEST != getRsItemService(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_TEST_GROUP_ITEM != getRsItemSubType(rstype)))
|
||||
{
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::deserialiseGxsTestGroupItem() FAIL wrong type" << std::endl;
|
||||
#endif
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
if (*size < rssize) /* check size */
|
||||
{
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::deserialiseGxsTestGroupItem() FAIL wrong size" << std::endl;
|
||||
#endif
|
||||
return NULL; /* not enough data */
|
||||
}
|
||||
|
||||
/* set the packet length */
|
||||
*size = rssize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
RsGxsTestGroupItem* item = new RsGxsTestGroupItem();
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_DESCR, item->group.mTestString);
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::deserialiseGxsTestGroupItem() FAIL size mismatch" << std::endl;
|
||||
#endif
|
||||
/* error */
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::deserialiseGxsTestGroupItem() NOK" << std::endl;
|
||||
#endif
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
|
||||
|
||||
void RsGxsTestMsgItem::clear()
|
||||
{
|
||||
msg.mTestString.clear();
|
||||
}
|
||||
|
||||
std::ostream& RsGxsTestMsgItem::print(std::ostream& out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsGxsTestMsgItem", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "TestString: " << msg.mTestString << std::endl;
|
||||
|
||||
printRsItemEnd(out ,"RsGxsTestMsgItem", indent);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
uint32_t RsGxsTestSerialiser::sizeGxsTestMsgItem(RsGxsTestMsgItem *item)
|
||||
{
|
||||
|
||||
const RsTestMsg& msg = item->msg;
|
||||
uint32_t s = 8; // header
|
||||
|
||||
s += GetTlvStringSize(msg.mTestString);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
bool RsGxsTestSerialiser::serialiseGxsTestMsgItem(RsGxsTestMsgItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::serialiseGxsTestMsgItem()" << std::endl;
|
||||
#endif
|
||||
|
||||
uint32_t tlvsize = sizeGxsTestMsgItem(item);
|
||||
uint32_t offset = 0;
|
||||
|
||||
if(*size < tlvsize)
|
||||
{
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::serialiseGxsTestMsgItem()" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
*size = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* GxsTestMsgItem */
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_MSG, item->msg.mTestString);
|
||||
|
||||
if(offset != tlvsize)
|
||||
{
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::serialiseGxsTestMsgItem() FAIL Size Error! " << std::endl;
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
#ifdef TEST_DEBUG
|
||||
if (!ok)
|
||||
{
|
||||
std::cerr << "RsGxsTestSerialiser::serialiseGxsTestMsgItem() NOK" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
RsGxsTestMsgItem* RsGxsTestSerialiser::deserialiseGxsTestMsgItem(void *data, uint32_t *size)
|
||||
{
|
||||
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::deserialiseGxsTestMsgItem()" << std::endl;
|
||||
#endif
|
||||
/* 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_GXS_TYPE_TEST != getRsItemService(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_TEST_MSG_ITEM != getRsItemSubType(rstype)))
|
||||
{
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::deserialiseGxsTestMsgItem() FAIL wrong type" << std::endl;
|
||||
#endif
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
if (*size < rssize) /* check size */
|
||||
{
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::deserialiseGxsTestMsgItem() FAIL wrong size" << std::endl;
|
||||
#endif
|
||||
return NULL; /* not enough data */
|
||||
}
|
||||
|
||||
/* set the packet length */
|
||||
*size = rssize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
RsGxsTestMsgItem* item = new RsGxsTestMsgItem();
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_MSG, item->msg.mTestString);
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::deserialiseGxsTestMsgItem() FAIL size mismatch" << std::endl;
|
||||
#endif
|
||||
/* error */
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
#ifdef TEST_DEBUG
|
||||
std::cerr << "RsGxsTestSerialiser::deserialiseGxsTestMsgItem() NOK" << std::endl;
|
||||
#endif
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
|
91
tests/unittests/libretroshare/services/gxs/rsgxstestitems.h
Normal file
91
tests/unittests/libretroshare/services/gxs/rsgxstestitems.h
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* libretroshare/src/serialiser: rsgxstestserviceitems.h
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie
|
||||
*
|
||||
* 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.1 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".
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "serialiser/rsserviceids.h"
|
||||
#include "serialiser/rsserial.h"
|
||||
|
||||
#include "serialiser/rsgxsitems.h"
|
||||
#include "gxstestservice.h"
|
||||
|
||||
const uint8_t RS_PKT_SUBTYPE_TEST_GROUP_ITEM = 0x02;
|
||||
const uint8_t RS_PKT_SUBTYPE_TEST_MSG_ITEM = 0x03;
|
||||
|
||||
class RsGxsTestGroupItem : public RsGxsGrpItem
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
RsGxsTestGroupItem(): RsGxsGrpItem(RS_SERVICE_GXS_TYPE_TEST,
|
||||
RS_PKT_SUBTYPE_TEST_GROUP_ITEM) { return;}
|
||||
virtual ~RsGxsTestGroupItem() { return;}
|
||||
|
||||
void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
|
||||
RsTestGroup group;
|
||||
};
|
||||
|
||||
class RsGxsTestMsgItem : public RsGxsMsgItem
|
||||
{
|
||||
public:
|
||||
|
||||
RsGxsTestMsgItem(): RsGxsMsgItem(RS_SERVICE_GXS_TYPE_TEST,
|
||||
RS_PKT_SUBTYPE_TEST_MSG_ITEM) {return; }
|
||||
virtual ~RsGxsTestMsgItem() { return;}
|
||||
void clear();
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
RsTestMsg msg;
|
||||
};
|
||||
|
||||
class RsGxsTestSerialiser : public RsSerialType
|
||||
{
|
||||
public:
|
||||
|
||||
RsGxsTestSerialiser()
|
||||
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_GXS_TYPE_TEST)
|
||||
{ return; }
|
||||
virtual ~RsGxsTestSerialiser() { 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 sizeGxsTestGroupItem(RsGxsTestGroupItem *item);
|
||||
bool serialiseGxsTestGroupItem (RsGxsTestGroupItem *item, void *data, uint32_t *size);
|
||||
RsGxsTestGroupItem * deserialiseGxsTestGroupItem(void *data, uint32_t *size);
|
||||
|
||||
uint32_t sizeGxsTestMsgItem(RsGxsTestMsgItem *item);
|
||||
bool serialiseGxsTestMsgItem (RsGxsTestMsgItem *item, void *data, uint32_t *size);
|
||||
RsGxsTestMsgItem * deserialiseGxsTestMsgItem(void *data, uint32_t *size);
|
||||
|
||||
};
|
||||
|
8
tests/unittests/run_tests.sh
Executable file
8
tests/unittests/run_tests.sh
Executable file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
GTESTFILTER='--gtest_filter=libretroshare_services.*'
|
||||
#GTESTFILTER='--gtest_filter=libretroshare_services.GXS_nxs_basic*'
|
||||
#GTESTOUTPUT='--gtest_output "xml:test_results.xml"'
|
||||
|
||||
echo ./unittests $GTESTOUTPUT $GTESTFILTER
|
||||
./unittests $GTESTOUTPUT $GTESTFILTER
|
@ -305,4 +305,14 @@ SOURCES += libretroshare/dbase/fisavetest.cc \
|
||||
|
||||
SOURCES += libretroshare/services/status/status_test.cc \
|
||||
|
||||
############################### gxs ########################################
|
||||
|
||||
HEADERS += libretroshare/services/gxs/rsgxstestitems.h \
|
||||
libretroshare/services/gxs/gxstestservice.h \
|
||||
libretroshare/services/gxs/GxsIsolatedServiceTester.h \
|
||||
|
||||
SOURCES += libretroshare/services/gxs/rsgxstestitems.cc \
|
||||
libretroshare/services/gxs/gxstestservice.cc \
|
||||
libretroshare/services/gxs/GxsIsolatedServiceTester.cc \
|
||||
libretroshare/services/gxs/nxsbasic_test.cc \
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user