From b9f99d95687f0ccd7879d6249bafbdf0c6be767d Mon Sep 17 00:00:00 2001 From: heck Date: Thu, 10 Jun 2021 21:46:40 +0200 Subject: [PATCH] Tests: PityTest - remove prototype tests --- test/test_model.cc | 37 -------------------------- test/test_redesign.cc | 51 ------------------------------------ test/test_transport.cc | 59 ------------------------------------------ 3 files changed, 147 deletions(-) delete mode 100644 test/test_model.cc delete mode 100644 test/test_redesign.cc delete mode 100644 test/test_transport.cc diff --git a/test/test_model.cc b/test/test_model.cc deleted file mode 100644 index f886bb4..0000000 --- a/test/test_model.cc +++ /dev/null @@ -1,37 +0,0 @@ -#include "../src/PityUnit.hh" -#include "../src/PityModel.hh" - -using namespace std; -using namespace pEp::Adapter; -using namespace pEp::PityTest11; - - -void test_node1(const PityUnit& unit) -{ - unit.log(unit.getModel()->getName()); - unit.log(unit.getModel()->own_node->to_string()); - unit.getModel()->sendMsg("node_2@peptest.org", "Fdsfs"); - - while(true) { - unit.log("MSG RX:" + unit.getModel()->receiveMsg()); - } -} - - -int main(int argc, char* argv[]) -{ - PityModel::debug_log_enabled = false; - PityNode::debug_log_enabled = false; - PityModel model{ "test_model", 3 }; - - for (auto n : model.getNodes()) { - pEpLog::log(n->getName()); - } - - PityUnit node1_test1 = PityUnit{ model.getNodeUnit(0), "test1", &test_node1 }; - PityUnit node2_test1 = PityUnit{ model.getNodeUnit(1), "test2", &test_node1 }; - PityUnit node3_test1 = PityUnit{ model.getNodeUnit(2), "test3", &test_node1 }; - - model.rootUnit().run(); - // pEpLog::log(model.rootUnit().to_string()); -} \ No newline at end of file diff --git a/test/test_redesign.cc b/test/test_redesign.cc deleted file mode 100644 index 050e2aa..0000000 --- a/test/test_redesign.cc +++ /dev/null @@ -1,51 +0,0 @@ -#include "../src/PityUnit.hh" -#include "../src/PityModel.hh" -#include "../src/PitySwarm.hh" - -using namespace pEp; -using namespace pEp::Adapter; -using namespace pEp::PityTest11; - -void test_node1(PityUnit& unit,PityModel* model, PityPerspective* psp) -{ - unit.log("ModelName:" + model->getName()); - unit.log("perspective name:" + psp->name); - unit.log("perspective partner:" + psp->partner); - unit.log("perspective peers:\n" + Utils::to_string(psp->peers)); - - std::string msg = "Message from: " + unit.getPathShort(); - int throttle = 1000; - while (true) { - Utils::sleep_millis(throttle); - for (auto peer : unit.transportEndpoints()) { - unit.log("sending to:" + peer.first); - unit.transport()->sendMsg(peer.first,msg); - 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[]) -{ - // 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 - PityModel model{ "test_redesign", 3 }; - - PitySwarm swarm{model}; - - swarm.addTestUnit(0,"test1",&test_node1); - swarm.addTestUnit(1,"test1",&test_node1); - swarm.addTestUnit(2,"test1",&test_node1); - - swarm.run(); -} \ No newline at end of file diff --git a/test/test_transport.cc b/test/test_transport.cc deleted file mode 100644 index 790c7e5..0000000 --- a/test/test_transport.cc +++ /dev/null @@ -1,59 +0,0 @@ -#include "../src/PityUnit.hh" -#include "../src/PityModel.hh" -#include "../../../src/std_utils.hh" - -using namespace pEp; -using namespace pEp::Adapter; -using namespace pEp::PityTest11; - -void test_node1(const PityUnit& unit) -{ - unit.log("ModelName:" + unit.getModel()->getName()); - unit.log("own_node:" + unit.getModel()->own_node->getName()); - unit.log("partner:" + unit.getModel()->own_node->partner); - unit.log("peers:\n" + Utils::to_string(unit.getModel()->own_node->peers)); - - std::string msg = "Message from: " + unit.getPathShort(); - int throttle = 2000; - while (true) { - Utils::sleep_millis(throttle); - for (auto peer : unit.getModel()->own_node->peers) { - unit.log("sending to:" + peer); - unit.getModel()->sendMsg(peer, msg); - Utils::sleep_millis(throttle); - } - - while (unit.getModel()->hasMsg()) { - unit.log("MSG RX:" + unit.getModel()->receiveMsg()); - Utils::sleep_millis(throttle); - } - } -} - -int main(int argc, char* argv[]) -{ - // debug log per class - PityModel::debug_log_enabled = false; - PityNode::debug_log_enabled = false; - PityUnit<>::debug_log_enabled = false; - - // Create model with 3 nodes - PityModel model{ "test_transport", 3 }; - - // //Configure model - // model.nodeNr(0)->partner = model.nodeNr(1)->getName(); - // model.nodeNr(1)->partner = model.nodeNr(2)->getName(); - // model.nodeNr(2)->partner = model.nodeNr(0)->getName(); - - PityUnit node1_test1 = PityUnit{ model.unitOfNodeNr(0), - "test1", - &test_node1 }; - PityUnit node2_test1 = PityUnit{ model.unitOfNodeNr(1), - "test1", - &test_node1 }; - PityUnit node3_test1 = PityUnit{ model.unitOfNodeNr(2), - "test1", - &test_node1 }; - - model.run(); -} \ No newline at end of file