mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 07:59:29 -05:00
more changes to support testing of delayed canSend signal from circles and reputations
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7375 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
5eef86d9fd
commit
a21c3f75fb
@ -58,3 +58,57 @@ bool rs_nxs_test::RsNxsSimpleDummyReputation::getReputation(const RsGxsId& id,
|
|||||||
rep.score = 5;
|
rep.score = 5;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rs_nxs_test::RsNxsDelayedDummyCircles::RsNxsDelayedDummyCircles(
|
||||||
|
int countBeforePresent) : mCountBeforePresent(countBeforePresent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
rs_nxs_test::RsNxsDelayedDummyCircles::~RsNxsDelayedDummyCircles() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rs_nxs_test::RsNxsDelayedDummyCircles::isLoaded(
|
||||||
|
const RsGxsCircleId& circleId) {
|
||||||
|
return allowed(circleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rs_nxs_test::RsNxsDelayedDummyCircles::loadCircle(
|
||||||
|
const RsGxsCircleId& circleId) {
|
||||||
|
return allowed(circleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rs_nxs_test::RsNxsDelayedDummyCircles::canSend(
|
||||||
|
const RsGxsCircleId& circleId, const RsPgpId& id) {
|
||||||
|
return allowed(circleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rs_nxs_test::RsNxsDelayedDummyCircles::canReceive(
|
||||||
|
const RsGxsCircleId& circleId, const RsPgpId& id) {
|
||||||
|
return allowed(circleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rs_nxs_test::RsNxsDelayedDummyCircles::recipients(
|
||||||
|
const RsGxsCircleId& circleId, std::list<RsPgpId>& friendlist) {
|
||||||
|
return allowed(circleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rs_nxs_test::RsNxsDelayedDummyCircles::allowed(
|
||||||
|
const RsGxsCircleId& circleId) {
|
||||||
|
|
||||||
|
if(mMembershipCallCount.find(circleId) == mMembershipCallCount.end())
|
||||||
|
mMembershipCallCount[circleId] = 0;
|
||||||
|
|
||||||
|
if(mMembershipCallCount[circleId] >= mCountBeforePresent)
|
||||||
|
{
|
||||||
|
mMembershipCallCount[circleId]++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mMembershipCallCount[circleId]++;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,6 +52,43 @@ namespace rs_nxs_test
|
|||||||
std::list<Membership> mMembership;
|
std::list<Membership> mMembership;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* This dummy circles implementation
|
||||||
|
* allow instantiation with simple membership
|
||||||
|
* list for a given circle
|
||||||
|
*/
|
||||||
|
class RsNxsDelayedDummyCircles : public RsGcxs
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
/*!
|
||||||
|
*
|
||||||
|
* @param membership
|
||||||
|
* @param countBeforePresent how many times a pgpid is checked before it becomes present
|
||||||
|
*/
|
||||||
|
RsNxsDelayedDummyCircles(int countBeforePresent);
|
||||||
|
virtual ~RsNxsDelayedDummyCircles();
|
||||||
|
|
||||||
|
/* GXS Interface - for working out who can receive */
|
||||||
|
bool isLoaded(const RsGxsCircleId &circleId);
|
||||||
|
bool loadCircle(const RsGxsCircleId &circleId);
|
||||||
|
|
||||||
|
int canSend(const RsGxsCircleId &circleId, const RsPgpId &id);
|
||||||
|
int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id);
|
||||||
|
bool recipients(const RsGxsCircleId &circleId, std::list<RsPgpId> &friendlist);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
bool allowed(const RsGxsCircleId& circleId);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
typedef int CallCount;
|
||||||
|
std::map<RsGxsCircleId, CallCount> mMembershipCallCount;
|
||||||
|
int mCountBeforePresent;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This dummy reputation allows you to set the
|
* This dummy reputation allows you to set the
|
||||||
* reputations of peers
|
* reputations of peers
|
||||||
|
@ -84,7 +84,7 @@ void NxsMsgTestScenario::cleanTestScenario()
|
|||||||
|
|
||||||
for(; cit != peerIds.end(); cit++)
|
for(; cit != peerIds.end(); cit++)
|
||||||
{
|
{
|
||||||
std::string tableFile = "grp_store_" + cit->toStdString();
|
std::string tableFile = "msg_store_" + cit->toStdString();
|
||||||
remove(tableFile.c_str());
|
remove(tableFile.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user