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 <fstream>
#include <memory>
#include <map>
#include <unordered_map>
namespace pEp {
namespace PityTest11 {
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 }
{
}

6
src/PityTransport.hh

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

6
src/PityUnit.hh

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

4
src/PityUnit.hxx

@ -14,7 +14,7 @@
#include <sstream>
#include <exception>
#include <memory>
#include <memory>
#include <unordered_map>
//using namespace pEp::Adapter::pEpLog;
@ -475,7 +475,7 @@ namespace pEp {
void PityUnit<T, P>::createTransport()
{
registerAsTransportEndpoint();
_transport = std::shared_ptr<PityTransport>(transportDir(), transportEndpoints());
_transport = std::make_shared<PityTransport>(transportDir(), transportEndpoints());
}
// 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);
Utils::sleep_millis(throttle);
}
//
// while (model->hasMsg()) {
// unit.log("MSG RX:" + model->receiveMsg());
// Utils::sleep_millis(throttle);
// }
// }
while (unit.transport()->hasMsg()) {
unit.log("MSG RX:" + unit.transport()->receiveMsg());
Utils::sleep_millis(throttle);
}
}
}
int main(int argc, char* argv[])
@ -35,6 +35,7 @@ int main(int argc, char* argv[])
// debug log per class
PityModel::debug_log_enabled = false;
PityNode::debug_log_enabled = false;
PityTransport::debug_log_enabled = false;
PityUnit<>::debug_log_enabled = false;
// Create model with 3 nodes

Loading…
Cancel
Save