2014-04-05 03:27:18 -04:00
|
|
|
#include "libretroshare/serialiser/support.h"
|
|
|
|
#include "data_support.h"
|
|
|
|
|
2014-04-05 12:01:08 -04:00
|
|
|
template<class T> void init_random(T& t) { t = T::random() ; }
|
2014-04-05 03:27:18 -04:00
|
|
|
|
|
|
|
bool operator==(const RsNxsGrp& l, const RsNxsGrp& r){
|
|
|
|
|
|
|
|
if(l.grpId != r.grpId) return false;
|
|
|
|
if(!(l.grp == r.grp) ) 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.msg == r.msg) ) return false;
|
|
|
|
if(! (l.meta == r.meta) ) return false;
|
|
|
|
if(l.transactionNumber != r.transactionNumber) return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool operator ==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r)
|
|
|
|
{
|
|
|
|
if(!(l.signSet == r.signSet)) return false;
|
|
|
|
if(!(l.keys == r.keys)) return false;
|
|
|
|
if(l.mGroupFlags != r.mGroupFlags) return false;
|
|
|
|
if(l.mPublishTs != r.mPublishTs) return false;
|
2015-12-20 11:24:13 -05:00
|
|
|
if(l.mSignFlags != r.mSignFlags) return false;
|
2014-04-05 03:27:18 -04:00
|
|
|
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.signSet == r.signSet)) return false;
|
|
|
|
if(l.mGroupId != r.mGroupId) return false;
|
|
|
|
if(l.mAuthorId != r.mAuthorId) return false;
|
|
|
|
if(l.mParentId != r.mParentId) return false;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
void init_item(RsNxsGrp& nxg)
|
|
|
|
{
|
|
|
|
|
|
|
|
nxg.clear();
|
|
|
|
|
|
|
|
nxg.grpId.random();
|
|
|
|
nxg.transactionNumber = rand()%23;
|
|
|
|
init_item(nxg.grp);
|
|
|
|
init_item(nxg.meta);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void init_item(RsNxsMsg& nxm)
|
|
|
|
{
|
|
|
|
nxm.clear();
|
|
|
|
|
|
|
|
nxm.msgId.random();
|
|
|
|
nxm.grpId.random();
|
|
|
|
init_item(nxm.msg);
|
|
|
|
init_item(nxm.meta);
|
|
|
|
nxm.transactionNumber = rand()%23;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
void init_item(RsGxsGrpMetaData* metaGrp)
|
|
|
|
{
|
|
|
|
|
2014-04-05 12:01:08 -04:00
|
|
|
init_random(metaGrp->mGroupId);
|
|
|
|
init_random(metaGrp->mOrigGrpId);
|
|
|
|
init_random(metaGrp->mAuthorId);
|
|
|
|
init_random(metaGrp->mCircleId);
|
|
|
|
init_random(metaGrp->mParentGrpId);
|
2014-04-05 03:27:18 -04:00
|
|
|
randString(SHORT_STR, metaGrp->mGroupName);
|
2014-04-05 12:01:08 -04:00
|
|
|
randString(SHORT_STR, metaGrp->mServiceString);
|
2014-04-05 03:27:18 -04:00
|
|
|
|
|
|
|
init_item(metaGrp->signSet);
|
|
|
|
init_item(metaGrp->keys);
|
|
|
|
|
|
|
|
metaGrp->mPublishTs = rand()%3452;
|
|
|
|
metaGrp->mGroupFlags = rand()%43;
|
2014-04-05 12:01:08 -04:00
|
|
|
metaGrp->mSignFlags = rand()%43;
|
|
|
|
metaGrp->mAuthenFlags = rand()%43;
|
2014-04-05 03:27:18 -04:00
|
|
|
|
|
|
|
metaGrp->mSubscribeFlags = rand()%2251;
|
2014-04-05 12:01:08 -04:00
|
|
|
metaGrp->mPop = rand()%5262;
|
2015-01-11 17:19:32 -05:00
|
|
|
metaGrp->mVisibleMsgCount = rand()%2421;
|
2014-04-05 03:27:18 -04:00
|
|
|
metaGrp->mLastPost = rand()%2211;
|
2014-04-05 12:01:08 -04:00
|
|
|
metaGrp->mReputationCutOff = rand()%5262;
|
|
|
|
|
|
|
|
metaGrp->mGroupStatus = rand()%313;
|
|
|
|
metaGrp->mRecvTS = rand()%313;
|
|
|
|
|
|
|
|
metaGrp->mOriginator = RsPeerId::random() ;
|
|
|
|
metaGrp->mInternalCircle = RsGxsCircleId::random() ;
|
|
|
|
metaGrp->mHash = RsFileHash::random() ;
|
2014-04-05 03:27:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void init_item(RsGxsMsgMetaData* metaMsg)
|
|
|
|
{
|
|
|
|
|
2014-04-05 12:01:08 -04:00
|
|
|
init_random(metaMsg->mGroupId) ;
|
|
|
|
init_random(metaMsg->mMsgId) ;
|
2014-04-05 12:27:10 -04:00
|
|
|
metaMsg->refcount = 1;
|
2014-04-05 12:01:08 -04:00
|
|
|
init_random(metaMsg->mThreadId) ;
|
|
|
|
init_random(metaMsg->mParentId) ;
|
|
|
|
init_random(metaMsg->mOrigMsgId) ;
|
2014-04-05 12:27:10 -04:00
|
|
|
init_random(metaMsg->mAuthorId) ;
|
2014-04-05 03:27:18 -04:00
|
|
|
|
|
|
|
init_item(metaMsg->signSet);
|
|
|
|
|
2014-04-05 12:27:10 -04:00
|
|
|
randString(SHORT_STR, metaMsg->mServiceString);
|
|
|
|
|
|
|
|
randString(SHORT_STR, metaMsg->mMsgName);
|
|
|
|
|
2014-04-05 03:27:18 -04:00
|
|
|
metaMsg->mPublishTs = rand()%313;
|
|
|
|
metaMsg->mMsgFlags = rand()%224;
|
|
|
|
metaMsg->mMsgStatus = rand()%4242;
|
|
|
|
metaMsg->mChildTs = rand()%221;
|
2014-04-05 12:27:10 -04:00
|
|
|
metaMsg->recvTS = rand()%2327 ;
|
|
|
|
|
|
|
|
init_random(metaMsg->mHash) ;
|
|
|
|
metaMsg->validated = true ;
|
2014-04-05 03:27:18 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RsSerialType* init_item(RsNxsGrp& nxg)
|
|
|
|
{
|
|
|
|
nxg.clear();
|
|
|
|
|
2014-04-05 12:01:08 -04:00
|
|
|
init_random(nxg.grpId) ;
|
2014-04-05 03:27:18 -04:00
|
|
|
nxg.transactionNumber = rand()%23;
|
|
|
|
init_item(nxg.grp);
|
|
|
|
init_item(nxg.meta);
|
|
|
|
|
|
|
|
return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RsSerialType* init_item(RsNxsMsg& nxm)
|
|
|
|
{
|
|
|
|
nxm.clear();
|
|
|
|
|
2014-04-05 12:01:08 -04:00
|
|
|
init_random(nxm.msgId) ;
|
|
|
|
init_random(nxm.grpId) ;
|
2014-04-05 03:27:18 -04:00
|
|
|
init_item(nxm.msg);
|
|
|
|
init_item(nxm.meta);
|
|
|
|
nxm.transactionNumber = rand()%23;
|
|
|
|
|
|
|
|
return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
|
|
|
}
|
|
|
|
|
2016-03-26 17:25:15 -04:00
|
|
|
RsSerialType* init_item(RsNxsSyncGrpReqItem& rsg)
|
2014-04-05 03:27:18 -04:00
|
|
|
{
|
|
|
|
rsg.clear();
|
2016-03-26 17:25:15 -04:00
|
|
|
rsg.flag = RsNxsSyncGrpItem::FLAG_USE_SYNC_HASH;
|
2014-04-05 03:27:18 -04:00
|
|
|
rsg.createdSince = rand()%2423;
|
|
|
|
randString(3124,rsg.syncHash);
|
|
|
|
|
|
|
|
return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
|
|
|
}
|
|
|
|
|
2016-03-26 17:25:15 -04:00
|
|
|
RsSerialType* init_item(RsNxsSyncMsgReqItem& rsgm)
|
2014-04-05 03:27:18 -04:00
|
|
|
{
|
|
|
|
rsgm.clear();
|
|
|
|
|
2016-03-26 17:25:15 -04:00
|
|
|
rsgm.flag = RsNxsSyncMsgItem::FLAG_USE_SYNC_HASH;
|
2016-12-08 08:30:47 -05:00
|
|
|
rsgm.createdSinceTS = rand()%24232;
|
2014-04-05 03:27:18 -04:00
|
|
|
rsgm.transactionNumber = rand()%23;
|
2014-04-05 12:01:08 -04:00
|
|
|
init_random(rsgm.grpId) ;
|
2014-04-05 03:27:18 -04:00
|
|
|
randString(SHORT_STR, rsgm.syncHash);
|
|
|
|
|
|
|
|
return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
|
|
|
}
|
|
|
|
|
|
|
|
RsSerialType* init_item(RsNxsSyncGrpItem& rsgl)
|
|
|
|
{
|
|
|
|
rsgl.clear();
|
|
|
|
|
|
|
|
rsgl.flag = RsNxsSyncGrpItem::FLAG_RESPONSE;
|
|
|
|
rsgl.transactionNumber = rand()%23;
|
|
|
|
rsgl.publishTs = rand()%23;
|
2014-04-05 12:01:08 -04:00
|
|
|
init_random(rsgl.grpId) ;
|
2014-04-05 03:27:18 -04:00
|
|
|
|
|
|
|
return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
|
|
|
}
|
|
|
|
|
|
|
|
RsSerialType* init_item(RsNxsSyncMsgItem& rsgml)
|
|
|
|
{
|
|
|
|
rsgml.clear();
|
|
|
|
|
|
|
|
rsgml.flag = RsNxsSyncGrpItem::FLAG_RESPONSE;
|
|
|
|
rsgml.transactionNumber = rand()%23;
|
2014-04-05 12:01:08 -04:00
|
|
|
init_random(rsgml.grpId) ;
|
|
|
|
init_random(rsgml.msgId) ;
|
2014-04-05 03:27:18 -04:00
|
|
|
|
|
|
|
return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
|
|
|
}
|
|
|
|
|
2016-03-26 17:25:15 -04:00
|
|
|
RsSerialType* init_item(RsNxsTransacItem &rstx){
|
2014-04-05 03:27:18 -04:00
|
|
|
|
|
|
|
rstx.clear();
|
|
|
|
|
|
|
|
rstx.timestamp = rand()%14141;
|
|
|
|
rstx.transactFlag = rand()%2424;
|
|
|
|
rstx.nItems = rand()%33132;
|
|
|
|
rstx.transactionNumber = rand()%242112;
|
|
|
|
|
|
|
|
return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-03-26 17:25:15 -04:00
|
|
|
bool operator==(const RsNxsSyncGrpReqItem& l, const RsNxsSyncGrpReqItem& r)
|
2014-04-05 03:27:18 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
if(l.syncHash != r.syncHash) return false;
|
|
|
|
if(l.flag != r.flag) return false;
|
|
|
|
if(l.createdSince != r.createdSince) return false;
|
|
|
|
if(l.transactionNumber != r.transactionNumber) return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-03-26 17:25:15 -04:00
|
|
|
bool operator==(const RsNxsSyncMsgReqItem& l, const RsNxsSyncMsgReqItem& r)
|
2014-04-05 03:27:18 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
if(l.flag != r.flag) return false;
|
2016-12-08 08:30:47 -05:00
|
|
|
if(l.createdSinceTS != r.createdSinceTS) return false;
|
2014-04-05 03:27:18 -04:00
|
|
|
if(l.syncHash != r.syncHash) return false;
|
|
|
|
if(l.grpId != r.grpId) return false;
|
|
|
|
if(l.transactionNumber != r.transactionNumber) return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const RsNxsSyncGrpItem& l, const RsNxsSyncGrpItem& r)
|
|
|
|
{
|
|
|
|
if(l.flag != r.flag) return false;
|
|
|
|
if(l.publishTs != r.publishTs) return false;
|
|
|
|
if(l.grpId != r.grpId) return false;
|
|
|
|
if(l.transactionNumber != r.transactionNumber) return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const RsNxsSyncMsgItem& l, const RsNxsSyncMsgItem& r)
|
|
|
|
{
|
|
|
|
if(l.flag != r.flag) return false;
|
|
|
|
if(l.grpId != r.grpId) return false;
|
|
|
|
if(l.msgId != r.msgId) return false;
|
|
|
|
if(l.transactionNumber != r.transactionNumber) return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-03-26 17:25:15 -04:00
|
|
|
bool operator==(const RsNxsTransacItem& l, const RsNxsTransacItem& r){
|
2014-04-05 03:27:18 -04:00
|
|
|
|
|
|
|
if(l.transactFlag != r.transactFlag) return false;
|
|
|
|
if(l.transactionNumber != r.transactionNumber) return false;
|
2015-12-20 08:32:11 -05:00
|
|
|
// timestamp is not serialised, see rsnxsitems.h
|
|
|
|
//if(l.timestamp != r.timestamp) return false;
|
2014-04-05 03:27:18 -04:00
|
|
|
if(l.nItems != r.nItems) return false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|