mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added test for gxs data test
updated tests, still need fixed vtable error for rsgds added more test utils to gxs git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@5257 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d533a2e580
commit
0b0549f437
@ -90,7 +90,7 @@
|
||||
|
||||
RsDataService::RsDataService(const std::string &serviceDir, const std::string &dbName, uint16_t serviceType,
|
||||
RsGxsSearchModule *mod)
|
||||
: mServiceDir(serviceDir), mDbName(mServiceDir + "/" + dbName), mServType(serviceType){
|
||||
: RsGeneralDataService(), mServiceDir(serviceDir), mDbName(mServiceDir + "/" + dbName), mServType(serviceType){
|
||||
|
||||
initialise();
|
||||
|
||||
|
@ -86,6 +86,7 @@ class RsGeneralDataService
|
||||
|
||||
public:
|
||||
|
||||
RsGeneralDataService(){}
|
||||
virtual ~RsGeneralDataService(){return;}
|
||||
|
||||
/*!
|
||||
@ -150,14 +151,14 @@ public:
|
||||
* @param msg map of message and decoded meta data information
|
||||
* @return error code
|
||||
*/
|
||||
virtual int storeMessage(std::map<RsNxsMsg*, RsGxsMsgMetaData*>& msg);
|
||||
virtual int storeMessage(std::map<RsNxsMsg*, RsGxsMsgMetaData*>& msg) = 0;
|
||||
|
||||
/*!
|
||||
* Stores a list of groups in data store
|
||||
* @param grp map of group and decoded meta data
|
||||
* @return error code
|
||||
*/
|
||||
virtual int storeGroup(std::map<RsNxsGrp*, RsGxsGrpMetaData*>& grp);
|
||||
virtual int storeGroup(std::map<RsNxsGrp*, RsGxsGrpMetaData*>& grp) = 0;
|
||||
|
||||
|
||||
/*!
|
||||
|
@ -24,6 +24,25 @@ uint32_t RsGxsGrpMetaData::serial_size()
|
||||
return s;
|
||||
}
|
||||
|
||||
void RsGxsGrpMetaData::clear(){
|
||||
|
||||
mGroupId.clear();
|
||||
mOrigGrpId.clear();
|
||||
mAuthorId.clear();
|
||||
mGroupName.clear();
|
||||
mPublishTs = 0;
|
||||
mGroupFlags = 0;
|
||||
mPop = 0;
|
||||
mMsgCount = 0;
|
||||
mGroupStatus = 0;
|
||||
mLastPost = 0;
|
||||
mSubscribeFlags = 0;
|
||||
|
||||
adminSign.TlvClear();
|
||||
keys.TlvClear();
|
||||
idSign.TlvClear();
|
||||
}
|
||||
|
||||
bool RsGxsGrpMetaData::serialise(void *data, uint32_t &pktsize)
|
||||
{
|
||||
|
||||
@ -70,24 +89,28 @@ bool RsGxsGrpMetaData::deserialise(void *data, uint32_t &pktsize)
|
||||
|
||||
bool ok = true ;
|
||||
|
||||
ok &= rssize != pktsize;
|
||||
ok &= rssize == pktsize;
|
||||
|
||||
if(!ok) return false;
|
||||
|
||||
ok &= GetTlvString(data, pktsize, &offset, 0, mGroupId);
|
||||
ok &= GetTlvString(data, pktsize, &offset, 0, mOrigGrpId);
|
||||
ok &= GetTlvString(data, pktsize, &offset, 0, mOrigGrpId);
|
||||
ok &= GetTlvString(data, pktsize, &offset, 0, mGroupName);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &mGroupFlags);
|
||||
ok &= getRawUInt32(data, pktsize, &offset, &mPublishTs);
|
||||
ok &= GetTlvString(data, pktsize, &offset, 0, mAuthorId);
|
||||
|
||||
ok &= adminSign.GetTlv(data, pktsize, &offset);
|
||||
ok &= keys.SetTlv(data, pktsize, &offset);
|
||||
ok &= idSign.SetTlv(data, pktsize, &offset);
|
||||
ok &= keys.GetTlv(data, pktsize, &offset);
|
||||
ok &= idSign.GetTlv(data, pktsize, &offset);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
RsGxsMsgMetaData::RsGxsMsgMetaData(){
|
||||
|
||||
}
|
||||
|
||||
uint32_t RsGxsMsgMetaData::serial_size()
|
||||
{
|
||||
|
||||
@ -98,6 +121,7 @@ uint32_t RsGxsMsgMetaData::serial_size()
|
||||
s += GetTlvStringSize(mThreadId);
|
||||
s += GetTlvStringSize(mParentId);
|
||||
s += GetTlvStringSize(mOrigMsgId);
|
||||
s += GetTlvStringSize(mAuthorId);
|
||||
|
||||
s += pubSign.TlvSize();
|
||||
s += idSign.TlvSize();
|
||||
@ -108,6 +132,25 @@ uint32_t RsGxsMsgMetaData::serial_size()
|
||||
return s;
|
||||
}
|
||||
|
||||
void RsGxsMsgMetaData::clear()
|
||||
{
|
||||
mGroupId.clear();
|
||||
mMsgId.clear();
|
||||
mThreadId.clear();
|
||||
mParentId.clear();
|
||||
mAuthorId.clear();
|
||||
mOrigMsgId.clear();
|
||||
mMsgName.clear();
|
||||
|
||||
pubSign.TlvClear();
|
||||
idSign.TlvClear();
|
||||
|
||||
mPublishTs = 0;
|
||||
mMsgFlags = 0;
|
||||
mMsgStatus = 0;
|
||||
mChildTs = 0;
|
||||
}
|
||||
|
||||
bool RsGxsMsgMetaData::serialise(void *data, uint32_t *size)
|
||||
{
|
||||
uint32_t tlvsize = serial_size() ;
|
||||
@ -136,6 +179,7 @@ bool RsGxsMsgMetaData::serialise(void *data, uint32_t *size)
|
||||
ok &= SetTlvString(data, *size, &offset, 0, mThreadId);
|
||||
ok &= SetTlvString(data, *size, &offset, 0, mParentId);
|
||||
ok &= SetTlvString(data, *size, &offset, 0, mOrigMsgId);
|
||||
ok &= SetTlvString(data, *size, &offset, 0, mAuthorId);
|
||||
|
||||
ok &= pubSign.SetTlv(data, *size, &offset);
|
||||
ok &= idSign.SetTlv(data, *size, &offset);
|
||||
@ -154,7 +198,7 @@ bool RsGxsMsgMetaData::deserialise(void *data, uint32_t *size)
|
||||
|
||||
bool ok = true ;
|
||||
|
||||
ok &= rssize != *size;
|
||||
ok &= rssize == *size;
|
||||
|
||||
if(!ok) return false;
|
||||
|
||||
@ -163,6 +207,7 @@ bool RsGxsMsgMetaData::deserialise(void *data, uint32_t *size)
|
||||
ok &= GetTlvString(data, *size, &offset, 0, mThreadId);
|
||||
ok &= GetTlvString(data, *size, &offset, 0, mParentId);
|
||||
ok &= GetTlvString(data, *size, &offset, 0, mOrigMsgId);
|
||||
ok &= GetTlvString(data, *size, &offset, 0, mAuthorId);
|
||||
|
||||
ok &= pubSign.GetTlv(data, *size, &offset);
|
||||
ok &= idSign.GetTlv(data, *size, &offset);
|
||||
|
@ -16,6 +16,7 @@ public:
|
||||
bool deserialise(void *data, uint32_t &pktsize);
|
||||
bool serialise(void* data, uint32_t &pktsize);
|
||||
uint32_t serial_size();
|
||||
void clear();
|
||||
|
||||
|
||||
std::string mGroupId;
|
||||
@ -55,6 +56,7 @@ public:
|
||||
bool deserialise(void *data, uint32_t *size);
|
||||
bool serialise(void* data, uint32_t *size);
|
||||
uint32_t serial_size();
|
||||
void clear();
|
||||
|
||||
std::string mGroupId;
|
||||
std::string mMsgId;
|
||||
|
@ -4,78 +4,90 @@
|
||||
|
||||
bool operator==(const RsNxsGrp& l, const RsNxsGrp& r){
|
||||
|
||||
if(!(l.adminSign == r.adminSign)) return false;
|
||||
if(!(l.idSign == r.idSign)) return false;
|
||||
if(l.timeStamp != r.timeStamp) return false;
|
||||
if(l.grpFlag != r.grpFlag) return false;
|
||||
if(l.identity != r.identity) return false;
|
||||
if(l.grpId != r.grpId) return false;
|
||||
if(l.keys.groupId != r.keys.groupId) return false;
|
||||
if(!(l.grp == r.grp) ) return false;
|
||||
|
||||
std::map<std::string, RsTlvSecurityKey>::const_iterator mit =
|
||||
l.keys.keys.begin(), mit_end = l.keys.keys.end();
|
||||
|
||||
for(; mit != mit_end; mit++){
|
||||
const RsTlvSecurityKey& lk = l.keys.keys.find(mit->first)->second;
|
||||
const RsTlvSecurityKey& rk = r.keys.keys.find(mit->first)->second;
|
||||
|
||||
if(! ( lk == rk) ) return false;
|
||||
}
|
||||
if(!(l.meta == r.meta) ) return false;
|
||||
if(l.transactionNumber != r.transactionNumber) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const RsNxsMsg& l, const RsNxsMsg& r){
|
||||
|
||||
|
||||
if(l.msgId != r.msgId) return false;
|
||||
if(l.grpId != r.grpId) return false;
|
||||
if(l.identity != r.identity) return false;
|
||||
if(l.timeStamp != r.timeStamp) return false;
|
||||
if(l.msgFlag != r.msgFlag) return false;
|
||||
if(! (l.msg == r.msg) ) return false;
|
||||
if(! (l.publishSign == r.publishSign) ) return false;
|
||||
if(! (l.idSign == r.idSign) ) return false;
|
||||
if(! (l.meta == r.meta) ) return false;
|
||||
if(l.transactionNumber != r.transactionNumber) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void init_item(RsNxsGrp* nxg)
|
||||
void init_item(RsNxsGrp& nxg)
|
||||
{
|
||||
|
||||
randString(SHORT_STR, nxg->identity);
|
||||
randString(SHORT_STR, nxg->grpId);
|
||||
nxg->timeStamp = rand()%23;
|
||||
nxg->grpFlag = rand()%242;
|
||||
init_item(nxg->grp);
|
||||
|
||||
init_item(nxg->adminSign);
|
||||
init_item(nxg->idSign);
|
||||
|
||||
int nKey = rand()%12;
|
||||
nxg->keys.groupId = nxg->grpId;
|
||||
for(int i=0; i < nKey; i++){
|
||||
RsTlvSecurityKey k;
|
||||
init_item(k);
|
||||
nxg->keys.keys[k.keyId] = k;
|
||||
}
|
||||
nxg.clear();
|
||||
|
||||
randString(SHORT_STR, nxg.grpId);
|
||||
nxg.transactionNumber = rand()%23;
|
||||
init_item(nxg.grp);
|
||||
init_item(nxg.meta);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void init_item(RsNxsMsg* nxm)
|
||||
{
|
||||
randString(SHORT_STR, nxm->msgId);
|
||||
randString(SHORT_STR, nxm->grpId);
|
||||
randString(SHORT_STR, nxm->identity);
|
||||
|
||||
init_item(nxm->publishSign);
|
||||
init_item(nxm->idSign);
|
||||
init_item(nxm->msg);
|
||||
nxm->msgFlag = rand()%4252;
|
||||
nxm->timeStamp = rand()%246;
|
||||
|
||||
|
||||
void init_item(RsNxsMsg& nxm)
|
||||
{
|
||||
nxm.clear();
|
||||
|
||||
randString(SHORT_STR, nxm.msgId);
|
||||
randString(SHORT_STR, nxm.grpId);
|
||||
init_item(nxm.msg);
|
||||
init_item(nxm.meta);
|
||||
nxm.transactionNumber = rand()%23;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void init_item(RsGxsGrpMetaData* metaGrp)
|
||||
{
|
||||
|
||||
randString(SHORT_STR, metaGrp->mGroupId);
|
||||
randString(SHORT_STR, metaGrp->mOrigGrpId);
|
||||
randString(SHORT_STR, metaGrp->mAuthorId);
|
||||
randString(SHORT_STR, metaGrp->mGroupName);
|
||||
|
||||
init_item(metaGrp->adminSign);
|
||||
init_item(metaGrp->keys);
|
||||
init_item(metaGrp->idSign);
|
||||
|
||||
metaGrp->mPublishTs = rand()%3452;
|
||||
metaGrp->mGroupFlags = rand()%43;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void init_item(RsGxsMsgMetaData* metaMsg)
|
||||
{
|
||||
|
||||
randString(SHORT_STR, metaMsg->mGroupId);
|
||||
randString(SHORT_STR, metaMsg->mMsgId);
|
||||
randString(SHORT_STR, metaMsg->mThreadId);
|
||||
randString(SHORT_STR, metaMsg->mParentId);
|
||||
randString(SHORT_STR, metaMsg->mAuthorId);
|
||||
randString(SHORT_STR, metaMsg->mOrigMsgId);
|
||||
randString(SHORT_STR, metaMsg->mMsgName);
|
||||
|
||||
init_item(metaMsg->pubSign);
|
||||
init_item(metaMsg->idSign);
|
||||
|
||||
metaMsg->mPublishTs = rand()%313;
|
||||
metaMsg->mMsgFlags = rand()%224;
|
||||
metaMsg->mMsgStatus = rand()%4242;
|
||||
metaMsg->mChildTs = rand()%221;
|
||||
}
|
||||
|
@ -2,11 +2,14 @@
|
||||
#define DATA_SUPPORT_H
|
||||
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
#include "gxs/rsgxsdata.h"
|
||||
|
||||
bool operator==(const RsNxsGrp&, const RsNxsGrp&);
|
||||
bool operator==(const RsNxsMsg&, const RsNxsMsg&);
|
||||
|
||||
void init_item(RsNxsGrp* nxg);
|
||||
void init_item(RsNxsMsg* nxm);
|
||||
void init_item(RsNxsGrp& nxg);
|
||||
void init_item(RsNxsMsg& nxm);
|
||||
void init_item(RsGxsGrpMetaData* metaGrp);
|
||||
void init_item(RsGxsMsgMetaData* metaMsg);
|
||||
|
||||
#endif // DATA_SUPPORT_H
|
||||
|
@ -19,9 +19,7 @@ int main()
|
||||
|
||||
test_groupStoreAndRetrieve(); REPORT("test_groupStoreAndRetrieve");
|
||||
|
||||
test_messageStoresAndRetrieve(); REPORT("test_messageStoresAndRetrieve");
|
||||
|
||||
test_groupVersionRetrieve(); REPORT("test_groupVersionRetrieve");
|
||||
//test_messageStoresAndRetrieve(); REPORT("test_messageStoresAndRetrieve");
|
||||
|
||||
FINALREPORT("RsDataService Tests");
|
||||
|
||||
@ -37,145 +35,32 @@ void test_groupStoreAndRetrieve(){
|
||||
setUp();
|
||||
|
||||
int nGrp = rand()%32;
|
||||
std::set<RsNxsGrp*> s;
|
||||
std::map<RsNxsGrp*, RsGxsGrpMetaData*> grps;
|
||||
RsNxsGrp* grp;
|
||||
RsGxsGrpMetaData* grpMeta;
|
||||
for(int i = 0; i < nGrp; i++){
|
||||
std::pair<RsNxsGrp*, RsGxsGrpMetaData*> p;
|
||||
grp = new RsNxsGrp(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
init_item(grp);
|
||||
s.insert(grp);
|
||||
grpMeta = new RsGxsGrpMetaData();
|
||||
p.first = grp;
|
||||
p.second = grpMeta;
|
||||
init_item(*grp);
|
||||
init_item(grpMeta);
|
||||
grps.insert(p);
|
||||
}
|
||||
|
||||
dStore->storeGroup(s);
|
||||
|
||||
std::map<std::string, RsNxsGrp*> gm;
|
||||
dStore->retrieveGrps(gm, false);
|
||||
|
||||
// now match grps together
|
||||
|
||||
// simple check,are they the same size
|
||||
CHECK(gm.size() == s.size());
|
||||
|
||||
std::set<RsNxsGrp*>::iterator sit = s.begin();
|
||||
std::map<std::string, RsNxsGrp*>::iterator mit;
|
||||
bool matched = true;
|
||||
|
||||
for(; sit != s.end(); sit++){
|
||||
RsNxsGrp* g1 = *sit;
|
||||
mit = gm.find(g1->grpId);
|
||||
|
||||
if(mit == gm.end()){
|
||||
matched = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
RsNxsGrp* g2 = gm[g1->grpId];
|
||||
|
||||
if(! (*g1 == *g2) )
|
||||
matched = false;
|
||||
|
||||
|
||||
// remove grp file
|
||||
if(g1)
|
||||
remove(g1->grpId.c_str());
|
||||
}
|
||||
|
||||
CHECK(matched);
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test_messageStoresAndRetrieve(){
|
||||
|
||||
setUp();
|
||||
|
||||
int nMsgs = rand()%32;
|
||||
std::set<RsNxsMsg*> s;
|
||||
RsNxsMsg* msg;
|
||||
std::string grpId;
|
||||
randString(SHORT_STR, grpId);
|
||||
for(int i = 0; i < nMsgs; i++){
|
||||
msg = new RsNxsMsg(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
init_item(msg);
|
||||
msg->grpId = grpId;
|
||||
s.insert(msg);
|
||||
}
|
||||
|
||||
dStore->storeMessage(s);
|
||||
|
||||
std::map<std::string, RsNxsMsg*> msgs;
|
||||
dStore->retrieveMsgs(grpId, msgs, false);
|
||||
|
||||
CHECK(msgs.size() == s.size());
|
||||
|
||||
std::set<RsNxsMsg*>::iterator sit = s.begin();
|
||||
std::map<std::string, RsNxsMsg*>::iterator mit;
|
||||
bool matched = true;
|
||||
|
||||
for(; sit != s.end(); sit++){
|
||||
RsNxsMsg* m1 = *sit;
|
||||
mit = msgs.find(m1->msgId);
|
||||
|
||||
if(mit == msgs.end()){
|
||||
matched = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
RsNxsMsg* m2 = msgs[m1->msgId];
|
||||
|
||||
if(! (*m1 == *m2) )
|
||||
matched = false;
|
||||
}
|
||||
|
||||
CHECK(matched);
|
||||
|
||||
std::string msgFile = grpId + "-msgs";
|
||||
remove(msgFile.c_str());
|
||||
|
||||
tearDown();
|
||||
}
|
||||
|
||||
|
||||
void test_groupVersionRetrieve(){
|
||||
|
||||
setUp();
|
||||
|
||||
std::set<RsNxsGrp*> grps;
|
||||
RsNxsGrp* group1 = new RsNxsGrp(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
RsNxsGrp* group2 = new RsNxsGrp(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);;
|
||||
RsNxsGrp* group3 = new RsNxsGrp(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);;
|
||||
RsNxsGrp* group2_r = NULL;
|
||||
|
||||
init_item(group1);
|
||||
init_item(group2);
|
||||
init_item(group3);
|
||||
|
||||
grps.insert(group1); grps.insert(group2); grps.insert(group3);
|
||||
|
||||
RsGxsGrpId grpId;
|
||||
grpId.grpId = group2->grpId;
|
||||
grpId.adminSign = group2->adminSign;
|
||||
|
||||
dStore->storeGroup(grps);
|
||||
group2_r = dStore->retrieveGrpVersion(grpId);
|
||||
|
||||
|
||||
CHECK(group2_r != NULL);
|
||||
|
||||
if(group2_r)
|
||||
CHECK(*group2 == *group2_r);
|
||||
|
||||
|
||||
delete group1;
|
||||
delete group2;
|
||||
delete group3;
|
||||
delete group2_r;
|
||||
std::map<std::string, RsNxsGrp*> gR;
|
||||
std::map<std::string, RsGxsGrpMetaData*> grpMetaR;
|
||||
dStore->retrieveNxsGrps(gR, false);
|
||||
dStore->retrieveGxsGrpMetaData(grpMetaR);
|
||||
|
||||
tearDown();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setUp(){
|
||||
dStore = new RsDataService(".", DATA_BASE_NAME, RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
}
|
||||
|
@ -6,10 +6,8 @@
|
||||
#include "gxs/rsgds.h"
|
||||
|
||||
void test_messageStoresAndRetrieve();
|
||||
void test_messageVersionRetrieve();
|
||||
|
||||
void test_groupStoreAndRetrieve();
|
||||
void test_groupVersionRetrieve();
|
||||
|
||||
void test_storeAndDeleteGroup();
|
||||
void test_storeAndDeleteMessage();
|
||||
@ -28,7 +26,5 @@ class DataReadWrite : RsThread
|
||||
|
||||
void test_cacheSize();
|
||||
|
||||
void init_item(RsNxsGrp*);
|
||||
void init_item(RsNxsMsg*);
|
||||
|
||||
#endif // RSDATASERVICE_TEST_H
|
||||
|
80
libretroshare/src/tests/gxs/rsgxsdata_test.cc
Normal file
80
libretroshare/src/tests/gxs/rsgxsdata_test.cc
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
#include "support.h"
|
||||
#include "data_support.h"
|
||||
#include "gxs/rsgxsdata.h"
|
||||
#include "util/utest.h"
|
||||
|
||||
INITTEST();
|
||||
|
||||
bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r);
|
||||
bool operator ==(const RsGxsMsgMetaData& l, const RsGxsMsgMetaData& r);
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
RsGxsGrpMetaData grpMeta1, grpMeta2;
|
||||
RsGxsMsgMetaData msgMeta1, msgMeta2;
|
||||
|
||||
grpMeta1.clear();
|
||||
init_item(&grpMeta1);
|
||||
|
||||
msgMeta1.clear();
|
||||
init_item(&msgMeta1);
|
||||
|
||||
uint32_t pktsize = grpMeta1.serial_size();
|
||||
char grp_data[pktsize];
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok &= grpMeta1.serialise(grp_data, pktsize);
|
||||
grpMeta2.clear();
|
||||
ok &= grpMeta2.deserialise(grp_data, pktsize);
|
||||
|
||||
CHECK(grpMeta1 == grpMeta2);
|
||||
|
||||
pktsize = msgMeta1.serial_size();
|
||||
char msg_data[pktsize];
|
||||
|
||||
ok &= msgMeta1.serialise(msg_data, &pktsize);
|
||||
msgMeta2.clear();
|
||||
ok &= msgMeta2.deserialise(msg_data, &pktsize);
|
||||
|
||||
CHECK(msgMeta1 == msgMeta2);
|
||||
|
||||
FINALREPORT("GxsMeta Data Test");
|
||||
|
||||
return TESTRESULT();
|
||||
}
|
||||
|
||||
|
||||
bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r)
|
||||
{
|
||||
if(!(l.adminSign == r.adminSign)) return false;
|
||||
if(!(l.idSign == r.idSign)) return false;
|
||||
if(!(l.keys == r.keys)) return false;
|
||||
if(l.mGroupFlags != r.mGroupFlags) return false;
|
||||
if(l.mPublishTs != r.mPublishTs) return false;
|
||||
if(l.mAuthorId != r.mAuthorId) return false;
|
||||
if(l.mGroupName != r.mGroupName) return false;
|
||||
if(l.mGroupId != r.mGroupId) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator ==(const RsGxsMsgMetaData& l, const RsGxsMsgMetaData& r)
|
||||
{
|
||||
|
||||
if(!(l.idSign == r.idSign)) return false;
|
||||
if(!(l.pubSign == r.pubSign)) return false;
|
||||
if(l.mGroupId != r.mGroupId) return false;
|
||||
if(l.mAuthorId != r.mAuthorId) return false;
|
||||
if(l.mParentId != r.mParentId) return false;
|
||||
if(l.mOrigMsgId != r.mOrigMsgId) return false;
|
||||
if(l.mThreadId != r.mThreadId) return false;
|
||||
if(l.mMsgId != r.mMsgId) return false;
|
||||
if(l.mMsgName != r.mMsgName) return false;
|
||||
if(l.mPublishTs != r.mPublishTs) return false;
|
||||
if(l.mMsgFlags != r.mMsgFlags) return false;
|
||||
|
||||
return true;
|
||||
}
|
@ -60,6 +60,37 @@ void randString(const uint32_t length, std::wstring& outStr)
|
||||
return;
|
||||
}
|
||||
|
||||
void init_item(RsTlvSecurityKeySet& ks)
|
||||
{
|
||||
int n = rand()%24;
|
||||
randString(SHORT_STR, ks.groupId);
|
||||
for(int i=1; i<n; i++)
|
||||
{
|
||||
std::string a_str;
|
||||
randString(SHORT_STR, a_str);
|
||||
|
||||
RsTlvSecurityKey& a_key = ks.keys[a_str];
|
||||
init_item(a_key);
|
||||
a_key.keyId = a_str;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const RsTlvSecurityKeySet& l, const RsTlvSecurityKeySet& r)
|
||||
{
|
||||
|
||||
if(l.groupId != r.groupId) return false;
|
||||
|
||||
std::map<std::string, RsTlvSecurityKey>::const_iterator l_cit = l.keys.begin(),
|
||||
r_cit = r.keys.begin();
|
||||
|
||||
for(; l_cit != l.keys.end(); l_cit++, r_cit++){
|
||||
if(l_cit->first != r_cit->first) return false;
|
||||
if(!(l_cit->second == r_cit->second)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const RsTlvSecurityKey& sk1, const RsTlvSecurityKey& sk2)
|
||||
{
|
||||
|
||||
|
@ -63,6 +63,7 @@ void init_item(RsTlvHashSet&);
|
||||
void init_item(RsTlvPeerIdSet&);
|
||||
void init_item(RsTlvImage&);
|
||||
void init_item(RsTlvPeerIdSet&);
|
||||
void init_item(RsTlvSecurityKeySet& );
|
||||
|
||||
bool operator==(const RsTlvSecurityKey&, const RsTlvSecurityKey& );
|
||||
bool operator==(const RsTlvKeySignature&, const RsTlvKeySignature& );
|
||||
@ -72,6 +73,7 @@ bool operator==(const RsTlvFileSet&, const RsTlvFileSet& );
|
||||
bool operator==(const RsTlvHashSet&, const RsTlvHashSet&);
|
||||
bool operator==(const RsTlvImage&, const RsTlvImage& );
|
||||
bool operator==(const RsTlvPeerIdSet& , const RsTlvPeerIdSet& );
|
||||
bool operator==(const RsTlvSecurityKeySet& , const RsTlvSecurityKeySet& );
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user