mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-03 11:54:30 -04:00
Added framework for testing a pair of GXS services.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7272 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
6be4a464a5
commit
23f6c405c8
6 changed files with 279 additions and 1 deletions
79
tests/unittests/libretroshare/services/gxs/nxspair_tests.cc
Normal file
79
tests/unittests/libretroshare/services/gxs/nxspair_tests.cc
Normal file
|
@ -0,0 +1,79 @@
|
|||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
// from librssimulator
|
||||
|
||||
// from libretroshare
|
||||
#include "serialiser/rsnxsitems.h"
|
||||
|
||||
// local
|
||||
#include "GxsPairServiceTester.h"
|
||||
#include "gxstestservice.h"
|
||||
|
||||
/* Here we want to test the most basic NXS interactions.
|
||||
* we have a GXS service, with no AuthorIDs or Circles.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test 1: nothing in Groups.... only sync packets.
|
||||
*
|
||||
* This test is rather slow - should speed it up.
|
||||
*/
|
||||
|
||||
TEST(libretroshare_services, GxsNxsPairExchange1)
|
||||
{
|
||||
RsPeerId p1 = RsPeerId::random();
|
||||
RsPeerId p2 = RsPeerId::random();
|
||||
int testMode = 0;
|
||||
|
||||
GxsPairServiceTester tester(p1, p2, testMode);
|
||||
|
||||
// we only care about the transaction going one way ...
|
||||
// so drop SyncGrp packets from p2 -> p1.
|
||||
|
||||
SetFilter &dropFilter = tester.getDropFilter();
|
||||
dropFilter.setFilterMode(SetFilter::FILTER_PARAMS);
|
||||
dropFilter.setUseSource(true);
|
||||
dropFilter.addSource(p2);
|
||||
{
|
||||
RsNxsSyncGrp *syncGrp = new RsNxsSyncGrp(RS_SERVICE_GXS_TYPE_TEST);
|
||||
dropFilter.setUseFullTypes(true);
|
||||
dropFilter.addFullType(syncGrp->PacketId());
|
||||
}
|
||||
|
||||
// these are currently slow operations.
|
||||
tester.createGroup(p2, "group1");
|
||||
tester.createGroup(p2, "group2");
|
||||
|
||||
int counter = 0;
|
||||
while((counter < 60))
|
||||
{
|
||||
counter++;
|
||||
tester.tick();
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
std::cerr << "==========================================================================================";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "#Packets: " << tester.getPacketCount();
|
||||
std::cerr << std::endl;
|
||||
|
||||
for(int i = 0; i < tester.getPacketCount(); i++)
|
||||
{
|
||||
SetPacket &pkt = tester.examinePacket(i);
|
||||
|
||||
std::cerr << "==========================================================================================";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "Time: " << pkt.mTime;
|
||||
std::cerr << " From: " << pkt.mSrcId.toStdString() << " To: " << pkt.mDestId.toStdString();
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "-----------------------------------------------------------------------------------------";
|
||||
std::cerr << std::endl;
|
||||
pkt.mItem->print(std::cerr);
|
||||
std::cerr << "==========================================================================================";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue