Browse Source

Tests: PityTest - HACK for transport peers problem

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

10
src/PityTransport.cc

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

5
src/PityUnit.hh

@ -63,6 +63,7 @@ namespace pEp {
// Util
void recreateDirsRecursively();
static std::string _normalizeName(std::string name); //TODO HACK in PityTransport this should be private
//Transport
PityTransport* transport() const;
@ -102,9 +103,7 @@ namespace pEp {
std::string _rootUnitDir();
// Util
std::string _normalizeName(std::string name) const;
std::string _status_string(const std::string& msg) const;
Utils::Color _colForProcUnitNr(int procUnitNr) const;
Utils::Color _termColor() const;
@ -113,7 +112,7 @@ namespace pEp {
// Fields
const std::string _name;
PityUnit<TestContext>* _parent; //nullptr if RootUnit
TestContext* _perspective; //nullptr if inherited
TestContext* _perspective; //nullptr if inherited
TestFunction _test_func;
ExecutionMode _exec_mode;
static std::string _global_root_dir;

3
src/PityUnit.hxx

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

Loading…
Cancel
Save