mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 06:02:41 -04:00
Merging branches/v0.6-initdev into trunk.
These split at 6672 -> 7075, so quite a bit merge. libretroshare compiles - but untested. retroshare-gui needs GenCertDialog.ui and IdEditDialog.ui to be properly merged. (compile errors). some plugins will be broken. retroshare-nogui is untested. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7078 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
commit
c0738eec7f
407 changed files with 23716 additions and 50779 deletions
|
@ -56,7 +56,9 @@ linux-* {
|
|||
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 += -lssl -lgpgme -lupnp -lixml -lgnome-keyring -lbz2
|
||||
# We need a explicit path here, to force using the home version of sqlite3 that really encrypts the database.
|
||||
LIBS += /home/crispy/Development/retroshare/sqlcipher/sqlcipher/.libs/libsqlite3.a
|
||||
LIBS *= -rdynamic -frtti
|
||||
DEFINES *= HAVE_XSS # for idle time, libx screensaver extensions
|
||||
DEFINES *= UBUNTU
|
||||
|
|
|
@ -108,7 +108,7 @@ bool GenExchangeTest::pollForMsgAcknowledgement(uint32_t token,
|
|||
now = time(NULL);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
GenExchangeTestService* GenExchangeTest::getTestService()
|
||||
{
|
||||
|
@ -155,12 +155,13 @@ void GenExchangeTest::setUp()
|
|||
// would be useful for genexchange services
|
||||
// to have a protected reset button
|
||||
mTestService->start();
|
||||
}
|
||||
}
|
||||
|
||||
void GenExchangeTest::breakDown()
|
||||
{
|
||||
mTestService->join();
|
||||
clearAllData();
|
||||
mDataService->resetDataStore();
|
||||
mTestService->join();
|
||||
clearAllData();
|
||||
}
|
||||
|
||||
bool msgDataSort(const RsDummyMsg* m1, const RsDummyMsg* m2)
|
||||
|
@ -189,7 +190,7 @@ bool GenExchangeTest::compareMsgDataMaps()
|
|||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool GenExchangeTest::compareMsgIdMaps()
|
||||
|
@ -205,7 +206,7 @@ bool GenExchangeTest::compareMsgIdMaps()
|
|||
ok &= Comparison<std::vector<RsGxsMessageId>, RsGxsMessageId>::comparison(v1, v2);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool GenExchangeTest::compareMsgMetaMaps()
|
||||
|
@ -220,19 +221,19 @@ bool GenExchangeTest::compareMsgMetaMaps()
|
|||
ok &= Comparison<std::vector<RsMsgMetaData>, RsMsgMetaData>::comparison(v1, v2);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool GenExchangeTest::compareMsgRelateIdsMap()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool GenExchangeTest::compareMsgRelatedDataMap()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool grpDataSort(const RsDummyGrp* g1, const RsDummyGrp* g2)
|
||||
{
|
||||
|
@ -247,7 +248,7 @@ bool GenExchangeTest::compareGrpData()
|
|||
bool ok = Comparison<std::vector<RsDummyGrp*>, RsDummyGrp*>::comparison
|
||||
(mGrpDataIn, mGrpDataOut);
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator<(const RsGroupMetaData& l, const RsGroupMetaData& r)
|
||||
{
|
||||
|
@ -263,7 +264,7 @@ bool GenExchangeTest::compareGrpMeta()
|
|||
bool ok = Comparison<std::list<RsGroupMetaData>, RsGroupMetaData>::comparison
|
||||
(mGrpMetaDataIn, mGrpMetaDataOut);
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool GenExchangeTest::compareGrpIds()
|
||||
|
@ -289,7 +290,7 @@ void GenExchangeTest::createGrps(uint32_t nGrps,
|
|||
pollForGrpAcknowledgement(token, grpId);
|
||||
groupId.push_back(grpId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GenExchangeTest::init(RsMsgMetaData& msgMetaData) const
|
||||
{
|
||||
|
@ -334,7 +335,7 @@ void GenExchangeTest::init(RsDummyGrp& grpItem) const
|
|||
{
|
||||
randString(SHORT_STR, grpItem.grpData);
|
||||
init(grpItem.meta);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::init(RsDummyMsg& msgItem) const
|
||||
|
@ -346,72 +347,72 @@ void GenExchangeTest::init(RsDummyMsg& msgItem) const
|
|||
void GenExchangeTest::storeToMsgDataOutMaps(const DummyMsgMap& msgDataOut)
|
||||
{
|
||||
mMsgDataOut.insert(msgDataOut.begin(), msgDataOut.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::storeToMsgIdsOutMaps(const GxsMsgIdResult& msgIdsOut)
|
||||
{
|
||||
mMsgIdsOut.insert(msgIdsOut.begin(), msgIdsOut.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::storeToMsgMetaOutMaps(const GxsMsgMetaMap& msgMetaOut)
|
||||
{
|
||||
mMsgMetaDataOut.insert(msgMetaOut.begin(), msgMetaOut.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::storeToMsgDataInMaps(const DummyMsgMap& msgDataIn)
|
||||
{
|
||||
mMsgDataIn.insert(msgDataIn.begin(), msgDataIn.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::storeToMsgIdsInMaps(const GxsMsgIdResult& msgIdsIn)
|
||||
{
|
||||
mMsgIdsIn.insert(msgIdsIn.begin(), msgIdsIn.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::storeToMsgMetaInMaps(const GxsMsgMetaMap& msgMetaIn)
|
||||
{
|
||||
mMsgMetaDataIn.insert(msgMetaIn.begin(), msgMetaIn.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::storeToGrpIdsOutList(
|
||||
const std::list<RsGxsGroupId>& grpIdOut)
|
||||
{
|
||||
mGrpIdsOut.insert(mGrpIdsOut.end(), grpIdOut.begin(), grpIdOut.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::storeToGrpMetaOutList(
|
||||
const std::list<RsGroupMetaData>& grpMetaOut)
|
||||
{
|
||||
mGrpMetaDataOut.insert(mGrpMetaDataOut.end(), grpMetaOut.begin(), grpMetaOut.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::storeToGrpDataOutList(
|
||||
const std::vector<RsDummyGrp*>& grpDataOut)
|
||||
{
|
||||
mGrpDataOut.insert(mGrpDataOut.end(), grpDataOut.begin(), grpDataOut.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::storeToGrpIdsInList(
|
||||
const std::list<RsGxsGroupId>& grpIdIn)
|
||||
{
|
||||
mGrpIdsIn.insert(mGrpIdsIn.end(), grpIdIn.begin(), grpIdIn.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::storeToGrpMetaInList(
|
||||
const std::list<RsGroupMetaData>& grpMetaIn)
|
||||
{
|
||||
mGrpMetaDataIn.insert(mGrpMetaDataIn.end(), grpMetaIn.begin(), grpMetaIn.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::storeToGrpDataInList(
|
||||
|
@ -437,14 +438,14 @@ void GenExchangeTest::clearAllData()
|
|||
void GenExchangeTest::clearMsgDataInMap()
|
||||
{
|
||||
mMsgDataIn.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::clearMsgDataOutMap()
|
||||
{
|
||||
|
||||
clearMsgDataMap(mMsgDataOut);
|
||||
}
|
||||
}
|
||||
|
||||
void GenExchangeTest::clearMsgDataMap(DummyMsgMap& msgDataMap) const
|
||||
{
|
||||
|
@ -459,31 +460,31 @@ void GenExchangeTest::clearMsgDataMap(DummyMsgMap& msgDataMap) const
|
|||
void GenExchangeTest::clearMsgMetaInMap()
|
||||
{
|
||||
mMsgMetaDataIn.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::clearMsgMetaOutMap()
|
||||
{
|
||||
mMsgMetaDataOut.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::clearMsgIdInMap()
|
||||
{
|
||||
mMsgIdsIn.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::clearMsgIdOutMap()
|
||||
{
|
||||
mMsgIdsOut.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::clearMsgRelatedIdInMap()
|
||||
{
|
||||
mMsgRelatedIdsIn.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::clearGrpDataInList()
|
||||
|
@ -494,38 +495,38 @@ void GenExchangeTest::clearGrpDataInList()
|
|||
void GenExchangeTest::clearGrpDataList(std::vector<RsDummyGrp*>& grpData) const
|
||||
{
|
||||
deleteResVector<RsDummyGrp>(grpData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::clearGrpDataOutList()
|
||||
{
|
||||
clearGrpDataList(mGrpDataOut);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::clearGrpMetaInList()
|
||||
{
|
||||
mGrpMetaDataIn.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::clearGrpMetaOutList()
|
||||
{
|
||||
mGrpMetaDataOut.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::clearGrpIdInList()
|
||||
{
|
||||
mGrpIdsIn.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GenExchangeTest::clearGrpIdOutList()
|
||||
{
|
||||
mGrpIdsOut.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool operator ==(const RsMsgMetaData& lMeta, const RsMsgMetaData& rMeta)
|
||||
{
|
||||
|
@ -584,5 +585,5 @@ bool operator ==(const RsDummyMsg& lMsg, const RsDummyMsg& rMsg)
|
|||
bool operator ==(const RsGxsGrpItem& lGrp, const RsGxsGrpItem& rGrp)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -258,7 +258,7 @@ private:
|
|||
std::list<RsGroupMetaData> mGrpMetaDataOut, mGrpMetaDataIn;
|
||||
std::list<RsGxsGroupId> mGrpIdsOut, mGrpIdsIn;
|
||||
|
||||
DummyMsgMap mMsgDataOut, mMsgDataIn;
|
||||
std::map<RsGxsGroupId, std::vector<RsDummyMsg*> > mMsgDataOut, mMsgDataIn;
|
||||
GxsMsgMetaMap mMsgMetaDataOut, mMsgMetaDataIn;
|
||||
GxsMsgIdResult mMsgIdsOut, mMsgIdsIn;
|
||||
|
||||
|
|
|
@ -17,6 +17,11 @@ void GenExchangeTestService::publishDummyGrp(uint32_t &token, RsDummyGrp *grp)
|
|||
publishGroup(token, grp);
|
||||
}
|
||||
|
||||
void GenExchangeTestService::updateDummyGrp(uint32_t &token, RsGxsGroupUpdateMeta &updateMeta, RsDummyGrp *group)
|
||||
{
|
||||
updateGroup(token, updateMeta, group);
|
||||
}
|
||||
|
||||
void GenExchangeTestService::publishDummyMsg(uint32_t &token, RsDummyMsg *msg)
|
||||
{
|
||||
publishMsg(token, msg);
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
void notifyChanges(std::vector<RsGxsNotify*>& changes);
|
||||
|
||||
void publishDummyGrp(uint32_t& token, RsDummyGrp* grp);
|
||||
void updateDummyGrp(uint32_t &token, RsGxsGroupUpdateMeta& meta, RsDummyGrp *group);
|
||||
void publishDummyMsg(uint32_t& token, RsDummyMsg* msg);
|
||||
|
||||
/*!
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "gxspublishgrouptest.h"
|
||||
#include "util/utest.h"
|
||||
#include "support.h"
|
||||
|
||||
#define POLLING_TIME_OUT 5
|
||||
|
||||
|
@ -169,6 +170,65 @@ bool GxsPublishGroupTest::testGrpIdRetrieval()
|
|||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool GxsPublishGroupTest::testUpdateGroup()
|
||||
{
|
||||
setUp();
|
||||
|
||||
GenExchangeTestService* testService = getTestService();
|
||||
RsTokenService* tokenService = getTokenService();
|
||||
|
||||
// create some random grps to allow msg testing
|
||||
|
||||
RsDummyGrp* dgrp1 = new RsDummyGrp();
|
||||
RsDummyGrp* dgrp2 = new RsDummyGrp();
|
||||
|
||||
RsDummyGrp* dgrp2_copy = new RsDummyGrp();
|
||||
|
||||
init(*dgrp1);
|
||||
init(*dgrp2);
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = 45000;
|
||||
uint32_t token;
|
||||
RsGxsGroupId grpId;
|
||||
|
||||
std::vector<RsDummyGrp*> groupsPublished;
|
||||
std::list<RsGxsGroupId> grpIds;
|
||||
|
||||
std::string name = dgrp1->meta.mGroupName;
|
||||
*dgrp2 = *dgrp1;
|
||||
testService->publishDummyGrp(token, dgrp1);
|
||||
bool ok = pollForGrpAcknowledgement(token, grpId);
|
||||
|
||||
grpIds.push_back(grpId);
|
||||
RsGxsGroupUpdateMeta updateMeta(grpId);
|
||||
|
||||
updateMeta.setMetaUpdate(RsGxsGroupUpdateMeta::NAME, name);
|
||||
randString(SHORT_STR, dgrp2->grpData);
|
||||
dgrp2->meta.mGroupId = grpId;
|
||||
*dgrp2_copy = *dgrp2;
|
||||
dgrp2->grpData ="ojfosfjsofjsof";
|
||||
testService->updateDummyGrp(token, updateMeta, dgrp2);
|
||||
ok &= pollForGrpAcknowledgement(token, grpId);
|
||||
|
||||
groupsPublished.push_back(dgrp2_copy);
|
||||
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
|
||||
tokenService->requestGroupInfo(token, 0, opts, grpIds);
|
||||
|
||||
pollForToken(token, opts, true);
|
||||
|
||||
|
||||
ok &= compareGrpData();
|
||||
|
||||
breakDown();
|
||||
|
||||
return ok;
|
||||
|
||||
}
|
||||
|
||||
bool GxsPublishGroupTest::testGrpMetaRetrieval()
|
||||
{
|
||||
|
||||
|
@ -229,10 +289,11 @@ bool GxsPublishGroupTest::testGrpMetaRetrieval()
|
|||
}
|
||||
void GxsPublishGroupTest::runTests()
|
||||
{
|
||||
CHECK(testGrpSubmissionRetrieval());
|
||||
CHECK(testGrpIdRetrieval());
|
||||
CHECK(testGrpMetaRetrieval());
|
||||
CHECK(testSpecificGrpRetrieval());
|
||||
// CHECK(testGrpSubmissionRetrieval());
|
||||
// CHECK(testGrpIdRetrieval());
|
||||
// CHECK(testGrpMetaRetrieval());
|
||||
// CHECK(testSpecificGrpRetrieval());
|
||||
CHECK(testUpdateGroup());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ private:
|
|||
bool testSpecificGrpRetrieval();
|
||||
bool testGrpIdRetrieval();
|
||||
bool testGrpMetaRetrieval();
|
||||
bool testUpdateGroup();
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
@ -49,10 +49,10 @@ bool GxsPublishMsgTest::testMsgSubmissionRetrieval()
|
|||
msgOut->meta.mMsgId = msgId.second;
|
||||
|
||||
DummyMsgMap msgMap;
|
||||
std::vector<RsDummyMsg*> msgV;
|
||||
msgV.push_back(msgOut);
|
||||
msgMap[msgOut->meta.mGroupId] = msgV;
|
||||
storeToMsgDataOutMaps(msgMap);
|
||||
std::vector<RsDummyMsg*> msgV;
|
||||
msgV.push_back(msgOut);
|
||||
msgMap[msgOut->meta.mGroupId] = msgV;
|
||||
storeToMsgDataOutMaps(msgMap);
|
||||
|
||||
|
||||
RsTokReqOptions opts;
|
||||
|
|
|
@ -30,16 +30,16 @@ INITTEST();
|
|||
int main()
|
||||
{
|
||||
|
||||
RsGeneralDataService* dataStore = new RsDataService("./", "testServiceDb", RS_SERVICE_TYPE_DUMMY, NULL);
|
||||
RsGeneralDataService* dataStore = new RsDataService("./", "testServiceDb", RS_SERVICE_TYPE_DUMMY, NULL, "");
|
||||
|
||||
// we want to use default authentication which is NO authentication :)
|
||||
GenExchangeTestService testService(dataStore, NULL, NULL);
|
||||
|
||||
//GxsPublishGroupTest testGrpPublishing(&testService, dataStore);
|
||||
//testGrpPublishing.runTests();
|
||||
GxsPublishGroupTest testGrpPublishing(&testService, dataStore);
|
||||
testGrpPublishing.runTests();
|
||||
|
||||
GxsPublishMsgTest testMsgPublishing(&testService, dataStore);
|
||||
testMsgPublishing.runTests();
|
||||
//GxsPublishMsgTest testMsgPublishing(&testService, dataStore);
|
||||
//testMsgPublishing.runTests();
|
||||
|
||||
FINALREPORT("RsGenExchangeTest");
|
||||
|
||||
|
|
110
libretroshare/src/tests/serialiser/rsgxsupdateitem_test.cc
Normal file
110
libretroshare/src/tests/serialiser/rsgxsupdateitem_test.cc
Normal file
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* rsgxsupdateitem_test.cc
|
||||
*
|
||||
* Created on: 9 Dec 2013
|
||||
* Author: crispy
|
||||
*/
|
||||
|
||||
#include "support.h"
|
||||
#include "rsgxsupdateitem_test.h"
|
||||
|
||||
INITTEST();
|
||||
|
||||
RsSerialType* init_item(RsGxsGrpUpdateItem& i)
|
||||
{
|
||||
i.clear();
|
||||
i.grpUpdateTS = rand()%2424;
|
||||
randString(SHORT_STR, i.peerId);
|
||||
return new RsGxsUpdateSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
}
|
||||
|
||||
RsSerialType* init_item(RsGxsMsgUpdateItem& i)
|
||||
{
|
||||
i.clear();
|
||||
randString(SHORT_STR, i.peerId);
|
||||
int numUpdates = rand()%123;
|
||||
|
||||
std::string peer;
|
||||
for(int j=0; j < numUpdates; j++)
|
||||
{
|
||||
randString(SHORT_STR, peer);
|
||||
i.msgUpdateTS.insert(std::make_pair(peer, rand()%45));
|
||||
}
|
||||
|
||||
return new RsGxsUpdateSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
}
|
||||
|
||||
RsSerialType* init_item(RsGxsServerGrpUpdateItem& i)
|
||||
{
|
||||
i.clear();
|
||||
i.grpUpdateTS = rand()%2424;
|
||||
|
||||
return new RsGxsUpdateSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
}
|
||||
|
||||
RsSerialType* init_item(RsGxsServerMsgUpdateItem& i)
|
||||
{
|
||||
i.clear();
|
||||
randString(SHORT_STR, i.grpId);
|
||||
i.msgUpdateTS = rand()%4252;
|
||||
return new RsGxsUpdateSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
}
|
||||
|
||||
bool operator ==(const RsGxsGrpUpdateItem& l, const RsGxsGrpUpdateItem& r)
|
||||
{
|
||||
bool ok = l.grpUpdateTS == r.grpUpdateTS;
|
||||
ok &= l.peerId == r.peerId;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool operator ==(const RsGxsMsgUpdateItem& l, const RsGxsMsgUpdateItem& r)
|
||||
{
|
||||
bool ok = l.peerId == r.peerId;
|
||||
|
||||
const std::map<std::string, uint32_t>& lUp = l.msgUpdateTS, rUp = r.msgUpdateTS;
|
||||
|
||||
ok &= lUp.size() == rUp.size();
|
||||
|
||||
std::map<std::string, uint32_t>::const_iterator lit = lUp.begin(), rit;
|
||||
|
||||
for(; lit != lUp.end(); lit++)
|
||||
{
|
||||
std::string key = lit->first;
|
||||
if((rit = rUp.find(key)) != rUp.end())
|
||||
ok &= lit->second == rit->second;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool operator ==(const RsGxsServerGrpUpdateItem& l,
|
||||
const RsGxsServerGrpUpdateItem& r)
|
||||
{
|
||||
return l.grpUpdateTS == r.grpUpdateTS;
|
||||
}
|
||||
|
||||
bool operator ==(const RsGxsServerMsgUpdateItem& l,
|
||||
const RsGxsServerMsgUpdateItem& r)
|
||||
{
|
||||
bool ok = l.grpId == r.grpId;
|
||||
ok &= l.msgUpdateTS == r.msgUpdateTS;
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cerr << "RsGxsUpdateItem Tests" << std::endl;
|
||||
|
||||
test_RsItem<RsGxsGrpUpdateItem>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); REPORT("Serialise/Deserialise RsGxsGrpUpdateItem");
|
||||
test_RsItem<RsGxsMsgUpdateItem>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); REPORT("Serialise/Deserialise RsGxsMsgUpdateItem");
|
||||
test_RsItem<RsGxsServerGrpUpdateItem>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); REPORT("Serialise/Deserialise RsGxsServerGrpUpdateItem");
|
||||
test_RsItem<RsGxsServerMsgUpdateItem>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM); REPORT("Serialise/Deserialise RsGxsServerMsgUpdateItem");
|
||||
|
||||
FINALREPORT("RsGxsUpdateItem Tests");
|
||||
|
||||
return TESTRESULT();
|
||||
}
|
25
libretroshare/src/tests/serialiser/rsgxsupdateitem_test.h
Normal file
25
libretroshare/src/tests/serialiser/rsgxsupdateitem_test.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* rsgxsupdateitem_test.h
|
||||
*
|
||||
* Created on: 9 Dec 2013
|
||||
* Author: crispy
|
||||
*/
|
||||
|
||||
#ifndef RSGXSUPDATEITEM_TEST_H_
|
||||
#define RSGXSUPDATEITEM_TEST_H_
|
||||
|
||||
#include "serialiser/rsgxsupdateitems.h"
|
||||
#include "support.h"
|
||||
|
||||
|
||||
RsSerialType* init_item(RsGxsGrpUpdateItem& i);
|
||||
RsSerialType* init_item(RsGxsMsgUpdateItem& i);
|
||||
RsSerialType* init_item(RsGxsServerGrpUpdateItem& i);
|
||||
RsSerialType* init_item(RsGxsServerMsgUpdateItem& i);
|
||||
|
||||
bool operator==(const RsGxsGrpUpdateItem& l, const RsGxsGrpUpdateItem& r);
|
||||
bool operator==(const RsGxsMsgUpdateItem& l, const RsGxsMsgUpdateItem& r);
|
||||
bool operator==(const RsGxsServerGrpUpdateItem& l, const RsGxsServerGrpUpdateItem& r);
|
||||
bool operator==(const RsGxsServerMsgUpdateItem& l, const RsGxsServerMsgUpdateItem& r);
|
||||
|
||||
#endif /* RSGXSUPDATEITEM_TEST_H_ */
|
|
@ -39,7 +39,7 @@ RsSerialType* init_item(RsNxsSyncGrp& rsg)
|
|||
{
|
||||
rsg.clear();
|
||||
rsg.flag = RsNxsSyncGrp::FLAG_USE_SYNC_HASH;
|
||||
rsg.syncAge = rand()%2423;
|
||||
rsg.createdSince = rand()%2423;
|
||||
randString(3124,rsg.syncHash);
|
||||
|
||||
return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
|
@ -50,7 +50,7 @@ RsSerialType* init_item(RsNxsSyncMsg& rsgm)
|
|||
rsgm.clear();
|
||||
|
||||
rsgm.flag = RsNxsSyncMsg::FLAG_USE_SYNC_HASH;
|
||||
rsgm.syncAge = rand()%24232;
|
||||
rsgm.createdSince = rand()%24232;
|
||||
rsgm.transactionNumber = rand()%23;
|
||||
randString(SHORT_STR, rsgm.grpId);
|
||||
randString(SHORT_STR, rsgm.syncHash);
|
||||
|
@ -120,7 +120,7 @@ bool operator==(const RsNxsSyncGrp& l, const RsNxsSyncGrp& r)
|
|||
|
||||
if(l.syncHash != r.syncHash) return false;
|
||||
if(l.flag != r.flag) return false;
|
||||
if(l.syncAge != r.syncAge) return false;
|
||||
if(l.createdSince != r.createdSince) return false;
|
||||
if(l.transactionNumber != r.transactionNumber) return false;
|
||||
|
||||
return true;
|
||||
|
@ -130,7 +130,7 @@ bool operator==(const RsNxsSyncMsg& l, const RsNxsSyncMsg& r)
|
|||
{
|
||||
|
||||
if(l.flag != r.flag) return false;
|
||||
if(l.syncAge != r.syncAge) return false;
|
||||
if(l.createdSince != r.createdSince) return false;
|
||||
if(l.syncHash != r.syncHash) return false;
|
||||
if(l.grpId != r.grpId) return false;
|
||||
if(l.transactionNumber != r.transactionNumber) return false;
|
||||
|
|
|
@ -9,13 +9,15 @@ OPS_TOP_DIR = ../../../../openpgpsdk/src
|
|||
include $(RS_TOP_DIR)/tests/scripts/config.mk
|
||||
###############################################################
|
||||
|
||||
TESTOBJ = dirtest.o sha1_test.o aes_test.o dchat_decrypt.o
|
||||
TESTS = dirtest sha1_test aes_test dchat_decrypt
|
||||
TESTOBJ = dirtest.o compress_test.o sha1_test.o aes_test.o dchat_decrypt.o
|
||||
TESTS = dirtest sha1_test aes_test compress_test dchat_decrypt
|
||||
|
||||
all: tests
|
||||
|
||||
sha1_test: sha1_test.o
|
||||
$(CC) $(CFLAGS) -o sha1_test sha1_test.o $(LIBS)
|
||||
compress_test: compress_test.o
|
||||
$(CC) $(CFLAGS) -o compress_test compress_test.o $(LIBS)
|
||||
dirtest: dirtest.o
|
||||
$(CC) $(CFLAGS) -o dirtest dirtest.o $(LIBS)
|
||||
dirtest: aes_test.o
|
||||
|
|
217
libretroshare/src/tests/util/compress_test.cc
Normal file
217
libretroshare/src/tests/util/compress_test.cc
Normal file
|
@ -0,0 +1,217 @@
|
|||
|
||||
/*
|
||||
* "$Id: compress.cc,v 1.1 2007-02-19 20:08:30 rmf24 Exp $"
|
||||
*
|
||||
* RetroShare C++ Interface.
|
||||
*
|
||||
* Copyright 2012-2012 by Cyril Soler
|
||||
*
|
||||
* 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 <stdint.h>
|
||||
|
||||
#include "util/rscompress.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "util/utest.h"
|
||||
#include "util/argstream.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
|
||||
void printHelp(int argc,char *argv[])
|
||||
{
|
||||
std::cerr << argv[0] << ": tests AES encryption/decryption functions." << std::endl;
|
||||
std::cerr << "Usage: " << argv[0] << std::endl ;
|
||||
}
|
||||
|
||||
bool compareStrings(const std::string& s1,const std::string& s2)
|
||||
{
|
||||
uint32_t L = std::min(s1.length(),s2.length()) ;
|
||||
|
||||
for(int i=0;i<L;++i)
|
||||
if(s1[i] != s2[i])
|
||||
{
|
||||
std::cerr << "Strings differ at position " << i << std::endl;
|
||||
return false ;
|
||||
}
|
||||
return s1==s2;
|
||||
}
|
||||
void printHex(unsigned char *data,uint32_t length)
|
||||
{
|
||||
static const char outh[16] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' } ;
|
||||
static const char outl[16] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' } ;
|
||||
|
||||
for(uint32_t j = 0; j < length; j++)
|
||||
{
|
||||
std::cerr << outh[ (data[j]>>4) ] ;
|
||||
std::cerr << outh[ data[j] & 0xf ] ;
|
||||
}
|
||||
}
|
||||
|
||||
INITTEST() ;
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
std::string inputfile ;
|
||||
argstream as(argc,argv) ;
|
||||
|
||||
as >> help() ;
|
||||
|
||||
as.defaultErrorHandling() ;
|
||||
|
||||
std::cerr << "Testing RsCompress" << std::endl;
|
||||
|
||||
std::string source_string = "This is a very secret string, but ultimately it will always be decyphered \
|
||||
ar cqs libretroshare.a temp/linux-g++-64/obj/p3bitdht.o \
|
||||
temp/linux-g++-64/obj/p3bitdht_interface.o \
|
||||
temp/linux-g++-64/obj/p3bitdht_peers.o \
|
||||
temp/linux-g++-64/obj/p3bitdht_peernet.o \
|
||||
temp/linux-g++-64/obj/p3bitdht_relay.o \
|
||||
temp/linux-g++-64/obj/connectstatebox.o temp/linux-g++-64/obj/udppeer.o \
|
||||
temp/linux-g++-64/obj/tcppacket.o temp/linux-g++-64/obj/tcpstream.o \
|
||||
temp/linux-g++-64/obj/tou.o temp/linux-g++-64/obj/bss_tou.o \
|
||||
temp/linux-g++-64/obj/udpstunner.o temp/linux-g++-64/obj/udprelay.o \
|
||||
temp/linux-g++-64/obj/cachestrapper.o temp/linux-g++-64/obj/fimonitor.o \
|
||||
temp/linux-g++-64/obj/findex.o temp/linux-g++-64/obj/fistore.o \
|
||||
temp/linux-g++-64/obj/rsexpr.o temp/linux-g++-64/obj/ftchunkmap.o \
|
||||
temp/linux-g++-64/obj/ftcontroller.o \
|
||||
temp/linux-g++-64/obj/ftdatamultiplex.o temp/linux-g++-64/obj/ftdbase.o \
|
||||
temp/linux-g++-64/obj/ftextralist.o temp/linux-g++-64/obj/ftfilecreator.o \
|
||||
temp/linux-g++-64/obj/ftfileprovider.o \
|
||||
temp/linux-g++-64/obj/ftfilesearch.o temp/linux-g++-64/obj/ftserver.o \
|
||||
temp/linux-g++-64/obj/fttransfermodule.o \
|
||||
temp/linux-g++-64/obj/ftturtlefiletransferitem.o \
|
||||
temp/linux-g++-64/obj/authgpg.o temp/linux-g++-64/obj/authssl.o \
|
||||
temp/linux-g++-64/obj/pgphandler.o temp/linux-g++-64/obj/pgpkeyutil.o \
|
||||
temp/linux-g++-64/obj/rscertificate.o temp/linux-g++-64/obj/p3cfgmgr.o \
|
||||
temp/linux-g++-64/obj/p3peermgr.o temp/linux-g++-64/obj/p3linkmgr.o \
|
||||
temp/linux-g++-64/obj/p3netmgr.o temp/linux-g++-64/obj/p3notify.o \
|
||||
temp/linux-g++-64/obj/pqiqos.o temp/linux-g++-64/obj/pqiarchive.o \
|
||||
temp/linux-g++-64/obj/pqibin.o temp/linux-g++-64/obj/pqihandler.o \
|
||||
temp/linux-g++-64/obj/p3historymgr.o temp/linux-g++-64/obj/pqiipset.o \
|
||||
temp/linux-g++-64/obj/pqiloopback.o temp/linux-g++-64/obj/pqimonitor.o \
|
||||
temp/linux-g++-64/obj/pqinetwork.o temp/linux-g++-64/obj/pqiperson.o \
|
||||
temp/linux-g++-64/obj/pqipersongrp.o temp/linux-g++-64/obj/pqisecurity.o \
|
||||
temp/linux-g++-64/obj/pqiservice.o temp/linux-g++-64/obj/pqissl.o \
|
||||
temp/linux-g++-64/obj/pqissllistener.o \
|
||||
temp/linux-g++-64/obj/pqisslpersongrp.o temp/linux-g++-64/obj/pqissludp.o \
|
||||
temp/linux-g++-64/obj/pqisslproxy.o temp/linux-g++-64/obj/pqistore.o \
|
||||
temp/linux-g++-64/obj/pqistreamer.o \
|
||||
temp/linux-g++-64/obj/pqithreadstreamer.o \
|
||||
temp/linux-g++-64/obj/pqiqosstreamer.o temp/linux-g++-64/obj/sslfns.o \
|
||||
temp/linux-g++-64/obj/pqinetstatebox.o \
|
||||
temp/linux-g++-64/obj/p3face-config.o temp/linux-g++-64/obj/p3face-msgs.o \
|
||||
temp/linux-g++-64/obj/p3face-server.o temp/linux-g++-64/obj/p3history.o \
|
||||
temp/linux-g++-64/obj/p3msgs.o temp/linux-g++-64/obj/p3peers.o \
|
||||
temp/linux-g++-64/obj/p3status.o temp/linux-g++-64/obj/rsinit.o \
|
||||
temp/linux-g++-64/obj/rsloginhandler.o temp/linux-g++-64/obj/rstypes.o \
|
||||
temp/linux-g++-64/obj/p3serverconfig.o \
|
||||
temp/linux-g++-64/obj/pluginmanager.o temp/linux-g++-64/obj/dlfcn_win32.o \
|
||||
temp/linux-g++-64/obj/rspluginitems.o \
|
||||
temp/linux-g++-64/obj/rsbaseserial.o \
|
||||
temp/linux-g++-64/obj/rsfiletransferitems.o \
|
||||
temp/linux-g++-64/obj/rsserviceserialiser.o \
|
||||
temp/linux-g++-64/obj/rsconfigitems.o \
|
||||
temp/linux-g++-64/obj/rshistoryitems.o temp/linux-g++-64/obj/rsmsgitems.o \
|
||||
temp/linux-g++-64/obj/rsserial.o temp/linux-g++-64/obj/rsstatusitems.o \
|
||||
temp/linux-g++-64/obj/rstlvaddrs.o temp/linux-g++-64/obj/rstlvbase.o \
|
||||
temp/linux-g++-64/obj/rstlvfileitem.o temp/linux-g++-64/obj/rstlvimage.o \
|
||||
temp/linux-g++-64/obj/rstlvkeys.o temp/linux-g++-64/obj/rstlvkvwide.o \
|
||||
temp/linux-g++-64/obj/rstlvtypes.o temp/linux-g++-64/obj/rstlvutil.o \
|
||||
temp/linux-g++-64/obj/rstlvdsdv.o temp/linux-g++-64/obj/rsdsdvitems.o \
|
||||
temp/linux-g++-64/obj/rstlvbanlist.o \
|
||||
temp/linux-g++-64/obj/rsbanlistitems.o \
|
||||
temp/linux-g++-64/obj/rsbwctrlitems.o \
|
||||
temp/linux-g++-64/obj/rsdiscovery2items.o \
|
||||
temp/linux-g++-64/obj/rsheartbeatitems.o \
|
||||
temp/linux-g++-64/obj/rsrttitems.o temp/linux-g++-64/obj/p3chatservice.o \
|
||||
temp/linux-g++-64/obj/p3msgservice.o temp/linux-g++-64/obj/p3service.o \
|
||||
temp/linux-g++-64/obj/p3statusservice.o temp/linux-g++-64/obj/p3dsdv.o \
|
||||
temp/linux-g++-64/obj/p3banlist.o temp/linux-g++-64/obj/p3bwctrl.o \
|
||||
temp/linux-g++-64/obj/p3discovery2.o temp/linux-g++-64/obj/p3heartbeat.o \
|
||||
temp/linux-g++-64/obj/p3rtt.o temp/linux-g++-64/obj/p3turtle.o \
|
||||
temp/linux-g++-64/obj/rsturtleitem.o \
|
||||
temp/linux-g++-64/obj/folderiterator.o temp/linux-g++-64/obj/rsdebug.o \
|
||||
temp/linux-g++-64/obj/rscompress.o temp/linux-g++-64/obj/smallobject.o \
|
||||
temp/linux-g++-64/obj/rsdir.o temp/linux-g++-64/obj/rsdiscspace.o \
|
||||
temp/linux-g++-64/obj/rsnet.o temp/linux-g++-64/obj/rsnet_ss.o \
|
||||
temp/linux-g++-64/obj/extaddrfinder.o temp/linux-g++-64/obj/dnsresolver.o \
|
||||
temp/linux-g++-64/obj/rsprint.o temp/linux-g++-64/obj/rsstring.o \
|
||||
temp/linux-g++-64/obj/rsthreads.o temp/linux-g++-64/obj/rsversion.o \
|
||||
temp/linux-g++-64/obj/rswin.o temp/linux-g++-64/obj/rsaes.o \
|
||||
temp/linux-g++-64/obj/rsrandom.o temp/linux-g++-64/obj/rstickevent.o \
|
||||
temp/linux-g++-64/obj/UPnPBase.o \
|
||||
temp/linux-g++-64/obj/upnphandler_linux.o \
|
||||
temp/linux-g++-64/obj/rsnxsitems.o temp/linux-g++-64/obj/rsdataservice.o \
|
||||
temp/linux-g++-64/obj/rsgenexchange.o \
|
||||
temp/linux-g++-64/obj/rsgxsnetservice.o temp/linux-g++-64/obj/rsgxsdata.o \
|
||||
temp/linux-g++-64/obj/rsgxsitems.o \
|
||||
temp/linux-g++-64/obj/rsgxsdataaccess.o temp/linux-g++-64/obj/retrodb.o \
|
||||
temp/linux-g++-64/obj/contentvalue.o temp/linux-g++-64/obj/rsdbbind.o \
|
||||
temp/linux-g++-64/obj/gxssecurity.o temp/linux-g++-64/obj/gxstokenqueue.o \
|
||||
temp/linux-g++-64/obj/rsgxsnetutils.o temp/linux-g++-64/obj/rsgxsutil.o \
|
||||
temp/linux-g++-64/obj/p3idservice.o temp/linux-g++-64/obj/rsgxsiditems.o \
|
||||
temp/linux-g++-64/obj/p3gxscircles.o \
|
||||
temp/linux-g++-64/obj/rsgxscircleitems.o \
|
||||
temp/linux-g++-64/obj/p3gxsforums.o \
|
||||
temp/linux-g++-64/obj/rsgxsforumitems.o \
|
||||
temp/linux-g++-64/obj/p3gxschannels.o temp/linux-g++-64/obj/p3gxscommon.o \
|
||||
temp/linux-g++-64/obj/rsgxscommentitems.o \
|
||||
temp/linux-g++-64/obj/rsgxschannelitems.o temp/linux-g++-64/obj/p3wiki.o \
|
||||
temp/linux-g++-64/obj/rswikiitems.o temp/linux-g++-64/obj/p3wire.o \
|
||||
temp/linux-g++-64/obj/rswireitems.o temp/linux-g++-64/obj/p3posted.o \
|
||||
temp/linux-g++-64/obj/rsposteditems.o \
|
||||
temp/linux-g++-64/obj/p3photoservice.o \
|
||||
temp/linux-g++-64/obj/rsphotoitems.o" ;
|
||||
|
||||
std::cerr << "Input string: length=" << source_string.length() << std::endl;
|
||||
std::cerr << "Input string: hash =" << RsDirUtil::sha1sum((uint8_t*)source_string.c_str(),source_string.length()).toStdString() << std::endl;
|
||||
|
||||
uint8_t *output_data ;
|
||||
uint32_t output_length ;
|
||||
|
||||
CHECK(RsCompress::compress_memory_chunk((uint8_t*)source_string.c_str(),source_string.length(),output_data,output_length)) ;
|
||||
|
||||
std::cerr << "Compressed data: " << std::endl;
|
||||
std::cerr << " Length = " << output_length << std::endl;
|
||||
std::cerr << " hash = " << RsDirUtil::sha1sum(output_data,output_length).toStdString() << std::endl;
|
||||
|
||||
std::cerr << "Uncompressing..." << std::endl;
|
||||
|
||||
uint8_t *decomp_output_data=NULL ;
|
||||
uint32_t decomp_output_length=0 ;
|
||||
|
||||
CHECK(RsCompress::uncompress_memory_chunk(output_data,output_length,decomp_output_data,decomp_output_length)) ;
|
||||
|
||||
std::cerr << "Decompressed data: size=" << decomp_output_length << std::endl;
|
||||
std::cerr << "Decompressed data: hash=" << RsDirUtil::sha1sum(decomp_output_data,decomp_output_length).toStdString() << std::endl;
|
||||
|
||||
std::string decompress_string((char *)decomp_output_data,decomp_output_length) ;
|
||||
CHECK(compareStrings(decompress_string, source_string)) ;
|
||||
|
||||
free(decomp_output_data) ;
|
||||
free(output_data) ;
|
||||
|
||||
FINALREPORT("RSCompress") ;
|
||||
return TESTRESULT() ;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue