2012-07-05 21:26:14 +00:00
|
|
|
#ifndef NXSTESTHUB_H
|
|
|
|
#define NXSTESTHUB_H
|
|
|
|
|
|
|
|
#include "util/rsthreads.h"
|
|
|
|
#include "gxs/rsgxsnetservice.h"
|
2012-07-12 20:18:58 +00:00
|
|
|
#include "nxstestscenario.h"
|
|
|
|
|
|
|
|
// it would probably be useful if the test scenario
|
|
|
|
// provided the net dummy managers
|
|
|
|
// hence one could envision synchronising between an arbitrary number
|
|
|
|
// of peers
|
2012-07-05 21:26:14 +00:00
|
|
|
|
|
|
|
|
2012-07-12 20:18:58 +00:00
|
|
|
class NxsNetDummyMgr1 : public RsNxsNetMgr
|
|
|
|
{
|
2012-07-05 21:26:14 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2012-07-12 20:18:58 +00:00
|
|
|
NxsNetDummyMgr1() : mOwnId("peerA") {
|
|
|
|
|
|
|
|
mPeers.insert("peerB");
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getOwnId() { return mOwnId; }
|
|
|
|
void getOnlineList(std::set<std::string>& ssl_peers) { ssl_peers = mPeers; }
|
|
|
|
|
|
|
|
private:
|
2012-07-05 21:26:14 +00:00
|
|
|
|
2012-07-12 20:18:58 +00:00
|
|
|
std::string mOwnId;
|
|
|
|
std::set<std::string> mPeers;
|
2012-07-05 21:26:14 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2012-07-12 20:18:58 +00:00
|
|
|
class NxsNetDummyMgr2 : public RsNxsNetMgr
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
NxsNetDummyMgr2() : mOwnId("peerB") {
|
2012-07-05 21:26:14 +00:00
|
|
|
|
2012-07-12 20:18:58 +00:00
|
|
|
mPeers.insert("peerA");
|
2012-07-05 21:26:14 +00:00
|
|
|
|
2012-07-12 20:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string getOwnId() { return mOwnId; }
|
|
|
|
void getOnlineList(std::set<std::string>& ssl_peers) { ssl_peers = mPeers; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
std::string mOwnId;
|
|
|
|
std::set<std::string> mPeers;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Testing of nxs services occurs through use of two services
|
|
|
|
* When a service sends this class can interrogate the send and the receives of
|
|
|
|
*
|
|
|
|
* NxsScenario stores the type of synchronisation to be tested
|
|
|
|
* Operation:
|
|
|
|
* First NxsTestHub needs to be instantiated with a test scenario
|
|
|
|
* * The scenario contains two databases to be used on the communicating pair of RsGxsNetService instances (net instances)
|
|
|
|
* The Test hub has a ticker service for the p3Services which allows the netservices to search what groups and messages they have
|
|
|
|
* and synchronise according to their subscriptions. The default is to subscribe to all groups held by other peer
|
|
|
|
* The threads for both net instances are started which begins their processing of transactions
|
|
|
|
*/
|
2012-07-05 21:26:14 +00:00
|
|
|
class NxsTestHub : public RsThread
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
2012-07-12 20:18:58 +00:00
|
|
|
/*!
|
|
|
|
* This construct the test hub
|
|
|
|
* for a give scenario in mind
|
|
|
|
*/
|
|
|
|
NxsTestHub(NxsTestScenario*);
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
virtual ~NxsTestHub();
|
2012-07-05 21:26:14 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* To be called only after this thread has
|
|
|
|
* been shutdown
|
|
|
|
*/
|
|
|
|
bool testsPassed();
|
|
|
|
|
2012-07-12 20:18:58 +00:00
|
|
|
/*!
|
|
|
|
* This simulates the p3Service ticker and calls both gxs net services tick methods
|
|
|
|
* Also enables transport of messages between both services
|
|
|
|
*/
|
2012-07-05 21:26:14 +00:00
|
|
|
void run();
|
2012-07-12 20:18:58 +00:00
|
|
|
|
|
|
|
|
2012-07-14 17:59:54 +00:00
|
|
|
void cleanUp();
|
2012-07-12 20:18:58 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
std::pair<p3Service*, p3Service*> mServicePairs;
|
|
|
|
std::pair<RsGxsNetService*, RsGxsNetService*> netServicePairs;
|
|
|
|
NxsTestScenario *mTestScenario;
|
|
|
|
|
|
|
|
NxsNetDummyMgr1 netMgr1;
|
|
|
|
NxsNetDummyMgr2 netMgr2;
|
|
|
|
|
2012-07-05 21:26:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // NXSTESTHUB_H
|