Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/bucket/BucketList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ BucketListDepth::operator uint32_t() const
uint32_t
BucketList::levelSize(uint32_t level)
{
if (level >= kNumLevels) {
CLOG_ERROR(Bucket,"levelSize: level {} is out of range", level);
}
releaseAssert(level < kNumLevels);
return 1UL << (2 * (level + 1));
}
Expand Down
9 changes: 5 additions & 4 deletions src/bucket/test/BucketListTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ TEST_CASE_VERSIONS("network config snapshots BucketList size", "[bucketlist]")
{
VirtualClock clock;
Config cfg(getTestConfig(0, Config::TESTDB_IN_MEMORY_SQLITE));
cfg.DEPRECATED_SQL_LEDGER_STATE = true;
cfg.USE_CONFIG_FOR_GENESIS = true;

auto app = createTestApplication<BucketTestApplication>(clock, cfg);
Expand All @@ -696,7 +697,7 @@ TEST_CASE_VERSIONS("network config snapshots BucketList size", "[bucketlist]")

uint64_t correctAverage = sum / correctWindow.size();

LedgerTxn ltx(app->getLedgerTxnRoot(), false,
LedgerTxn ltx(app->getTestLedgerTxn(), false,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
REQUIRE(networkConfig.getAverageBucketListSize() == correctAverage);

Expand Down Expand Up @@ -772,7 +773,7 @@ TEST_CASE_VERSIONS("eviction scan", "[bucketlist]")
auto& bl = bm.getBucketList();

auto& networkCfg = [&]() -> SorobanNetworkConfig& {
LedgerTxn ltx(app->getLedgerTxnRoot());
LedgerTxn ltx(app->getTestLedgerTxn());
return app->getLedgerManager().getMutableSorobanNetworkConfig();
}();

Expand Down Expand Up @@ -817,7 +818,7 @@ TEST_CASE_VERSIONS("eviction scan", "[bucketlist]")

auto checkIfEntryExists = [&](std::set<LedgerKey> const& keys,
bool shouldExist) {
LedgerTxn ltx(app->getLedgerTxnRoot());
LedgerTxn ltx(app->getTestLedgerTxn());
for (auto const& key : keys)
{
auto txle = ltx.loadWithoutRecord(key);
Expand Down Expand Up @@ -1030,7 +1031,7 @@ TEST_CASE_VERSIONS("eviction scan", "[bucketlist]")
lm.setNextLedgerEntryBatchForBucketTesting({}, {ttlLe}, {});
closeLedger(*app);

LedgerTxn ltx(app->getLedgerTxnRoot());
LedgerTxn ltx(app->getTestLedgerTxn());
auto firstEntry = ltx.loadWithoutRecord(*entryToUpdate);
REQUIRE(static_cast<bool>(firstEntry));

Expand Down
4 changes: 2 additions & 2 deletions src/bucket/test/BucketTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,14 +942,14 @@ TEST_CASE_VERSIONS("bucket apply", "[bucket]")
CLOG_INFO(Bucket, "Applying bucket with {} live entries", live.size());
birth->apply(*app);
{
auto count = app->getLedgerTxnRoot().countObjects(ACCOUNT);
auto count = app->getTestLedgerTxn().countObjects(ACCOUNT);
REQUIRE(count == live.size() + 1 /* root account */);
}

CLOG_INFO(Bucket, "Applying bucket with {} dead entries", dead.size());
death->apply(*app);
{
auto count = app->getLedgerTxnRoot().countObjects(ACCOUNT);
auto count = app->getTestLedgerTxn().countObjects(ACCOUNT);
REQUIRE(count == 1 /* root account */);
}
});
Expand Down
3 changes: 3 additions & 0 deletions src/herder/HerderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,9 @@ HerderImpl::setUpgrades(Upgrades::UpgradeParameters const& upgrades)
std::string
HerderImpl::getUpgradesJson()
{
#ifdef BUILD_TESTS
mApp.resetTestLedgerTxn();
#endif
LedgerTxn ltx(mApp.getLedgerTxnRoot());
return mUpgrades.getParameters().toDebugJson(ltx);
}
Expand Down
6 changes: 6 additions & 0 deletions src/herder/TransactionQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ TransactionQueue::canAdd(TransactionFrameBasePtr tx,
}
}
}
#ifdef BUILD_TESTS
mApp.resetTestLedgerTxn();
#endif
LedgerTxn ltx(mApp.getLedgerTxnRoot(),
/* shouldUpdateLastModified */ true,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
Expand Down Expand Up @@ -1106,6 +1109,9 @@ SorobanTransactionQueue::broadcastSome()
size_t
SorobanTransactionQueue::getMaxQueueSizeOps() const
{
#ifdef BUILD_TESTS
mApp.resetTestLedgerTxn();
#endif
LedgerTxn ltx(mApp.getLedgerTxnRoot(),
/* shouldUpdateLastModified */ true,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
Expand Down
2 changes: 1 addition & 1 deletion src/herder/TxQueueLimiter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ TxQueueLimiter::canAddTx(TransactionFrameBasePtr const& newTx,
std::vector<std::pair<TxStackPtr, bool>>& txsToEvict)
{

LedgerTxn ltx(mApp.getLedgerTxnRoot(), /* shouldUpdateLastModified */ true,
LedgerTxn ltx(mApp.getTestLedgerTxn(), /* shouldUpdateLastModified */ true,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
return canAddTx(newTx, oldTx, txsToEvict,
ltx.loadHeader().current().ledgerVersion);
Expand Down
4 changes: 4 additions & 0 deletions src/herder/TxSetFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,11 @@ ApplicableTxSetFrame::checkValid(Application& app,
}

{
#ifdef BUILD_TESTS
// LedgerTxn ltx(app.getTestLedgerTxn());
#else
LedgerTxn ltx(app.getLedgerTxnRoot());
#endif
auto limits = app.getLedgerManager().maxLedgerResources(
/* isSoroban */ true);
if (anyGreater(*totalTxSetRes, limits))
Expand Down
5 changes: 5 additions & 0 deletions src/herder/TxSetUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ TxSetUtils::getInvalidTxList(TxSetTransactions const& txs, Application& app,
bool returnEarlyOnFirstInvalidTx)
{
ZoneScoped;
#ifdef BUILD_TESTS
//LedgerTxn ltx(app.getTestLedgerTxn(), /* shouldUpdateLastModified */ true,
// TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
app.resetTestLedgerTxn();
#endif
LedgerTxn ltx(app.getLedgerTxnRoot(), /* shouldUpdateLastModified */ true,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
if (protocolVersionStartsFrom(ltx.loadHeader().current().ledgerVersion,
Expand Down
23 changes: 12 additions & 11 deletions src/herder/test/HerderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ TEST_CASE_VERSIONS("standalone", "[herder][acceptance]")
{
bool hasC = false;
{
LedgerTxn ltx(app->getLedgerTxnRoot());
LedgerTxn ltx(app->getTestLedgerTxn());
hasC = protocolVersionStartsFrom(
ltx.loadHeader().current().ledgerVersion,
ProtocolVersion::V_10);
Expand Down Expand Up @@ -731,7 +731,7 @@ TEST_CASE_VERSIONS("txset with PreconditionsV2", "[herder][txset]")
SECTION("minSeqNum gap")
{
{
LedgerTxn ltx(app->getLedgerTxnRoot());
LedgerTxn ltx(app->getTestLedgerTxn());
if (ltx.loadHeader().current().ledgerVersion >=
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION))
{
Expand Down Expand Up @@ -766,7 +766,7 @@ TEST_CASE_VERSIONS("txset with PreconditionsV2", "[herder][txset]")
SECTION("minSeqLedgerGap")
{
{
LedgerTxn ltx(app->getLedgerTxnRoot());
LedgerTxn ltx(app->getTestLedgerTxn());
if (ltx.loadHeader().current().ledgerVersion >=
static_cast<uint32_t>(SOROBAN_PROTOCOL_VERSION))
{
Expand Down Expand Up @@ -1121,7 +1121,7 @@ TEST_CASE("txset base fee", "[herder][txset]")

LedgerHeader lhCopy;
{
LedgerTxn ltx(app->getLedgerTxnRoot());
LedgerTxn ltx(app->getTestLedgerTxn());
lhCopy = ltx.loadHeader().current();
}

Expand Down Expand Up @@ -1408,7 +1408,7 @@ surgeTest(uint32 protocolVersion, uint32_t nbTxs, uint32_t maxTxSetSize,

LedgerHeader lhCopy;
{
LedgerTxn ltx(app->getLedgerTxnRoot());
LedgerTxn ltx(app->getTestLedgerTxn());
lhCopy = ltx.loadHeader().current();
}

Expand Down Expand Up @@ -1966,7 +1966,7 @@ TEST_CASE("surge pricing with DEX separation", "[herder][txset]")

LedgerHeader lhCopy;
{
LedgerTxn ltx(app->getLedgerTxnRoot());
LedgerTxn ltx(app->getTestLedgerTxn());
lhCopy = ltx.loadHeader().current();
}

Expand Down Expand Up @@ -2155,7 +2155,7 @@ TEST_CASE("surge pricing with DEX separation holds invariants",

LedgerHeader lhCopy;
{
LedgerTxn ltx(app->getLedgerTxnRoot());
LedgerTxn ltx(app->getTestLedgerTxn());
lhCopy = ltx.loadHeader().current();
}

Expand Down Expand Up @@ -3526,7 +3526,7 @@ TEST_CASE("tx queue source account limit", "[herder][transactionqueue]")
// applied
REQUIRE(!node->getHerder().isBannedTx(tx2->getFullHash()));
// Only first account is in the ledger
LedgerTxn ltx(node->getLedgerTxnRoot());
LedgerTxn ltx(node->getTestLedgerTxn());
REQUIRE(stellar::loadAccount(ltx, a1.getPublicKey()));
REQUIRE(!stellar::loadAccount(ltx, b1.getPublicKey()));
}
Expand All @@ -3549,7 +3549,7 @@ TEST_CASE("tx queue source account limit", "[herder][transactionqueue]")
REQUIRE(node->getHerder().getTx(tx2->getFullHash()) == nullptr);
REQUIRE(node->getHerder().isBannedTx(tx2->getFullHash()));
// Both accounts are in the ledger
LedgerTxn ltx(node->getLedgerTxnRoot());
LedgerTxn ltx(node->getTestLedgerTxn());
REQUIRE(stellar::loadAccount(ltx, a1.getPublicKey()));
REQUIRE(stellar::loadAccount(ltx, b1.getPublicKey()));
}
Expand Down Expand Up @@ -4168,13 +4168,13 @@ setupUpgradeAtNextLedger(Application& app)
}
else
{
LedgerTxn ltx(app.getLedgerTxnRoot());
LedgerTxn ltx(app.getTestLedgerTxn());
ConfigUpgradeSetFrameConstPtr configUpgradeSet;
ConfigUpgradeSet configUpgradeSetXdr;
auto& configEntry = configUpgradeSetXdr.updatedEntry.emplace_back();
configEntry.configSettingID(CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0);
configEntry.contractHistoricalData().feeHistorical1KB = 1234;
configUpgradeSet = makeConfigUpgradeSet(ltx, configUpgradeSetXdr);
configUpgradeSet = makeConfigUpgradeSet(app, ltx, configUpgradeSetXdr);

scheduledUpgrades.mConfigUpgradeSetKey = configUpgradeSet->getKey();
ltx.commit();
Expand All @@ -4197,6 +4197,7 @@ herderExternalizesValuesWithProtocol(uint32_t version)
auto simulation = std::make_shared<Simulation>(
Simulation::OVER_LOOPBACK, networkID, [version](int i) {
auto cfg = getTestConfig(i, Config::TESTDB_ON_DISK_SQLITE);
cfg.DEPRECATED_SQL_LEDGER_STATE = true;
cfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION = version;
return cfg;
});
Expand Down
6 changes: 3 additions & 3 deletions src/herder/test/TxSetTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TEST_CASE("generalized tx set XDR validation", "[txset]")
GeneralizedTransactionSet xdrTxSet(1);
xdrTxSet.v1TxSet().previousLedgerHash =
app->getLedgerManager().getLastClosedLedgerHeader().hash;
LedgerTxn ltx(app->getLedgerTxnRoot());
LedgerTxn ltx(app->getTestLedgerTxn());
SECTION("no phases")
{
auto txSet = TxSetXDRFrame::makeFromWire(xdrTxSet);
Expand Down Expand Up @@ -519,7 +519,7 @@ TEST_CASE("generalized tx set XDR conversion", "[txset]")
auto txSetFrame = TxSetXDRFrame::makeFromWire(txSetXdr);
ApplicableTxSetFrameConstPtr applicableFrame;
{
LedgerTxn ltx(app->getLedgerTxnRoot(), false,
LedgerTxn ltx(app->getTestLedgerTxn(), false,
TransactionMode::READ_ONLY_WITHOUT_SQL_TXN);
applicableFrame = txSetFrame->prepareForApply(*app);
}
Expand Down Expand Up @@ -843,7 +843,7 @@ TEST_CASE("generalized tx set fees", "[txset][soroban]")
auto tx = createUploadWasmTx(*app, source, inclusionFee,
resourceFee, resources);
REQUIRE(tx->getInclusionFee() == inclusionFee);
LedgerTxn ltx(app->getLedgerTxnRoot());
LedgerTxn ltx(app->getTestLedgerTxn());
if (validateTx)
{
REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0));
Expand Down
Loading