Exemplo n.º 1
0
namespace stellar
{

TEST_CASE("TCPPeer can communicate", "[overlay]")
{
    Simulation::pointer s = std::make_shared<Simulation>(Simulation::OVER_TCP);

    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()));

    s->startAllNodes();

    auto b = TCPPeer::initiate(*n0, "127.0.0.1", n1->getConfig().PEER_PORT);

    s->crankForAtLeast(std::chrono::seconds(3), false);

    REQUIRE(n0->getOverlayManager()
                .getConnectedPeer("127.0.0.1", n1->getConfig().PEER_PORT)
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()));

    s->addPendingConnection(v10SecretKey.getPublicKey(),
                            v11SecretKey.getPublicKey());
    s->startAllNodes();
    s->crankForAtLeast(std::chrono::seconds(1), false);

    auto p0 = n0->getOverlayManager().getConnectedPeer(
                  "127.0.0.1", n1->getConfig().PEER_PORT);

    auto p1 = n1->getOverlayManager().getConnectedPeer(