Browse Source

Tests: PityTest - HACK for transport peers problem

master
heck 4 years ago
parent
commit
7b8116162d
  1. 10
      src/PityTransport.cc
  2. 3
      src/PityUnit.hh
  3. 3
      src/PityUnit.hxx

10
src/PityTransport.cc

@ -1,4 +1,5 @@
#include "PityTransport.hh" #include "PityTransport.hh"
#include "PityUnit.hh"
#include "iostream" #include "iostream"
#include "../../../src/std_utils.hh" #include "../../../src/std_utils.hh"
#include <random> #include <random>
@ -6,6 +7,7 @@
#include <memory> #include <memory>
#include <unordered_map> #include <unordered_map>
namespace pEp { namespace pEp {
namespace PityTest11 { namespace PityTest11 {
bool PityTransport::debug_log_enabled = false; bool PityTransport::debug_log_enabled = false;
@ -18,12 +20,16 @@ namespace pEp {
void PityTransport::sendMsg(const std::string nodename, const std::string& msg) const void PityTransport::sendMsg(const std::string nodename, const std::string& msg) const
{ {
pEpLogClass("Address: " + nodename + " msg: " + msg); pEpLogClass("Address: " + nodename + " msg: " + msg);
// HACK TODO
std::string nodename_normalize = PityUnit<>::_normalizeName(nodename);
bool found = false; bool found = false;
std::string dir; std::string dir;
try { try {
dir = _endpoints.at(nodename); dir = _endpoints.at(nodename_normalize);
} catch (std::out_of_range&) { } catch (std::out_of_range&) {
throw std::runtime_error("no such nodename: " + nodename); throw std::runtime_error("no such nodename: " + nodename_normalize);
} }
Utils::dir_ensure(dir); Utils::dir_ensure(dir);
std::stringstream filename; std::stringstream filename;

3
src/PityUnit.hh

@ -63,6 +63,7 @@ namespace pEp {
// Util // Util
void recreateDirsRecursively(); void recreateDirsRecursively();
static std::string _normalizeName(std::string name); //TODO HACK in PityTransport this should be private
//Transport //Transport
PityTransport* transport() const; PityTransport* transport() const;
@ -102,9 +103,7 @@ namespace pEp {
std::string _rootUnitDir(); std::string _rootUnitDir();
// Util // Util
std::string _normalizeName(std::string name) const;
std::string _status_string(const std::string& msg) const; std::string _status_string(const std::string& msg) const;
Utils::Color _colForProcUnitNr(int procUnitNr) const; Utils::Color _colForProcUnitNr(int procUnitNr) const;
Utils::Color _termColor() const; Utils::Color _termColor() const;

3
src/PityUnit.hxx

@ -478,8 +478,9 @@ namespace pEp {
} }
// name is alphanumeric only (everything else will be replaced by an underscore) // name is alphanumeric only (everything else will be replaced by an underscore)
// static
template<class TestContext> template<class TestContext>
std::string PityUnit<TestContext>::_normalizeName(std::string name) const std::string PityUnit<TestContext>::_normalizeName(std::string name)
{ {
replace_if( replace_if(
name.begin(), name.begin(),

Loading…
Cancel
Save