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:
chrisparker126 2014-05-18 17:24:21 +00:00
parent 5eef86d9fd
commit a21c3f75fb
3 changed files with 92 additions and 1 deletions

View File

@ -58,3 +58,57 @@ bool rs_nxs_test::RsNxsSimpleDummyReputation::getReputation(const RsGxsId& id,
rep.score = 5;
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;
}
}

View File

@ -52,6 +52,43 @@ namespace rs_nxs_test
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
* reputations of peers

View File

@ -84,7 +84,7 @@ void NxsMsgTestScenario::cleanTestScenario()
for(; cit != peerIds.end(); cit++)
{
std::string tableFile = "grp_store_" + cit->toStdString();
std::string tableFile = "msg_store_" + cit->toStdString();
remove(tableFile.c_str());
}