Browse Source

Tests: PityTest - fixes

master
heck 4 years ago
parent
commit
686815f309
  1. 4
      src/PityTransport.cc
  2. 6
      src/PityTransport.hh
  3. 6
      src/PityUnit.hh
  4. 4
      src/PityUnit.hxx
  5. 13
      test/test_redesign.cc

4
src/PityTransport.cc

@ -4,13 +4,13 @@
#include <random> #include <random>
#include <fstream> #include <fstream>
#include <memory> #include <memory>
#include <map> #include <unordered_map>
namespace pEp { namespace pEp {
namespace PityTest11 { namespace PityTest11 {
bool PityTransport::debug_log_enabled = false; bool PityTransport::debug_log_enabled = false;
PityTransport::PityTransport(const std::string& inboxDir, Endpoints& endpoints) : PityTransport::PityTransport(std::string inboxDir, Endpoints& endpoints) :
_inboxDir{ inboxDir }, _endpoints{ endpoints } _inboxDir{ inboxDir }, _endpoints{ endpoints }
{ {
} }

6
src/PityTransport.hh

@ -12,13 +12,13 @@
namespace pEp { namespace pEp {
namespace PityTest11 { namespace PityTest11 {
// Address - Dir // Address - Dir
using Endpoints = std::unordered_map<std::string, std::string>; using Endpoints = std::unordered_map<std::string, std::string>;
class PityTransport { class PityTransport {
public: public:
// Constructors // Constructors
PityTransport() = delete; PityTransport() = delete;
PityTransport(const std::string& inboxDir, Endpoints& endpoints); explicit PityTransport(std::string inboxDir, Endpoints& endpoints);
// Getters // Getters
//Transport //Transport
@ -29,7 +29,7 @@ namespace pEp {
//internal logging //internal logging
static bool debug_log_enabled; static bool debug_log_enabled;
Adapter::pEpLog::pEpLogger logger_debug{ "PityModel", debug_log_enabled }; Adapter::pEpLog::pEpLogger logger_debug{ "PityTransport", debug_log_enabled };
private: private:
std::string _inboxDir; std::string _inboxDir;

6
src/PityUnit.hh

@ -6,12 +6,12 @@
#include "../../../src/pEpLog.hh" #include "../../../src/pEpLog.hh"
#include "../../../src/std_utils.hh" #include "../../../src/std_utils.hh"
#include "fs_mutex.hh"
#include "PityTransport.hh"
#include <string> #include <string>
#include <map> #include <map>
#include <memory> #include <memory>
#include "fs_mutex.hh" #include <unordered_map>
#include "PityTransport.hh"
//#include "PityModel.hh"
// Yes, the mem mgmt is purely static on purpose (so far) // Yes, the mem mgmt is purely static on purpose (so far)

4
src/PityUnit.hxx

@ -14,7 +14,7 @@
#include <sstream> #include <sstream>
#include <exception> #include <exception>
#include <memory> #include <memory>
#include <memory> #include <unordered_map>
//using namespace pEp::Adapter::pEpLog; //using namespace pEp::Adapter::pEpLog;
@ -475,7 +475,7 @@ namespace pEp {
void PityUnit<T, P>::createTransport() void PityUnit<T, P>::createTransport()
{ {
registerAsTransportEndpoint(); registerAsTransportEndpoint();
_transport = std::shared_ptr<PityTransport>(transportDir(), transportEndpoints()); _transport = std::make_shared<PityTransport>(transportDir(), transportEndpoints());
} }
// Inherited (if null see parent recursively) // Inherited (if null see parent recursively)

13
test/test_redesign.cc

@ -22,12 +22,12 @@ void test_node1(PityUnit<PityModel>& unit,PityModel* model, PityPerspective* psp
unit.transport()->sendMsg(peer.first,msg); unit.transport()->sendMsg(peer.first,msg);
Utils::sleep_millis(throttle); Utils::sleep_millis(throttle);
} }
//
// while (model->hasMsg()) { while (unit.transport()->hasMsg()) {
// unit.log("MSG RX:" + model->receiveMsg()); unit.log("MSG RX:" + unit.transport()->receiveMsg());
// Utils::sleep_millis(throttle); Utils::sleep_millis(throttle);
// } }
// } }
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
@ -35,6 +35,7 @@ int main(int argc, char* argv[])
// debug log per class // debug log per class
PityModel::debug_log_enabled = false; PityModel::debug_log_enabled = false;
PityNode::debug_log_enabled = false; PityNode::debug_log_enabled = false;
PityTransport::debug_log_enabled = false;
PityUnit<>::debug_log_enabled = false; PityUnit<>::debug_log_enabled = false;
// Create model with 3 nodes // Create model with 3 nodes

Loading…
Cancel
Save