mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-03-24 15:56:35 -04:00
fixed unit tests
This commit is contained in:
parent
1b8b9d4e56
commit
ebf54d1340
@ -13,10 +13,8 @@ const uint8_t RsNxsSyncGrpItem::FLAG_RESPONSE = 0x002;
|
||||
const uint8_t RsNxsSyncMsgItem::FLAG_REQUEST = 0x001;
|
||||
const uint8_t RsNxsSyncMsgItem::FLAG_RESPONSE = 0x002;
|
||||
|
||||
#ifdef UNUSED_CODE
|
||||
const uint8_t RsNxsSyncGrpItem::FLAG_USE_SYNC_HASH = 0x001;
|
||||
const uint8_t RsNxsSyncMsgItem::FLAG_USE_SYNC_HASH = 0x001;
|
||||
#endif
|
||||
|
||||
/** transaction state **/
|
||||
const uint16_t RsNxsTransacItem::FLAG_BEGIN_P1 = 0x0001;
|
||||
|
@ -221,9 +221,7 @@ public:
|
||||
|
||||
static const uint8_t FLAG_REQUEST;
|
||||
static const uint8_t FLAG_RESPONSE;
|
||||
#ifdef UNUSED_CODE
|
||||
static const uint8_t FLAG_USE_SYNC_HASH;
|
||||
#endif
|
||||
|
||||
RsNxsSyncGrpItem(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_SYNC_GRP_ITEM) { clear(); return ; }
|
||||
virtual ~RsNxsSyncGrpItem() { return; }
|
||||
|
@ -176,21 +176,21 @@ RsSerialType* init_item(RsNxsMsg& nxm)
|
||||
return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
}
|
||||
|
||||
RsSerialType* init_item(RsNxsSyncGrp& rsg)
|
||||
RsSerialType* init_item(RsNxsSyncGrpReqItem& rsg)
|
||||
{
|
||||
rsg.clear();
|
||||
rsg.flag = RsNxsSyncGrp::FLAG_USE_SYNC_HASH;
|
||||
rsg.flag = RsNxsSyncGrpItem::FLAG_USE_SYNC_HASH;
|
||||
rsg.createdSince = rand()%2423;
|
||||
randString(3124,rsg.syncHash);
|
||||
|
||||
return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
}
|
||||
|
||||
RsSerialType* init_item(RsNxsSyncMsg& rsgm)
|
||||
RsSerialType* init_item(RsNxsSyncMsgReqItem& rsgm)
|
||||
{
|
||||
rsgm.clear();
|
||||
|
||||
rsgm.flag = RsNxsSyncMsg::FLAG_USE_SYNC_HASH;
|
||||
rsgm.flag = RsNxsSyncMsgItem::FLAG_USE_SYNC_HASH;
|
||||
rsgm.createdSince = rand()%24232;
|
||||
rsgm.transactionNumber = rand()%23;
|
||||
init_random(rsgm.grpId) ;
|
||||
@ -223,7 +223,7 @@ RsSerialType* init_item(RsNxsSyncMsgItem& rsgml)
|
||||
return new RsNxsSerialiser(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
}
|
||||
|
||||
RsSerialType* init_item(RsNxsTransac& rstx){
|
||||
RsSerialType* init_item(RsNxsTransacItem &rstx){
|
||||
|
||||
rstx.clear();
|
||||
|
||||
@ -236,7 +236,7 @@ RsSerialType* init_item(RsNxsTransac& rstx){
|
||||
}
|
||||
|
||||
|
||||
bool operator==(const RsNxsSyncGrp& l, const RsNxsSyncGrp& r)
|
||||
bool operator==(const RsNxsSyncGrpReqItem& l, const RsNxsSyncGrpReqItem& r)
|
||||
{
|
||||
|
||||
if(l.syncHash != r.syncHash) return false;
|
||||
@ -247,7 +247,7 @@ bool operator==(const RsNxsSyncGrp& l, const RsNxsSyncGrp& r)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const RsNxsSyncMsg& l, const RsNxsSyncMsg& r)
|
||||
bool operator==(const RsNxsSyncMsgReqItem& l, const RsNxsSyncMsgReqItem& r)
|
||||
{
|
||||
|
||||
if(l.flag != r.flag) return false;
|
||||
@ -279,7 +279,7 @@ bool operator==(const RsNxsSyncMsgItem& l, const RsNxsSyncMsgItem& r)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator==(const RsNxsTransac& l, const RsNxsTransac& r){
|
||||
bool operator==(const RsNxsTransacItem& l, const RsNxsTransacItem& r){
|
||||
|
||||
if(l.transactFlag != r.transactFlag) return false;
|
||||
if(l.transactionNumber != r.transactionNumber) return false;
|
||||
|
@ -9,11 +9,11 @@ bool operator==(const RsNxsGrp&, const RsNxsGrp&);
|
||||
bool operator==(const RsNxsMsg&, const RsNxsMsg&);
|
||||
bool operator==(const RsGxsGrpMetaData& l, const RsGxsGrpMetaData& r);
|
||||
bool operator==(const RsGxsMsgMetaData& l, const RsGxsMsgMetaData& r);
|
||||
bool operator==(const RsNxsSyncGrp& l, const RsNxsSyncGrp& r);
|
||||
bool operator==(const RsNxsSyncMsg& l, const RsNxsSyncMsg& r);
|
||||
bool operator==(const RsNxsSyncGrpItem& l, const RsNxsSyncGrpItem& r);
|
||||
bool operator==(const RsNxsSyncMsgItem& l, const RsNxsSyncMsgItem& r);
|
||||
bool operator==(const RsNxsTransac& l, const RsNxsTransac& r);
|
||||
bool operator==(const RsNxsSyncGrpItem& l, const RsNxsSyncGrpItem& r);
|
||||
bool operator==(const RsNxsSyncMsgItem& l, const RsNxsSyncMsgItem& r);
|
||||
bool operator==(const RsNxsTransacItem& l, const RsNxsTransacItem& r);
|
||||
|
||||
//void init_item(RsNxsGrp& nxg);
|
||||
//void init_item(RsNxsMsg& nxm);
|
||||
@ -23,11 +23,11 @@ void init_item(RsGxsMsgMetaData* metaMsg);
|
||||
|
||||
RsSerialType* init_item(RsNxsGrp& nxg);
|
||||
RsSerialType* init_item(RsNxsMsg& nxm);
|
||||
RsSerialType* init_item(RsNxsSyncGrp& rsg);
|
||||
RsSerialType* init_item(RsNxsSyncMsg& rsgm);
|
||||
RsSerialType* init_item(RsNxsSyncGrpReqItem &rsg);
|
||||
RsSerialType* init_item(RsNxsSyncMsgReqItem &rsgm);
|
||||
RsSerialType* init_item(RsNxsSyncGrpItem& rsgl);
|
||||
RsSerialType* init_item(RsNxsSyncMsgItem& rsgml);
|
||||
RsSerialType* init_item(RsNxsTransac& rstx);
|
||||
RsSerialType* init_item(RsNxsTransacItem& rstx);
|
||||
|
||||
template<typename T>
|
||||
void copy_all_but(T& ex, const std::list<T>& s, std::list<T>& d)
|
||||
|
@ -24,7 +24,7 @@ bool rs_nxs_test::RsNxsSimpleDummyCircles::loadCircle(
|
||||
}
|
||||
|
||||
int rs_nxs_test::RsNxsSimpleDummyCircles::canSend(const RsGxsCircleId& circleId,
|
||||
const RsPgpId& id) {
|
||||
const RsPgpId& id, bool &should_encrypt) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -33,11 +33,20 @@ int rs_nxs_test::RsNxsSimpleDummyCircles::canReceive(
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rs_nxs_test::RsNxsSimpleDummyCircles::isRecipient(const RsGxsCircleId &circleId, const RsGxsId& id)
|
||||
{
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool rs_nxs_test::RsNxsSimpleDummyCircles::recipients(
|
||||
const RsGxsCircleId& circleId, std::list<RsPgpId>& friendlist) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool rs_nxs_test::RsNxsSimpleDummyCircles::recipients(
|
||||
const RsGxsCircleId& circleId, std::list<RsGxsId>& friendlist) {
|
||||
return true;
|
||||
}
|
||||
rs_nxs_test::RsNxsSimpleDummyReputation::RsNxsSimpleDummyReputation(
|
||||
RepMap& repMap, bool cached) {
|
||||
}
|
||||
@ -76,8 +85,7 @@ bool rs_nxs_test::RsNxsDelayedDummyCircles::loadCircle(
|
||||
return allowed(circleId);
|
||||
}
|
||||
|
||||
int rs_nxs_test::RsNxsDelayedDummyCircles::canSend(
|
||||
const RsGxsCircleId& circleId, const RsPgpId& id) {
|
||||
int rs_nxs_test::RsNxsDelayedDummyCircles::canSend(const RsGxsCircleId& circleId, const RsPgpId& id, bool &should_encrypt) {
|
||||
return allowed(circleId);
|
||||
}
|
||||
|
||||
|
@ -39,10 +39,13 @@ namespace rs_nxs_test
|
||||
bool isLoaded(const RsGxsCircleId &circleId);
|
||||
bool loadCircle(const RsGxsCircleId &circleId);
|
||||
|
||||
int canSend(const RsGxsCircleId &circleId, const RsPgpId &id);
|
||||
int canSend(const RsGxsCircleId &circleId, const RsPgpId &id,bool& should_encrypt);
|
||||
int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id);
|
||||
bool recipients(const RsGxsCircleId &circleId, std::list<RsPgpId> &friendlist);
|
||||
|
||||
virtual bool recipients(const RsGxsCircleId &circleId, std::list<RsGxsId>& idlist) ;
|
||||
virtual bool isRecipient(const RsGxsCircleId &circleId, const RsGxsId& id) ;
|
||||
virtual bool getLocalCircleServerUpdateTS(const RsGxsCircleId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) { return true ; }
|
||||
};
|
||||
|
||||
/*!
|
||||
@ -66,10 +69,13 @@ namespace rs_nxs_test
|
||||
bool isLoaded(const RsGxsCircleId &circleId);
|
||||
bool loadCircle(const RsGxsCircleId &circleId);
|
||||
|
||||
int canSend(const RsGxsCircleId &circleId, const RsPgpId &id);
|
||||
int canSend(const RsGxsCircleId &circleId, const RsPgpId &id,bool& should_encrypt);
|
||||
int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id);
|
||||
bool recipients(const RsGxsCircleId &circleId, std::list<RsPgpId> &friendlist);
|
||||
|
||||
virtual bool recipients(const RsGxsCircleId &circleId, std::list<RsGxsId>& idlist) { return true ;}
|
||||
virtual bool isRecipient(const RsGxsCircleId &circleId, const RsGxsId& id) { return allowed(circleId) ; }
|
||||
virtual bool getLocalCircleServerUpdateTS(const RsGxsCircleId& gid,time_t& grp_server_update_TS,time_t& msg_server_update_TS) { return true ; }
|
||||
private:
|
||||
|
||||
bool allowed(const RsGxsCircleId& circleId);
|
||||
|
@ -81,6 +81,7 @@ rs_nxs_test::NxsTestHub::NxsTestHub(NxsTestScenario::pointer testScenario)
|
||||
mTestScenario->getServiceInfo(),
|
||||
mTestScenario->getDummyReputations(*cit),
|
||||
mTestScenario->getDummyCircles(*cit),
|
||||
NULL,
|
||||
mTestScenario->getDummyPgpUtils(),
|
||||
true
|
||||
)
|
||||
|
@ -12,9 +12,9 @@ TEST(libretroshare_serialiser, RsNxsItem)
|
||||
{
|
||||
test_RsItem<RsNxsGrp>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
test_RsItem<RsNxsMsg>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
test_RsItem<RsNxsSyncGrp>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
test_RsItem<RsNxsSyncMsg>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
test_RsItem<RsNxsSyncGrpItem>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
test_RsItem<RsNxsSyncMsgItem>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
test_RsItem<RsNxsTransac>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
test_RsItem<RsNxsSyncGrpItem>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
test_RsItem<RsNxsSyncMsgItem>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
test_RsItem<RsNxsTransacItem>(RS_SERVICE_TYPE_PLUGIN_SIMPLE_FORUM);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ GxsPeerNode::GxsPeerNode(const RsPeerId &ownId, const std::list<RsPeerId> &frien
|
||||
mGxsIdNs = new RsGxsNetService(
|
||||
RS_SERVICE_GXS_TYPE_GXSID, mGxsIdDs, nxsMgr,
|
||||
mGxsIdService, mGxsIdService->getServiceInfo(),
|
||||
mGxsIdService, mGxsCircles,
|
||||
mGxsIdService, mGxsCircles,mGxsIdService,
|
||||
mPgpAuxUtils,
|
||||
false); // don't synchronise group automatic (need explicit group request)
|
||||
|
||||
@ -81,7 +81,7 @@ GxsPeerNode::GxsPeerNode(const RsPeerId &ownId, const std::list<RsPeerId> &frien
|
||||
#endif
|
||||
(RS_SERVICE_GXS_TYPE_GXSCIRCLE, mGxsCirclesDs, nxsMgr,
|
||||
mGxsCircles, mGxsCircles->getServiceInfo(),
|
||||
mGxsIdService, mGxsCircles,
|
||||
mGxsIdService, mGxsCircles,NULL,
|
||||
mPgpAuxUtils);
|
||||
}
|
||||
else
|
||||
@ -107,7 +107,7 @@ GxsPeerNode::GxsPeerNode(const RsPeerId &ownId, const std::list<RsPeerId> &frien
|
||||
#endif
|
||||
(RS_SERVICE_GXS_TYPE_TEST, mTestDs, nxsMgr,
|
||||
mTestService, mTestService->getServiceInfo(),
|
||||
mGxsIdService, mGxsCircles,
|
||||
mGxsIdService, mGxsCircles,mGxsIdService,
|
||||
mPgpAuxUtils);
|
||||
|
||||
if (mUseIdentityService)
|
||||
|
@ -54,7 +54,7 @@ TEST(libretroshare_services, DISABLED_GXS_nxs_basic)
|
||||
std::cerr << "Sending in SyncGrp";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsNxsSyncGrp *syncGrp = new RsNxsSyncGrp(RS_SERVICE_GXS_TYPE_TEST);
|
||||
RsNxsSyncGrpItem *syncGrp = new RsNxsSyncGrpItem(RS_SERVICE_GXS_TYPE_TEST);
|
||||
syncGrp->flag = 0; //RsNxsSyncGrp::FLAG_USE_SYNC_HASH;
|
||||
syncGrp->PeerId(friendId);
|
||||
tester.sendPacket(syncGrp);
|
||||
@ -69,7 +69,7 @@ TEST(libretroshare_services, DISABLED_GXS_nxs_basic)
|
||||
std::cerr << "Recved in SyncGrp";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsNxsSyncGrp *grp = dynamic_cast<RsNxsSyncGrp *>(item);
|
||||
RsNxsSyncGrpItem *grp = dynamic_cast<RsNxsSyncGrpItem *>(item);
|
||||
ASSERT_TRUE(grp);
|
||||
delete grp;
|
||||
|
||||
@ -134,7 +134,7 @@ TEST(libretroshare_services, DISABLED_GXS_nxs_basic2)
|
||||
std::cerr << "Created Groups.";
|
||||
std::cerr << std::endl;
|
||||
|
||||
RsNxsSyncGrp *syncGrp = new RsNxsSyncGrp(RS_SERVICE_GXS_TYPE_TEST);
|
||||
RsNxsSyncGrpItem *syncGrp= new RsNxsSyncGrpItem(RS_SERVICE_GXS_TYPE_TEST);
|
||||
syncGrp->flag = 0; //RsNxsSyncGrp::FLAG_USE_SYNC_HASH;
|
||||
syncGrp->PeerId(friendId);
|
||||
tester.sendPacket(syncGrp);
|
||||
@ -159,8 +159,8 @@ TEST(libretroshare_services, DISABLED_GXS_nxs_basic2)
|
||||
item->print(std::cerr);
|
||||
|
||||
// ignore NxsSyncGrp.
|
||||
RsNxsSyncGrp *grp = dynamic_cast<RsNxsSyncGrp *>(item);
|
||||
RsNxsTransac *trans = dynamic_cast<RsNxsTransac *>(item);
|
||||
RsNxsSyncGrpItem *grp = dynamic_cast<RsNxsSyncGrpItem *>(item);
|
||||
RsNxsTransacItem *trans = dynamic_cast<RsNxsTransacItem *>(item);
|
||||
if (grp)
|
||||
{
|
||||
std::cerr << "Recved in SyncGrp - ignoring";
|
||||
|
@ -41,7 +41,7 @@ TEST(libretroshare_services, DISABLED_GxsNxsPairExchange1)
|
||||
dropFilter.setUseSource(true);
|
||||
dropFilter.addSource(p2);
|
||||
{
|
||||
RsNxsSyncGrp *syncGrp = new RsNxsSyncGrp(RS_SERVICE_GXS_TYPE_TEST);
|
||||
RsNxsSyncGrpItem *syncGrp = new RsNxsSyncGrpItem(RS_SERVICE_GXS_TYPE_TEST);
|
||||
dropFilter.setUseFullTypes(true);
|
||||
dropFilter.addFullType(syncGrp->PacketId());
|
||||
}
|
||||
@ -111,7 +111,7 @@ TEST(libretroshare_services, DISABLED_GxsNxsPairExchange2)
|
||||
dropFilter.setUseSource(true);
|
||||
dropFilter.addSource(p2);
|
||||
{
|
||||
RsNxsSyncGrp *syncGrp = new RsNxsSyncGrp(RS_SERVICE_GXS_TYPE_TEST);
|
||||
RsNxsSyncGrpItem *syncGrp = new RsNxsSyncGrpItem(RS_SERVICE_GXS_TYPE_TEST);
|
||||
dropFilter.setUseFullTypes(true);
|
||||
dropFilter.addFullType(syncGrp->PacketId());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user