diff --git a/libretroshare/src/tests/gxs/genexchangetester.cpp b/libretroshare/src/tests/gxs/genexchangetester.cpp index dfc057de4..4434a4ab8 100644 --- a/libretroshare/src/tests/gxs/genexchangetester.cpp +++ b/libretroshare/src/tests/gxs/genexchangetester.cpp @@ -391,6 +391,8 @@ bool GenExchangeTester::testGrpMetaModRequest() bool ok = true; std::string newServiceString; + uint32_t newGrpStatus = randNum(); + uint32_t newSubscribeGrpFlag = randNum(); randString(SHORT_STR, newServiceString); // mod service flag for first grp @@ -398,6 +400,14 @@ bool GenExchangeTester::testGrpMetaModRequest() pollForToken(token, opts); ok = mTestService->acknowledgeTokenGrp(token, grpId); + mTestService->setGroupStatusFlagTS(token, grpIds[0], newGrpStatus); + pollForToken(token, opts); + ok = mTestService->acknowledgeTokenGrp(token, grpId); + + mTestService->setGroupSubscribeFlagTS(token, grpIds[0], newSubscribeGrpFlag); + pollForToken(token, opts); + ok = mTestService->acknowledgeTokenGrp(token, grpId); + std::list reqGrpIds; reqGrpIds.push_back(grpIds[0]); opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; @@ -416,6 +426,13 @@ bool GenExchangeTester::testGrpMetaModRequest() if(meta.mServiceString != newServiceString) ok = false; + if(meta.mSubscribeFlags != newSubscribeGrpFlag) + ok = false; + + if(meta.mGroupStatus != newGrpStatus) + ok = false; + + } breakDown(); @@ -425,8 +442,6 @@ bool GenExchangeTester::testGrpMetaModRequest() void GenExchangeTester::setUpLargeGrps(uint32_t nGrps) { - - for(int i=0; i < nGrps; i++) { RsDummyGrp* dgrp = new RsDummyGrp(); @@ -442,6 +457,97 @@ void GenExchangeTester::setUpLargeGrps(uint32_t nGrps) } } +bool GenExchangeTester::testMsgMetaModRequest() +{ + setUp(); + setUpGrps(); + + RsDummyMsg* msg = new RsDummyMsg(); + init(msg); + + msg->meta.mGroupId = mRandGrpIds[(rand()%3)]; + uint32_t token; + RsDummyMsg* msgOut = new RsDummyMsg(); + *msgOut = *msg; + mTestService->publishDummyMsg(token, msg); + + // poll will block until found + RsTokReqOptionsV2 opts; + opts.mReqType = 4200; + pollForToken(token, opts); + RsGxsGrpMsgIdPair msgId; + + mTestService->acknowledgeTokenMsg(token, msgId); + + if(msgId.first.empty() || msgId.second.empty()){ + breakDown(); + return false; + } + + std::string newServiceString; + randString(SHORT_STR, newServiceString); + + // first modify service string + mTestService->setMsgServiceStringTS(token, msgId, newServiceString); + pollForToken(token, opts); + + mTestService->acknowledgeTokenMsg(token, msgId); + + uint32_t newStatus = 2; + // first modify service string + mTestService->setMsgStatusFlagTS(token, msgId, newStatus); + pollForToken(token, opts); + + mTestService->acknowledgeTokenMsg(token, msgId); + + // now request msg + GxsMsgReq req; + std::vector msgV; + msgV.push_back(msgId.second); + req.insert(std::make_pair(msgId.first, msgV)); + + opts.mReqType = GXS_REQUEST_TYPE_MSG_META; + mTokenService->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, req); + + // poll again + pollForToken(token, opts); + + bool ok = true; + + if(mMsgMetaDataIn.empty()) + ok = false; + + if(ok){ + + GxsMsgMetaMap::iterator mit = mMsgMetaDataIn.begin(); + std::vector& metaV = mit->second; + + RsMsgMetaData meta; + if(metaV.empty()){ + ok = false; + }else{ + meta = *(metaV.begin()); + } + + + if(meta.mServiceString != newServiceString) + ok &= false; + + if(meta.mMsgStatus != newStatus) + ok &= false; + + + } + + /********************/ + + // complete + breakDown(); + + return ok; + +} + bool GenExchangeTester::testMsgSubmissionRetrieval() { diff --git a/libretroshare/src/tests/gxs/rsgenexchange_test.cc b/libretroshare/src/tests/gxs/rsgenexchange_test.cc index 68b2baff5..4ae8adb3c 100644 --- a/libretroshare/src/tests/gxs/rsgenexchange_test.cc +++ b/libretroshare/src/tests/gxs/rsgenexchange_test.cc @@ -20,6 +20,7 @@ int main() CHECK(tester.testRelatedMsgIdRetrieval_Parents()); REPORT("tester.testRelatedMsgIdRetrieval_Parents()"); CHECK(tester.testRelatedMsgIdRetrieval_OrigMsgId()); REPORT("tester.testRelatedMsgIdRetrieval_OrigMsgId()"); CHECK(tester.testRelatedMsgIdRetrieval_Latest()); REPORT("tester.testRelatedMsgIdRetrieval_Latest()"); + CHECK(tester.testMsgMetaModRequest()); REPORT("tester.testMsgMetaModRequest()"); CHECK(tester.testGrpSubmissionRetrieval()); REPORT("tester.testGrpSubmissionRetrieval()"); CHECK(tester.testGrpMetaRetrieval()); REPORT("tester.testGrpMetaRetrieval()");