int test(int argc, char* const* argv, el::Level ll, std::vector<std::string> const& metrics) { gTestMetrics = metrics; Config const& cfg = getTestConfig(); Logging::setLoggingToFile(cfg.LOG_FILE_PATH); Logging::setLogLevel(ll, nullptr); LOG(INFO) << "Testing stellar-core " << STELLAR_CORE_VERSION; LOG(INFO) << "Logging to " << cfg.LOG_FILE_PATH; return Catch::Session().run(argc, argv); }
SCPEnvelope makeEnvelope(int slotIndex) { auto result = SCPEnvelope{}; result.statement.slotIndex = slotIndex; result.statement.pledges.type(SCP_ST_CONFIRM); result.statement.pledges.confirm().nPrepared = slotIndex; return result; } } TEST_CASE("Tracker works", "[overlay][Tracker]") { VirtualClock clock; auto const& cfg = getTestConfig(); auto app = Application::create(clock, cfg); auto hash = sha256(ByteSlice{"hash"}); auto nullAskPeer = AskPeer{[](Peer::pointer, Hash) {}}; SECTION("empty tracker") { Tracker t{*app, hash, nullAskPeer}; REQUIRE(t.size() == 0); REQUIRE(t.empty()); REQUIRE(t.getLastSeenSlotIndex() == 0); } SECTION("can listen on envelope") {
#include "TCPPeer.h" #include "lib/catch.hpp" #include "main/Application.h" #include "main/test.h" #include "overlay/PeerDoor.h" #include "main/Config.h" #include "util/Logging.h" #include "simulation/Simulation.h" #include "overlay/OverlayManager.h" namespace stellar { TEST_CASE("TCPPeer can communicate", "[overlay]") { Hash networkID = sha256(getTestConfig().NETWORK_PASSPHRASE); Simulation::pointer s = std::make_shared<Simulation>(Simulation::OVER_TCP, networkID); auto v10SecretKey = SecretKey::fromSeed(sha256("v10")); auto v11SecretKey = SecretKey::fromSeed(sha256("v11")); SCPQuorumSet n0_qset; n0_qset.threshold = 1; n0_qset.validators.push_back(v10SecretKey.getPublicKey()); auto n0 = s->getNode(s->addNode(v10SecretKey, n0_qset, s->getClock())); SCPQuorumSet n1_qset; n1_qset.threshold = 1; n1_qset.validators.push_back(v11SecretKey.getPublicKey()); auto n1 = s->getNode(s->addNode(v11SecretKey, n1_qset, s->getClock()));