2014-04-13 08:21:51 -04:00
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
// from librssimulator
|
|
|
|
|
|
|
|
// from libretroshare
|
|
|
|
#include "serialiser/rsnxsitems.h"
|
|
|
|
|
|
|
|
// local
|
|
|
|
#include "GxsPairServiceTester.h"
|
2014-04-27 09:26:14 -04:00
|
|
|
#include "GxsPeerNode.h"
|
2014-04-13 08:21:51 -04:00
|
|
|
#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.
|
|
|
|
*/
|
|
|
|
|
2014-04-27 09:26:14 -04:00
|
|
|
//TEST(libretroshare_services, GxsNxsPairExchange1)
|
|
|
|
TEST(libretroshare_services, DISABLED_GxsNxsPairExchange1)
|
2014-04-13 08:21:51 -04:00
|
|
|
{
|
|
|
|
RsPeerId p1 = RsPeerId::random();
|
|
|
|
RsPeerId p2 = RsPeerId::random();
|
|
|
|
int testMode = 0;
|
|
|
|
|
2014-04-27 09:26:14 -04:00
|
|
|
GxsPairServiceTester tester(p1, p2, testMode, false);
|
|
|
|
GxsPeerNode *peerNode1 = tester.getGxsPeerNode(p1);
|
|
|
|
GxsPeerNode *peerNode2 = tester.getGxsPeerNode(p2);
|
2014-04-13 08:21:51 -04:00
|
|
|
|
|
|
|
// 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);
|
|
|
|
{
|
2016-03-26 17:25:15 -04:00
|
|
|
RsNxsSyncGrpItem *syncGrp = new RsNxsSyncGrpItem(RS_SERVICE_GXS_TYPE_TEST);
|
2014-04-13 08:21:51 -04:00
|
|
|
dropFilter.setUseFullTypes(true);
|
|
|
|
dropFilter.addFullType(syncGrp->PacketId());
|
|
|
|
}
|
|
|
|
|
|
|
|
// these are currently slow operations.
|
2014-04-27 09:26:14 -04:00
|
|
|
|
|
|
|
RsGxsGroupId p2GroupId1, p2GroupId2;
|
|
|
|
RsGxsCircleId nullCircleId;
|
|
|
|
RsGxsId nullAuthorId;
|
|
|
|
EXPECT_TRUE(peerNode2->createGroup("group1", GXS_CIRCLE_TYPE_PUBLIC, nullCircleId, nullAuthorId, p2GroupId1));
|
|
|
|
EXPECT_TRUE(peerNode2->createGroup("group2", GXS_CIRCLE_TYPE_PUBLIC, nullCircleId, nullAuthorId, p2GroupId2));
|
|
|
|
std::cerr << "p2->group1 id: " << p2GroupId1;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
std::cerr << "p2->group2 id: " << p2GroupId2;
|
|
|
|
std::cerr << std::endl;
|
2014-04-13 08:21:51 -04:00
|
|
|
|
|
|
|
int counter = 0;
|
2014-04-27 09:26:14 -04:00
|
|
|
while((counter < 30))
|
2014-04-13 08:21:51 -04:00
|
|
|
{
|
|
|
|
counter++;
|
|
|
|
tester.tick();
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
|
2014-04-27 09:26:14 -04:00
|
|
|
std::list<RsGxsGroupId> p1GroupList;
|
|
|
|
std::list<RsGxsGroupId> p2GroupList;
|
|
|
|
EXPECT_TRUE(peerNode1->getGroupList(p1GroupList));
|
|
|
|
EXPECT_TRUE(peerNode2->getGroupList(p2GroupList));
|
|
|
|
EXPECT_TRUE(p1GroupList.size() == 2);
|
|
|
|
EXPECT_TRUE(p2GroupList.size() == 2);
|
|
|
|
EXPECT_TRUE(p1GroupList.end() != std::find(p1GroupList.begin(), p1GroupList.end(), p2GroupId1));
|
|
|
|
EXPECT_TRUE(p1GroupList.end() != std::find(p1GroupList.begin(), p1GroupList.end(), p2GroupId2));
|
|
|
|
EXPECT_TRUE(p2GroupList.end() != std::find(p2GroupList.begin(), p2GroupList.end(), p2GroupId1));
|
|
|
|
EXPECT_TRUE(p2GroupList.end() != std::find(p2GroupList.begin(), p2GroupList.end(), p2GroupId2));
|
|
|
|
|
|
|
|
std::vector<RsTestGroup> p1Groups;
|
|
|
|
std::vector<RsTestGroup> p2Groups;
|
|
|
|
EXPECT_TRUE(peerNode1->getGroups(p1Groups));
|
|
|
|
EXPECT_TRUE(peerNode2->getGroups(p2Groups));
|
|
|
|
EXPECT_TRUE(p1Groups.size() == 2);
|
|
|
|
EXPECT_TRUE(p2Groups.size() == 2);
|
|
|
|
|
|
|
|
tester.PrintCapturedPackets();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
* Test 2 includes ID & Circle Services.
|
|
|
|
**/
|
|
|
|
|
|
|
|
TEST(libretroshare_services, DISABLED_GxsNxsPairExchange2)
|
|
|
|
//TEST(libretroshare_services, GxsNxsPairExchange2)
|
|
|
|
{
|
|
|
|
RsPeerId p1 = RsPeerId::random();
|
|
|
|
RsPeerId p2 = RsPeerId::random();
|
|
|
|
int testMode = 0;
|
|
|
|
|
|
|
|
GxsPairServiceTester tester(p1, p2, testMode, true);
|
|
|
|
GxsPeerNode *peerNode1 = tester.getGxsPeerNode(p1);
|
|
|
|
GxsPeerNode *peerNode2 = tester.getGxsPeerNode(p2);
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
{
|
2016-03-26 17:25:15 -04:00
|
|
|
RsNxsSyncGrpItem *syncGrp = new RsNxsSyncGrpItem(RS_SERVICE_GXS_TYPE_TEST);
|
2014-04-27 09:26:14 -04:00
|
|
|
dropFilter.setUseFullTypes(true);
|
|
|
|
dropFilter.addFullType(syncGrp->PacketId());
|
|
|
|
}
|
|
|
|
|
|
|
|
// these are currently slow operations.
|
|
|
|
RsGxsGroupId p2GroupId1, p2GroupId2;
|
|
|
|
RsGxsCircleId nullCircleId;
|
|
|
|
RsGxsId nullAuthorId;
|
|
|
|
EXPECT_TRUE(peerNode2->createGroup("group1", GXS_CIRCLE_TYPE_PUBLIC, nullCircleId, nullAuthorId, p2GroupId1));
|
|
|
|
EXPECT_TRUE(peerNode2->createGroup("group2", GXS_CIRCLE_TYPE_PUBLIC, nullCircleId, nullAuthorId, p2GroupId2));
|
|
|
|
std::cerr << "p2->group1 id: " << p2GroupId1;
|
2014-04-13 08:21:51 -04:00
|
|
|
std::cerr << std::endl;
|
2014-04-27 09:26:14 -04:00
|
|
|
std::cerr << "p2->group2 id: " << p2GroupId2;
|
2014-04-13 08:21:51 -04:00
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2014-04-27 09:26:14 -04:00
|
|
|
|
|
|
|
int counter = 0;
|
|
|
|
while((counter < 60))
|
2014-04-13 08:21:51 -04:00
|
|
|
{
|
2014-04-27 09:26:14 -04:00
|
|
|
counter++;
|
|
|
|
tester.tick();
|
|
|
|
sleep(1);
|
2014-04-13 08:21:51 -04:00
|
|
|
}
|
|
|
|
|
2014-04-27 09:26:14 -04:00
|
|
|
std::list<RsGxsGroupId> p1GroupList;
|
|
|
|
std::list<RsGxsGroupId> p2GroupList;
|
|
|
|
EXPECT_TRUE(peerNode1->getGroupList(p1GroupList));
|
|
|
|
EXPECT_TRUE(peerNode2->getGroupList(p2GroupList));
|
|
|
|
EXPECT_TRUE(p1GroupList.size() == 2);
|
|
|
|
EXPECT_TRUE(p2GroupList.size() == 2);
|
|
|
|
EXPECT_TRUE(p1GroupList.end() != std::find(p1GroupList.begin(), p1GroupList.end(), p2GroupId1));
|
|
|
|
EXPECT_TRUE(p1GroupList.end() != std::find(p1GroupList.begin(), p1GroupList.end(), p2GroupId2));
|
|
|
|
EXPECT_TRUE(p2GroupList.end() != std::find(p2GroupList.begin(), p2GroupList.end(), p2GroupId1));
|
|
|
|
EXPECT_TRUE(p2GroupList.end() != std::find(p2GroupList.begin(), p2GroupList.end(), p2GroupId2));
|
|
|
|
|
|
|
|
tester.PrintCapturedPackets();
|
|
|
|
}
|
2014-04-13 08:21:51 -04:00
|
|
|
|