Browse Source

Test: test_swarm_tofu - Uniform initialization ONLY

pull/15/head
heck 2 years ago
parent
commit
2717c6570e
  1. 27
      test/test_swarm_tofu.cc

27
test/test_swarm_tofu.cc

@ -65,14 +65,13 @@ MinMsgRx tofu_receive(TestUnitSwarm &pity, TestContext *ctx)
void tofu_receiveAndReply(TestUnitSwarm &pity, TestContext *ctx) void tofu_receiveAndReply(TestUnitSwarm &pity, TestContext *ctx)
{ {
MinMsgRx rx_msg = tofu_receive(pity, ctx); MinMsgRx rx_msg{ tofu_receive(pity, ctx) };
std::string addr{ std::get<0>(rx_msg) }; std::string addr{ std::get<0>(rx_msg) };
std::string longmsg_orig{ std::get<1>(rx_msg) }; std::string longmsg_orig{ std::get<1>(rx_msg) };
pEpMessage msg = createMessage( pEpMessage msg{
ctx->own_ident, createMessage(ctx->own_ident, addr, "REPLY_FROM:'" + std::string(addr) + "' - " + longmsg_orig)
addr, };
"REPLY_FROM:'" + std::string(addr) + "' - " + longmsg_orig);
tofu_send(pity, ctx, addr, "REPLY_FROM:'" + std::string(addr) + "' - " + longmsg_orig); tofu_send(pity, ctx, addr, "REPLY_FROM:'" + std::string(addr) + "' - " + longmsg_orig);
} }
@ -86,7 +85,7 @@ int test_create_myself(TestUnitSwarm &pity, TestContext *ctx)
// Create new identity // Create new identity
pity.log("updating or creating identity for me"); pity.log("updating or creating identity for me");
ctx->own_ident = createOwnIdent(ctx->own_name); ctx->own_ident = createOwnIdent(ctx->own_name);
::PEP_STATUS status = ::myself(Adapter::session(), ctx->own_ident.get()); ::PEP_STATUS status {::myself(Adapter::session(), ctx->own_ident.get())};
pEp::throw_status(status); pEp::throw_status(status);
return 0; return 0;
} }
@ -113,21 +112,21 @@ int test_tofu_react(TestUnitSwarm &pity, TestContext *ctx)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// Adapter::pEpLog::set_enabled(true); // Adapter::pEpLog::set_enabled(true);
// Adapter::GroupDriverReplicator::log_enabled = true; // Adapter::GroupDriverReplicator::log_enabled {true};
// Adapter::GroupDriverEngine::log_enabled = true; // Adapter::GroupDriverEngine::log_enabled {true};
// Adapter::GroupDriverDummy::log_enabled = true; // Adapter::GroupDriverDummy::log_enabled {true};
// TestUnit::debug_log_enabled = false; // TestUnit::debug_log_enabled {false};
// PityTransport::debug_log_enabled = true; // PityTransport::debug_log_enabled {true};
int nodesCount = 23; int nodesCount{ 23 };
PityModel model{ "model_tofu2", nodesCount }; PityModel model{ "model_tofu2", nodesCount };
TestUnitSwarm suite = TestUnitSwarm{"suite_tofu2"}; TestUnitSwarm suite{ TestUnitSwarm{ "suite_tofu2" } };
PitySwarm swarm{ "swarm_tofu2", model }; PitySwarm swarm{ "swarm_tofu2", model };
suite.addRef(swarm.getSwarmUnit()); suite.addRef(swarm.getSwarmUnit());
// ------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------
swarm.addTestUnit(0, TestUnitSwarm{ "test_create_myself", test_create_myself }); swarm.addTestUnit(0, TestUnitSwarm{ "test_create_myself", test_create_myself });
swarm.addTestUnit(0, TestUnitSwarm{ "test_tofu_init_all_peers", test_tofu_init_all_peers }); swarm.addTestUnit(0, TestUnitSwarm{ "test_tofu_init_all_peers", test_tofu_init_all_peers });
for (int i = 1; i < nodesCount; i++) { for (int i{ 1 }; i < nodesCount; i++) {
swarm.addTestUnit(i, TestUnitSwarm{ "test_create_myself", test_create_myself }); swarm.addTestUnit(i, TestUnitSwarm{ "test_create_myself", test_create_myself });
swarm.addTestUnit(i, TestUnitSwarm{ "test_tofu_react", test_tofu_react }); swarm.addTestUnit(i, TestUnitSwarm{ "test_tofu_react", test_tofu_react });
} }

Loading…
Cancel
Save