mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
-fixed an update issue with actual group item
- simply didn't open grp file in "out" mode on update -made update a bit more sturdy is group not found on update - prevent client can crash librs - updated unit tests for grps and messages - removed data base removal on db reset as cannot rekey db unfortunately (as passphrase (ssl) cannot be kept in the clear in mem) git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs_finale@6873 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d31a34bd95
commit
a6f62caef4
@ -663,7 +663,7 @@ int RsDataService::updateGroup(std::map<RsNxsGrp *, RsGxsGrpMetaData *> &grp)
|
|||||||
if(!validSize(grpPtr)) continue;
|
if(!validSize(grpPtr)) continue;
|
||||||
|
|
||||||
std::string grpFile = mServiceDir + "/" + grpPtr->grpId;
|
std::string grpFile = mServiceDir + "/" + grpPtr->grpId;
|
||||||
std::fstream ostrm(grpFile.c_str(), std::ios::binary | std::ios::trunc);
|
std::ofstream ostrm(grpFile.c_str(), std::ios::binary | std::ios::trunc);
|
||||||
uint32_t offset = 0; // get file offset
|
uint32_t offset = 0; // get file offset
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -1058,34 +1058,33 @@ int RsDataService::retrieveGxsGrpMetaData(std::map<RsGxsGroupId, RsGxsGrpMetaDat
|
|||||||
|
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
|
|
||||||
std::map<RsGxsGroupId, RsGxsGrpMetaData *>::iterator mit = grp.begin();
|
std::map<RsGxsGroupId, RsGxsGrpMetaData *>::iterator mit = grp.begin();
|
||||||
|
|
||||||
for(; mit != grp.end(); mit++)
|
for(; mit != grp.end(); mit++)
|
||||||
{
|
{
|
||||||
const RsGxsGroupId& grpId = mit->first;
|
const RsGxsGroupId& grpId = mit->first;
|
||||||
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, grpMetaColumns, "grpId='" + grpId + "'", "");
|
RetroCursor* c = mDb->sqlQuery(GRP_TABLE_NAME, grpMetaColumns, "grpId='" + grpId + "'", "");
|
||||||
|
|
||||||
if(c)
|
if(c)
|
||||||
{
|
{
|
||||||
bool valid = c->moveToFirst();
|
bool valid = c->moveToFirst();
|
||||||
|
|
||||||
while(valid)
|
while(valid)
|
||||||
{
|
{
|
||||||
RsGxsGrpMetaData* g = locked_getGrpMeta(*c);
|
RsGxsGrpMetaData* g = locked_getGrpMeta(*c);
|
||||||
|
|
||||||
if(g)
|
if(g)
|
||||||
{
|
{
|
||||||
grp[g->mGroupId] = g;
|
grp[g->mGroupId] = g;
|
||||||
}
|
}
|
||||||
valid = c->moveToNext();
|
valid = c->moveToNext();
|
||||||
}
|
}
|
||||||
delete c;
|
delete c;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -1104,21 +1103,21 @@ int RsDataService::resetDataStore()
|
|||||||
std::map<std::string, RsNxsGrp*>::iterator mit
|
std::map<std::string, RsNxsGrp*>::iterator mit
|
||||||
= grps.begin();
|
= grps.begin();
|
||||||
|
|
||||||
|
|
||||||
// remove all grp msgs files from service dir
|
|
||||||
for(; mit != grps.end(); mit++){
|
|
||||||
std::string file = mServiceDir + "/" + mit->first;
|
|
||||||
std::string msgFile = file + "-msgs";
|
|
||||||
remove(file.c_str()); // remove group file
|
|
||||||
remove(msgFile.c_str()); // and remove messages file
|
|
||||||
delete mit->second;
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mDbMutex);
|
RsStackMutex stack(mDbMutex);
|
||||||
mDb->closeDb();
|
|
||||||
}
|
|
||||||
|
|
||||||
remove(mDbName.c_str()); // remove db file
|
// remove all grp msgs files from service dir
|
||||||
|
for(; mit != grps.end(); mit++){
|
||||||
|
std::string file = mServiceDir + "/" + mit->first;
|
||||||
|
std::string msgFile = file + "-msgs";
|
||||||
|
remove(file.c_str()); // remove group file
|
||||||
|
remove(msgFile.c_str()); // and remove messages file
|
||||||
|
delete mit->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
mDb->execSQL("DROP TABLE " + MSG_TABLE_NAME);
|
||||||
|
mDb->execSQL("DROP TABLE " + GRP_TABLE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
// recreate database
|
// recreate database
|
||||||
initialise();
|
initialise();
|
||||||
|
@ -1881,7 +1881,20 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||||||
{
|
{
|
||||||
GroupUpdatePublish& gup = *vit;
|
GroupUpdatePublish& gup = *vit;
|
||||||
const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId;
|
const RsGxsGroupId& groupId = gup.grpItem->meta.mGroupId;
|
||||||
RsGxsGrpMetaData* meta = grpMeta[groupId];
|
std::map<std::string, RsGxsGrpMetaData*>::iterator mit = grpMeta.find(groupId);
|
||||||
|
|
||||||
|
RsGxsGrpMetaData* meta = NULL;
|
||||||
|
if(mit == grpMeta.end())
|
||||||
|
{
|
||||||
|
std::cerr << "Error! could not find meta of old group to update!" << std::endl;
|
||||||
|
mDataAccess->updatePublicRequestStatus(gup.mToken, RsTokenService::GXS_REQUEST_V2_STATUS_FAILED);
|
||||||
|
delete gup.grpItem;
|
||||||
|
continue;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
meta = mit->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
gup.grpItem->meta = *meta;
|
gup.grpItem->meta = *meta;
|
||||||
assignMetaUpdates(gup.grpItem->meta, gup.mUpdateMeta);
|
assignMetaUpdates(gup.grpItem->meta, gup.mUpdateMeta);
|
||||||
@ -1897,6 +1910,7 @@ void RsGenExchange::processGroupUpdatePublish()
|
|||||||
ggps.mStartTS = time(NULL);
|
ggps.mStartTS = time(NULL);
|
||||||
ggps.mLastAttemptTS = 0;
|
ggps.mLastAttemptTS = 0;
|
||||||
ggps.mIsUpdate = true;
|
ggps.mIsUpdate = true;
|
||||||
|
ggps.mToken = gup.mToken;
|
||||||
mGrpsToPublish.push_back(ggps);
|
mGrpsToPublish.push_back(ggps);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
|
@ -46,6 +46,7 @@ public:
|
|||||||
|
|
||||||
mGroupStatus = 0;
|
mGroupStatus = 0;
|
||||||
mCircleType = 0;
|
mCircleType = 0;
|
||||||
|
mAuthenFlags = 0;
|
||||||
|
|
||||||
mPublishTs = 0;
|
mPublishTs = 0;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,9 @@ linux-* {
|
|||||||
LIBS += ../../../lib/libretroshare.a
|
LIBS += ../../../lib/libretroshare.a
|
||||||
LIBS += ../../../../../libbitdht/src/lib/libbitdht.a
|
LIBS += ../../../../../libbitdht/src/lib/libbitdht.a
|
||||||
LIBS += ../../../../../openpgpsdk/src/lib/libops.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
|
LIBS *= -rdynamic -frtti
|
||||||
DEFINES *= HAVE_XSS # for idle time, libx screensaver extensions
|
DEFINES *= HAVE_XSS # for idle time, libx screensaver extensions
|
||||||
DEFINES *= UBUNTU
|
DEFINES *= UBUNTU
|
||||||
|
@ -108,7 +108,7 @@ bool GenExchangeTest::pollForMsgAcknowledgement(uint32_t token,
|
|||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GenExchangeTestService* GenExchangeTest::getTestService()
|
GenExchangeTestService* GenExchangeTest::getTestService()
|
||||||
{
|
{
|
||||||
@ -155,12 +155,13 @@ void GenExchangeTest::setUp()
|
|||||||
// would be useful for genexchange services
|
// would be useful for genexchange services
|
||||||
// to have a protected reset button
|
// to have a protected reset button
|
||||||
mTestService->start();
|
mTestService->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenExchangeTest::breakDown()
|
void GenExchangeTest::breakDown()
|
||||||
{
|
{
|
||||||
mTestService->join();
|
mDataService->resetDataStore();
|
||||||
clearAllData();
|
mTestService->join();
|
||||||
|
clearAllData();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool msgDataSort(const RsDummyMsg* m1, const RsDummyMsg* m2)
|
bool msgDataSort(const RsDummyMsg* m1, const RsDummyMsg* m2)
|
||||||
@ -189,7 +190,7 @@ bool GenExchangeTest::compareMsgDataMaps()
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GenExchangeTest::compareMsgIdMaps()
|
bool GenExchangeTest::compareMsgIdMaps()
|
||||||
@ -205,7 +206,7 @@ bool GenExchangeTest::compareMsgIdMaps()
|
|||||||
ok &= Comparison<std::vector<RsGxsMessageId>, RsGxsMessageId>::comparison(v1, v2);
|
ok &= Comparison<std::vector<RsGxsMessageId>, RsGxsMessageId>::comparison(v1, v2);
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GenExchangeTest::compareMsgMetaMaps()
|
bool GenExchangeTest::compareMsgMetaMaps()
|
||||||
@ -220,19 +221,19 @@ bool GenExchangeTest::compareMsgMetaMaps()
|
|||||||
ok &= Comparison<std::vector<RsMsgMetaData>, RsMsgMetaData>::comparison(v1, v2);
|
ok &= Comparison<std::vector<RsMsgMetaData>, RsMsgMetaData>::comparison(v1, v2);
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GenExchangeTest::compareMsgRelateIdsMap()
|
bool GenExchangeTest::compareMsgRelateIdsMap()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GenExchangeTest::compareMsgRelatedDataMap()
|
bool GenExchangeTest::compareMsgRelatedDataMap()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool grpDataSort(const RsDummyGrp* g1, const RsDummyGrp* g2)
|
bool grpDataSort(const RsDummyGrp* g1, const RsDummyGrp* g2)
|
||||||
{
|
{
|
||||||
@ -247,7 +248,7 @@ bool GenExchangeTest::compareGrpData()
|
|||||||
bool ok = Comparison<std::vector<RsDummyGrp*>, RsDummyGrp*>::comparison
|
bool ok = Comparison<std::vector<RsDummyGrp*>, RsDummyGrp*>::comparison
|
||||||
(mGrpDataIn, mGrpDataOut);
|
(mGrpDataIn, mGrpDataOut);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator<(const RsGroupMetaData& l, const RsGroupMetaData& r)
|
bool operator<(const RsGroupMetaData& l, const RsGroupMetaData& r)
|
||||||
{
|
{
|
||||||
@ -263,7 +264,7 @@ bool GenExchangeTest::compareGrpMeta()
|
|||||||
bool ok = Comparison<std::list<RsGroupMetaData>, RsGroupMetaData>::comparison
|
bool ok = Comparison<std::list<RsGroupMetaData>, RsGroupMetaData>::comparison
|
||||||
(mGrpMetaDataIn, mGrpMetaDataOut);
|
(mGrpMetaDataIn, mGrpMetaDataOut);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool GenExchangeTest::compareGrpIds()
|
bool GenExchangeTest::compareGrpIds()
|
||||||
@ -289,7 +290,7 @@ void GenExchangeTest::createGrps(uint32_t nGrps,
|
|||||||
pollForGrpAcknowledgement(token, grpId);
|
pollForGrpAcknowledgement(token, grpId);
|
||||||
groupId.push_back(grpId);
|
groupId.push_back(grpId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenExchangeTest::init(RsMsgMetaData& msgMetaData) const
|
void GenExchangeTest::init(RsMsgMetaData& msgMetaData) const
|
||||||
{
|
{
|
||||||
@ -334,7 +335,7 @@ void GenExchangeTest::init(RsDummyGrp& grpItem) const
|
|||||||
{
|
{
|
||||||
randString(SHORT_STR, grpItem.grpData);
|
randString(SHORT_STR, grpItem.grpData);
|
||||||
init(grpItem.meta);
|
init(grpItem.meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::init(RsDummyMsg& msgItem) const
|
void GenExchangeTest::init(RsDummyMsg& msgItem) const
|
||||||
@ -346,72 +347,72 @@ void GenExchangeTest::init(RsDummyMsg& msgItem) const
|
|||||||
void GenExchangeTest::storeToMsgDataOutMaps(const DummyMsgMap& msgDataOut)
|
void GenExchangeTest::storeToMsgDataOutMaps(const DummyMsgMap& msgDataOut)
|
||||||
{
|
{
|
||||||
mMsgDataOut.insert(msgDataOut.begin(), msgDataOut.end());
|
mMsgDataOut.insert(msgDataOut.begin(), msgDataOut.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::storeToMsgIdsOutMaps(const GxsMsgIdResult& msgIdsOut)
|
void GenExchangeTest::storeToMsgIdsOutMaps(const GxsMsgIdResult& msgIdsOut)
|
||||||
{
|
{
|
||||||
mMsgIdsOut.insert(msgIdsOut.begin(), msgIdsOut.end());
|
mMsgIdsOut.insert(msgIdsOut.begin(), msgIdsOut.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::storeToMsgMetaOutMaps(const GxsMsgMetaMap& msgMetaOut)
|
void GenExchangeTest::storeToMsgMetaOutMaps(const GxsMsgMetaMap& msgMetaOut)
|
||||||
{
|
{
|
||||||
mMsgMetaDataOut.insert(msgMetaOut.begin(), msgMetaOut.end());
|
mMsgMetaDataOut.insert(msgMetaOut.begin(), msgMetaOut.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::storeToMsgDataInMaps(const DummyMsgMap& msgDataIn)
|
void GenExchangeTest::storeToMsgDataInMaps(const DummyMsgMap& msgDataIn)
|
||||||
{
|
{
|
||||||
mMsgDataIn.insert(msgDataIn.begin(), msgDataIn.end());
|
mMsgDataIn.insert(msgDataIn.begin(), msgDataIn.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::storeToMsgIdsInMaps(const GxsMsgIdResult& msgIdsIn)
|
void GenExchangeTest::storeToMsgIdsInMaps(const GxsMsgIdResult& msgIdsIn)
|
||||||
{
|
{
|
||||||
mMsgIdsIn.insert(msgIdsIn.begin(), msgIdsIn.end());
|
mMsgIdsIn.insert(msgIdsIn.begin(), msgIdsIn.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::storeToMsgMetaInMaps(const GxsMsgMetaMap& msgMetaIn)
|
void GenExchangeTest::storeToMsgMetaInMaps(const GxsMsgMetaMap& msgMetaIn)
|
||||||
{
|
{
|
||||||
mMsgMetaDataIn.insert(msgMetaIn.begin(), msgMetaIn.end());
|
mMsgMetaDataIn.insert(msgMetaIn.begin(), msgMetaIn.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::storeToGrpIdsOutList(
|
void GenExchangeTest::storeToGrpIdsOutList(
|
||||||
const std::list<RsGxsGroupId>& grpIdOut)
|
const std::list<RsGxsGroupId>& grpIdOut)
|
||||||
{
|
{
|
||||||
mGrpIdsOut.insert(mGrpIdsOut.end(), grpIdOut.begin(), grpIdOut.end());
|
mGrpIdsOut.insert(mGrpIdsOut.end(), grpIdOut.begin(), grpIdOut.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::storeToGrpMetaOutList(
|
void GenExchangeTest::storeToGrpMetaOutList(
|
||||||
const std::list<RsGroupMetaData>& grpMetaOut)
|
const std::list<RsGroupMetaData>& grpMetaOut)
|
||||||
{
|
{
|
||||||
mGrpMetaDataOut.insert(mGrpMetaDataOut.end(), grpMetaOut.begin(), grpMetaOut.end());
|
mGrpMetaDataOut.insert(mGrpMetaDataOut.end(), grpMetaOut.begin(), grpMetaOut.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::storeToGrpDataOutList(
|
void GenExchangeTest::storeToGrpDataOutList(
|
||||||
const std::vector<RsDummyGrp*>& grpDataOut)
|
const std::vector<RsDummyGrp*>& grpDataOut)
|
||||||
{
|
{
|
||||||
mGrpDataOut.insert(mGrpDataOut.end(), grpDataOut.begin(), grpDataOut.end());
|
mGrpDataOut.insert(mGrpDataOut.end(), grpDataOut.begin(), grpDataOut.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::storeToGrpIdsInList(
|
void GenExchangeTest::storeToGrpIdsInList(
|
||||||
const std::list<RsGxsGroupId>& grpIdIn)
|
const std::list<RsGxsGroupId>& grpIdIn)
|
||||||
{
|
{
|
||||||
mGrpIdsIn.insert(mGrpIdsIn.end(), grpIdIn.begin(), grpIdIn.end());
|
mGrpIdsIn.insert(mGrpIdsIn.end(), grpIdIn.begin(), grpIdIn.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::storeToGrpMetaInList(
|
void GenExchangeTest::storeToGrpMetaInList(
|
||||||
const std::list<RsGroupMetaData>& grpMetaIn)
|
const std::list<RsGroupMetaData>& grpMetaIn)
|
||||||
{
|
{
|
||||||
mGrpMetaDataIn.insert(mGrpMetaDataIn.end(), grpMetaIn.begin(), grpMetaIn.end());
|
mGrpMetaDataIn.insert(mGrpMetaDataIn.end(), grpMetaIn.begin(), grpMetaIn.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::storeToGrpDataInList(
|
void GenExchangeTest::storeToGrpDataInList(
|
||||||
@ -437,14 +438,14 @@ void GenExchangeTest::clearAllData()
|
|||||||
void GenExchangeTest::clearMsgDataInMap()
|
void GenExchangeTest::clearMsgDataInMap()
|
||||||
{
|
{
|
||||||
mMsgDataIn.clear();
|
mMsgDataIn.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::clearMsgDataOutMap()
|
void GenExchangeTest::clearMsgDataOutMap()
|
||||||
{
|
{
|
||||||
|
|
||||||
clearMsgDataMap(mMsgDataOut);
|
clearMsgDataMap(mMsgDataOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenExchangeTest::clearMsgDataMap(DummyMsgMap& msgDataMap) const
|
void GenExchangeTest::clearMsgDataMap(DummyMsgMap& msgDataMap) const
|
||||||
{
|
{
|
||||||
@ -459,31 +460,31 @@ void GenExchangeTest::clearMsgDataMap(DummyMsgMap& msgDataMap) const
|
|||||||
void GenExchangeTest::clearMsgMetaInMap()
|
void GenExchangeTest::clearMsgMetaInMap()
|
||||||
{
|
{
|
||||||
mMsgMetaDataIn.clear();
|
mMsgMetaDataIn.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::clearMsgMetaOutMap()
|
void GenExchangeTest::clearMsgMetaOutMap()
|
||||||
{
|
{
|
||||||
mMsgMetaDataOut.clear();
|
mMsgMetaDataOut.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::clearMsgIdInMap()
|
void GenExchangeTest::clearMsgIdInMap()
|
||||||
{
|
{
|
||||||
mMsgIdsIn.clear();
|
mMsgIdsIn.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::clearMsgIdOutMap()
|
void GenExchangeTest::clearMsgIdOutMap()
|
||||||
{
|
{
|
||||||
mMsgIdsOut.clear();
|
mMsgIdsOut.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::clearMsgRelatedIdInMap()
|
void GenExchangeTest::clearMsgRelatedIdInMap()
|
||||||
{
|
{
|
||||||
mMsgRelatedIdsIn.clear();
|
mMsgRelatedIdsIn.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::clearGrpDataInList()
|
void GenExchangeTest::clearGrpDataInList()
|
||||||
@ -494,38 +495,38 @@ void GenExchangeTest::clearGrpDataInList()
|
|||||||
void GenExchangeTest::clearGrpDataList(std::vector<RsDummyGrp*>& grpData) const
|
void GenExchangeTest::clearGrpDataList(std::vector<RsDummyGrp*>& grpData) const
|
||||||
{
|
{
|
||||||
deleteResVector<RsDummyGrp>(grpData);
|
deleteResVector<RsDummyGrp>(grpData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::clearGrpDataOutList()
|
void GenExchangeTest::clearGrpDataOutList()
|
||||||
{
|
{
|
||||||
clearGrpDataList(mGrpDataOut);
|
clearGrpDataList(mGrpDataOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::clearGrpMetaInList()
|
void GenExchangeTest::clearGrpMetaInList()
|
||||||
{
|
{
|
||||||
mGrpMetaDataIn.clear();
|
mGrpMetaDataIn.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::clearGrpMetaOutList()
|
void GenExchangeTest::clearGrpMetaOutList()
|
||||||
{
|
{
|
||||||
mGrpMetaDataOut.clear();
|
mGrpMetaDataOut.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::clearGrpIdInList()
|
void GenExchangeTest::clearGrpIdInList()
|
||||||
{
|
{
|
||||||
mGrpIdsIn.clear();
|
mGrpIdsIn.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GenExchangeTest::clearGrpIdOutList()
|
void GenExchangeTest::clearGrpIdOutList()
|
||||||
{
|
{
|
||||||
mGrpIdsOut.clear();
|
mGrpIdsOut.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool operator ==(const RsMsgMetaData& lMeta, const RsMsgMetaData& rMeta)
|
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)
|
bool operator ==(const RsGxsGrpItem& lGrp, const RsGxsGrpItem& rGrp)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ private:
|
|||||||
std::list<RsGroupMetaData> mGrpMetaDataOut, mGrpMetaDataIn;
|
std::list<RsGroupMetaData> mGrpMetaDataOut, mGrpMetaDataIn;
|
||||||
std::list<RsGxsGroupId> mGrpIdsOut, mGrpIdsIn;
|
std::list<RsGxsGroupId> mGrpIdsOut, mGrpIdsIn;
|
||||||
|
|
||||||
DummyMsgMap mMsgDataOut, mMsgDataIn;
|
std::map<RsGxsGroupId, std::vector<RsDummyMsg*> > mMsgDataOut, mMsgDataIn;
|
||||||
GxsMsgMetaMap mMsgMetaDataOut, mMsgMetaDataIn;
|
GxsMsgMetaMap mMsgMetaDataOut, mMsgMetaDataIn;
|
||||||
GxsMsgIdResult mMsgIdsOut, mMsgIdsIn;
|
GxsMsgIdResult mMsgIdsOut, mMsgIdsIn;
|
||||||
|
|
||||||
|
@ -17,6 +17,11 @@ void GenExchangeTestService::publishDummyGrp(uint32_t &token, RsDummyGrp *grp)
|
|||||||
publishGroup(token, 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)
|
void GenExchangeTestService::publishDummyMsg(uint32_t &token, RsDummyMsg *msg)
|
||||||
{
|
{
|
||||||
publishMsg(token, msg);
|
publishMsg(token, msg);
|
||||||
|
@ -15,6 +15,7 @@ public:
|
|||||||
void notifyChanges(std::vector<RsGxsNotify*>& changes);
|
void notifyChanges(std::vector<RsGxsNotify*>& changes);
|
||||||
|
|
||||||
void publishDummyGrp(uint32_t& token, RsDummyGrp* grp);
|
void publishDummyGrp(uint32_t& token, RsDummyGrp* grp);
|
||||||
|
void updateDummyGrp(uint32_t &token, RsGxsGroupUpdateMeta& meta, RsDummyGrp *group);
|
||||||
void publishDummyMsg(uint32_t& token, RsDummyMsg* msg);
|
void publishDummyMsg(uint32_t& token, RsDummyMsg* msg);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "gxspublishgrouptest.h"
|
#include "gxspublishgrouptest.h"
|
||||||
#include "util/utest.h"
|
#include "util/utest.h"
|
||||||
|
#include "support.h"
|
||||||
|
|
||||||
#define POLLING_TIME_OUT 5
|
#define POLLING_TIME_OUT 5
|
||||||
|
|
||||||
@ -169,6 +170,65 @@ bool GxsPublishGroupTest::testGrpIdRetrieval()
|
|||||||
|
|
||||||
return ok;
|
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()
|
bool GxsPublishGroupTest::testGrpMetaRetrieval()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -229,10 +289,11 @@ bool GxsPublishGroupTest::testGrpMetaRetrieval()
|
|||||||
}
|
}
|
||||||
void GxsPublishGroupTest::runTests()
|
void GxsPublishGroupTest::runTests()
|
||||||
{
|
{
|
||||||
CHECK(testGrpSubmissionRetrieval());
|
// CHECK(testGrpSubmissionRetrieval());
|
||||||
CHECK(testGrpIdRetrieval());
|
// CHECK(testGrpIdRetrieval());
|
||||||
CHECK(testGrpMetaRetrieval());
|
// CHECK(testGrpMetaRetrieval());
|
||||||
CHECK(testSpecificGrpRetrieval());
|
// CHECK(testSpecificGrpRetrieval());
|
||||||
|
CHECK(testUpdateGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ private:
|
|||||||
bool testSpecificGrpRetrieval();
|
bool testSpecificGrpRetrieval();
|
||||||
bool testGrpIdRetrieval();
|
bool testGrpIdRetrieval();
|
||||||
bool testGrpMetaRetrieval();
|
bool testGrpMetaRetrieval();
|
||||||
|
bool testUpdateGroup();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -49,10 +49,10 @@ bool GxsPublishMsgTest::testMsgSubmissionRetrieval()
|
|||||||
msgOut->meta.mMsgId = msgId.second;
|
msgOut->meta.mMsgId = msgId.second;
|
||||||
|
|
||||||
DummyMsgMap msgMap;
|
DummyMsgMap msgMap;
|
||||||
std::vector<RsDummyMsg*> msgV;
|
std::vector<RsDummyMsg*> msgV;
|
||||||
msgV.push_back(msgOut);
|
msgV.push_back(msgOut);
|
||||||
msgMap[msgOut->meta.mGroupId] = msgV;
|
msgMap[msgOut->meta.mGroupId] = msgV;
|
||||||
storeToMsgDataOutMaps(msgMap);
|
storeToMsgDataOutMaps(msgMap);
|
||||||
|
|
||||||
|
|
||||||
RsTokReqOptions opts;
|
RsTokReqOptions opts;
|
||||||
|
@ -30,16 +30,16 @@ INITTEST();
|
|||||||
int main()
|
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 :)
|
// we want to use default authentication which is NO authentication :)
|
||||||
GenExchangeTestService testService(dataStore, NULL, NULL);
|
GenExchangeTestService testService(dataStore, NULL, NULL);
|
||||||
|
|
||||||
//GxsPublishGroupTest testGrpPublishing(&testService, dataStore);
|
GxsPublishGroupTest testGrpPublishing(&testService, dataStore);
|
||||||
//testGrpPublishing.runTests();
|
testGrpPublishing.runTests();
|
||||||
|
|
||||||
GxsPublishMsgTest testMsgPublishing(&testService, dataStore);
|
//GxsPublishMsgTest testMsgPublishing(&testService, dataStore);
|
||||||
testMsgPublishing.runTests();
|
//testMsgPublishing.runTests();
|
||||||
|
|
||||||
FINALREPORT("RsGenExchangeTest");
|
FINALREPORT("RsGenExchangeTest");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user