Ejemplo n.º 1
0
#include "main/Application.h"
#include "xdrpp/autocheck.h"
#include "main/test.h"
#include "lib/catch.hpp"
#include "util/Logging.h"
#include "util/Timer.h"
#include <future>
#include "process/ProcessManager.h"

using namespace stellar;

TEST_CASE("subprocess", "[process]")
{
    VirtualClock clock;
    Config const& cfg = getTestConfig();
    Application::pointer app = Application::create(clock, cfg);
    auto evt = app->getProcessManager().runProcess("hostname");
    bool exited = false;
    bool failed = false;
    evt.async_wait([&](asio::error_code ec)
                   {
                       CLOG(DEBUG, "Process") << "process exited: " << ec;
                       if (ec)
                       {
                           CLOG(DEBUG, "Process")
                               << "error code: " << ec.message();
                       }
                       failed = !!ec;
                       exited = true;
                   });
Ejemplo n.º 2
0
        return le;
    },
    autocheck::generator<LedgerEntry>());

LedgerEntry
generateValidLedgerEntry()
{
    return validLedgerEntryGenerator(10);
}

TEST_CASE("Ledger entry db lifecycle", "[ledger]")
{
    Config cfg(getTestConfig());
    VirtualClock clock;
    Application::pointer app = Application::create(clock, cfg);

    app->start();
    LedgerDelta delta(app->getLedgerManager().getCurrentLedgerHeader(),
                      app->getDatabase());
    auto& db = app->getDatabase();
    for (size_t i = 0; i < 100; ++i)
    {
        auto le = EntryFrame::FromXDR(validLedgerEntryGenerator(3));
        CHECK(!EntryFrame::exists(db, le->getKey()));
        le->storeAddOrChange(delta, db);
        CHECK(EntryFrame::exists(db, le->getKey()));
        le->storeDelete(delta, db);
        CHECK(!EntryFrame::exists(db, le->getKey()));
    }
}
Ejemplo n.º 3
0
#include "test/test.h"
#include "util/Fs.h"
#include "util/Logging.h"
#include "util/Timer.h"
#include "xdrpp/autocheck.h"
#include <chrono>
#include <future>
#include <thread>

using namespace stellar;

TEST_CASE("subprocess", "[process]")
{
    VirtualClock clock;
    Config const& cfg = getTestConfig();
    Application::pointer app = createTestApplication(clock, cfg);
    bool exited = false;
    bool failed = false;
    auto evt = app->getProcessManager().runProcess("hostname", "").lock();
    REQUIRE(evt);
    evt->async_wait([&](asio::error_code ec) {
        CLOG(DEBUG, "Process") << "process exited: " << ec;
        if (ec)
        {
            CLOG(DEBUG, "Process") << "error code: " << ec.message();
        }
        failed = !!ec;
        exited = true;
    });

    while (!exited && !clock.getIOContext().stopped())
Ejemplo n.º 4
0
        evt.async_wait(callComplete());
        mDidRun = true;
    }

    bool
    didRun() const
    {
        return mDidRun;
    }
};

TEST_CASE("work manager", "[work]")
{
    VirtualClock clock;
    Config const& cfg = getTestConfig();
    Application::pointer appPtr = createTestApplication(clock, cfg);
    auto& wm = appPtr->getWorkManager();

    auto w = wm.addWork<CallCmdWork>("hostname");
    w->addWork<CallCmdWork>("date");
    w->addWork<CallCmdWork>("uname");
    wm.advanceChildren();
    while (!wm.allChildrenSuccessful())
    {
        clock.crank();
    }
}

TEST_CASE("work propagates process failure", "[work]")
{
    VirtualClock clock;
#include "herder/HerderImpl.h"
#include "lib/catch.hpp"
#include "main/Application.h"
#include "test/TestAccount.h"
#include "test/TxTests.h"
#include "test/test.h"
#include "xdrpp/marshal.h"

using namespace stellar;
using namespace stellar::txtest;

TEST_CASE("PendingEnvelopes::recvSCPEnvelope", "[herder]")
{
    Config cfg(getTestConfig());
    VirtualClock clock;
    Application::pointer app = Application::create(clock, cfg);

    auto const& networkID = app->getNetworkID();
    auto const& lcl = app->getLedgerManager().getLastClosedLedgerHeader();

    auto root = TestAccount::createRoot(*app);
    auto a1 = getAccount("A");
    using TxPair = std::pair<Value, TxSetFramePtr>;
    auto makeTxPair = [](TxSetFramePtr txSet, uint64_t closeTime) {
        txSet->sortForHash();
        auto sv = StellarValue{txSet->getContentsHash(), closeTime,
                               emptyUpgradeSteps, 0};
        auto v = xdr::xdr_to_opaque(sv);

        return TxPair{v, txSet};
    };
Ejemplo n.º 6
0
#include "xdrpp/marshal.h"
#include <memory>
#include <unordered_map>
#include <utility>

using namespace stellar;

namespace LedgerEntryTests
{

TEST_CASE("Ledger Entry tests", "[ledgerentry]")
{
    Config cfg(getTestConfig(0));

    VirtualClock clock;
    Application::pointer app = createTestApplication(clock, cfg);
    app->start();
    Database& db = app->getDatabase();

    SECTION("round trip with database")
    {
        std::vector<LedgerEntry> accounts(50);

        std::unordered_map<AccountID, LedgerEntry> accountsMap;

        for (auto& l : accounts)
        {
            l.data.type(ACCOUNT);
            auto& a = l.data.account();
            a = LedgerTestUtils::generateValidAccountEntry(5);
            accountsMap.insert(std::make_pair(a.accountID, l));