From bd495882716f91dca4c9b640e209af4a2c3e4a95 Mon Sep 17 00:00:00 2001 From: Thomas Brady Date: Wed, 24 Jul 2024 11:12:35 -0700 Subject: [PATCH] WIP broken test refactor --- src/bucket/BucketList.cpp | 3 + src/bucket/test/BucketListTests.cpp | 9 +- src/bucket/test/BucketTests.cpp | 4 +- src/herder/HerderImpl.cpp | 3 + src/herder/TransactionQueue.cpp | 6 + src/herder/TxQueueLimiter.cpp | 2 +- src/herder/TxSetFrame.cpp | 4 + src/herder/TxSetUtils.cpp | 5 + src/herder/test/HerderTests.cpp | 23 +- src/herder/test/TxSetTests.cpp | 6 +- src/herder/test/UpgradesTests.cpp | 68 ++--- .../AccountSubEntriesCountIsValidTests.cpp | 4 +- ...ucketListIsConsistentWithDatabaseTests.cpp | 20 +- .../test/ConservationOfLumensTests.cpp | 14 +- src/invariant/test/InvariantTestUtils.cpp | 4 +- src/invariant/test/InvariantTests.cpp | 4 +- .../test/OrderBookIsNotCrossedTests.cpp | 2 +- .../test/SponsorshipCountIsValidTests.cpp | 26 +- src/ledger/LedgerManagerImpl.cpp | 8 +- src/ledger/LedgerTxn.cpp | 35 ++- src/ledger/test/LedgerHeaderTests.cpp | 4 +- src/ledger/test/LedgerTests.cpp | 4 +- src/ledger/test/LedgerTxnTests.cpp | 253 +++++++++--------- src/ledger/test/LiabilitiesTests.cpp | 44 +-- src/main/Application.h | 5 + src/main/ApplicationImpl.cpp | 28 ++ src/main/ApplicationImpl.h | 4 + src/main/CommandHandler.cpp | 2 +- src/main/test/ApplicationUtilsTests.cpp | 2 +- src/main/test/CommandHandlerTests.cpp | 12 +- src/overlay/test/FloodTests.cpp | 4 +- src/overlay/test/OverlayTests.cpp | 4 +- src/simulation/test/LoadGeneratorTests.cpp | 4 +- src/test/TestAccount.cpp | 46 ++-- src/test/TestMarket.cpp | 2 +- src/test/TestUtils.cpp | 4 +- src/test/TxTests.cpp | 51 ++-- src/test/TxTests.h | 4 +- src/test/test.cpp | 4 +- .../BeginSponsoringFutureReservesTests.cpp | 22 +- src/transactions/test/BumpSequenceTests.cpp | 2 +- src/transactions/test/ChangeTrustTests.cpp | 35 +-- .../test/ClaimableBalanceTests.cpp | 22 +- .../test/ClawbackClaimableBalanceTests.cpp | 4 +- src/transactions/test/CreateAccountTests.cpp | 10 +- .../test/EndSponsoringFutureReservesTests.cpp | 4 +- .../test/FeeBumpTransactionTests.cpp | 56 ++-- src/transactions/test/InflationTests.cpp | 26 +- .../test/InvokeHostFunctionTests.cpp | 61 +++-- .../test/LiquidityPoolDepositTests.cpp | 4 +- .../test/LiquidityPoolTradeTests.cpp | 2 +- src/transactions/test/ManageBuyOfferTests.cpp | 20 +- src/transactions/test/MergeTests.cpp | 31 +-- src/transactions/test/OfferTests.cpp | 66 ++--- .../test/PathPaymentStrictSendTests.cpp | 6 +- src/transactions/test/PathPaymentTests.cpp | 34 +-- src/transactions/test/PaymentTests.cpp | 22 +- .../test/RevokeSponsorshipTests.cpp | 70 ++--- src/transactions/test/SetOptionsTests.cpp | 12 +- .../test/SetTrustLineFlagsTests.cpp | 33 +-- src/transactions/test/SorobanTxTestUtils.cpp | 24 +- .../test/SponsorshipTestUtils.cpp | 30 +-- src/transactions/test/TxEnvelopeTests.cpp | 82 +++--- src/transactions/test/TxResultsTests.cpp | 5 +- 64 files changed, 776 insertions(+), 638 deletions(-) diff --git a/src/bucket/BucketList.cpp b/src/bucket/BucketList.cpp index b49ba3a9b3..17d27ee597 100644 --- a/src/bucket/BucketList.cpp +++ b/src/bucket/BucketList.cpp @@ -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)); } diff --git a/src/bucket/test/BucketListTests.cpp b/src/bucket/test/BucketListTests.cpp index edb8276fba..18e145518c 100644 --- a/src/bucket/test/BucketListTests.cpp +++ b/src/bucket/test/BucketListTests.cpp @@ -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(clock, cfg); @@ -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); @@ -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(); }(); @@ -817,7 +818,7 @@ TEST_CASE_VERSIONS("eviction scan", "[bucketlist]") auto checkIfEntryExists = [&](std::set const& keys, bool shouldExist) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); for (auto const& key : keys) { auto txle = ltx.loadWithoutRecord(key); @@ -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(firstEntry)); diff --git a/src/bucket/test/BucketTests.cpp b/src/bucket/test/BucketTests.cpp index 550438cac8..fa10788e1a 100644 --- a/src/bucket/test/BucketTests.cpp +++ b/src/bucket/test/BucketTests.cpp @@ -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 */); } }); diff --git a/src/herder/HerderImpl.cpp b/src/herder/HerderImpl.cpp index c4a475cd8f..a9edeff8a3 100644 --- a/src/herder/HerderImpl.cpp +++ b/src/herder/HerderImpl.cpp @@ -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); } diff --git a/src/herder/TransactionQueue.cpp b/src/herder/TransactionQueue.cpp index a9d36806f4..7da3ceed64 100644 --- a/src/herder/TransactionQueue.cpp +++ b/src/herder/TransactionQueue.cpp @@ -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); @@ -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); diff --git a/src/herder/TxQueueLimiter.cpp b/src/herder/TxQueueLimiter.cpp index 773251d7a7..84079f8c04 100644 --- a/src/herder/TxQueueLimiter.cpp +++ b/src/herder/TxQueueLimiter.cpp @@ -121,7 +121,7 @@ TxQueueLimiter::canAddTx(TransactionFrameBasePtr const& newTx, std::vector>& 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); diff --git a/src/herder/TxSetFrame.cpp b/src/herder/TxSetFrame.cpp index 3a1b324d6a..2d6c74a989 100644 --- a/src/herder/TxSetFrame.cpp +++ b/src/herder/TxSetFrame.cpp @@ -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)) diff --git a/src/herder/TxSetUtils.cpp b/src/herder/TxSetUtils.cpp index d8a74421d2..1953999bd8 100644 --- a/src/herder/TxSetUtils.cpp +++ b/src/herder/TxSetUtils.cpp @@ -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, diff --git a/src/herder/test/HerderTests.cpp b/src/herder/test/HerderTests.cpp index 48dfe8eb8a..0e50b8f0b5 100644 --- a/src/herder/test/HerderTests.cpp +++ b/src/herder/test/HerderTests.cpp @@ -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); @@ -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(SOROBAN_PROTOCOL_VERSION)) { @@ -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(SOROBAN_PROTOCOL_VERSION)) { @@ -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(); } @@ -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(); } @@ -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(); } @@ -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(); } @@ -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())); } @@ -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())); } @@ -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(); @@ -4197,6 +4197,7 @@ herderExternalizesValuesWithProtocol(uint32_t version) auto simulation = std::make_shared( 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; }); diff --git a/src/herder/test/TxSetTests.cpp b/src/herder/test/TxSetTests.cpp index 6e11b087e1..051b8d82ee 100644 --- a/src/herder/test/TxSetTests.cpp +++ b/src/herder/test/TxSetTests.cpp @@ -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); @@ -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); } @@ -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)); diff --git a/src/herder/test/UpgradesTests.cpp b/src/herder/test/UpgradesTests.cpp index bc785006f4..bac7ce192b 100644 --- a/src/herder/test/UpgradesTests.cpp +++ b/src/herder/test/UpgradesTests.cpp @@ -234,6 +234,7 @@ makeFlagsUpgrade(int flags) ConfigUpgradeSetFrameConstPtr makeMaxContractSizeBytesTestUpgrade( + Application& app, AbstractLedgerTxn& ltx, uint32_t maxContractSizeBytes, bool expiredEntry = false, ContractDataDurability type = ContractDataDurability::TEMPORARY) @@ -243,7 +244,7 @@ makeMaxContractSizeBytesTestUpgrade( auto& configEntry = configUpgradeSet.updatedEntry.emplace_back(); configEntry.configSettingID(CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES); configEntry.contractMaxSizeBytes() = maxContractSizeBytes; - return makeConfigUpgradeSet(ltx, configUpgradeSet, expiredEntry, type); + return makeConfigUpgradeSet(app, ltx, configUpgradeSet, expiredEntry, type); } ConfigUpgradeSetFrameConstPtr @@ -262,7 +263,7 @@ makeBucketListSizeWindowSampleSizeTestUpgrade(Application& app, auto& configEntry = configUpgradeSet.updatedEntry.emplace_back(); configEntry.configSettingID(CONFIG_SETTING_STATE_ARCHIVAL); configEntry.stateArchivalSettings() = sas; - return makeConfigUpgradeSet(ltx, configUpgradeSet); + return makeConfigUpgradeSet(app, ltx, configUpgradeSet); } LedgerKey @@ -311,7 +312,7 @@ testListUpgrades(VirtualClock::system_time_point preferredUpgradeDatetime, makeTxCountUpgrade(cfg.TESTING_UPGRADE_MAX_TX_SET_SIZE); auto baseReserveUpgrade = makeBaseReserveUpgrade(cfg.TESTING_UPGRADE_RESERVE); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); SECTION("protocol version upgrade needed") { header.ledgerVersion--; @@ -638,21 +639,23 @@ TEST_CASE("config upgrade validation", "[upgrades]") SECTION("expired config upgrade entry") { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); // This will attempt to construct an upgrade set from an expired // entry. This is invalid, so the returned upgrade set should be // null. REQUIRE(makeMaxContractSizeBytesTestUpgrade( + *app, ltx, 32768, /*expiredEntry=*/true) == nullptr); } SECTION("PERSISTENT config upgrade entry") { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); // This will attempt to construct an upgrade set from a PERSISTENT // entry. This is invalid, so the returned upgrade set should be // null. REQUIRE(makeMaxContractSizeBytesTestUpgrade( + *app, ltx, 32768, /*expiredEntry=*/false, ContractDataDurability::PERSISTENT) == nullptr); } @@ -660,8 +663,8 @@ TEST_CASE("config upgrade validation", "[upgrades]") ConfigUpgradeSetFrameConstPtr configUpgradeSet; Upgrades::UpgradeParameters scheduledUpgrades; { - LedgerTxn ltx(app->getLedgerTxnRoot()); - configUpgradeSet = makeMaxContractSizeBytesTestUpgrade(ltx, 32768); + LedgerTxn ltx(app->getTestLedgerTxn()); + configUpgradeSet = makeMaxContractSizeBytesTestUpgrade(*app, ltx, 32768); scheduledUpgrades.mUpgradeTime = genesis(0, 1); scheduledUpgrades.mConfigUpgradeSetKey = configUpgradeSet->getKey(); @@ -671,7 +674,7 @@ TEST_CASE("config upgrade validation", "[upgrades]") SECTION("validate for apply") { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); LedgerUpgrade outUpgrade; SECTION("valid") { @@ -700,7 +703,7 @@ TEST_CASE("config upgrade validation", "[upgrades]") ConfigUpgradeSet badConfigUpgradeSet; auto testInvalidXdr = [&]() { auto configUpgradeSetFrame = - makeConfigUpgradeSet(ltx, badConfigUpgradeSet); + makeConfigUpgradeSet(*app, ltx, badConfigUpgradeSet); REQUIRE(configUpgradeSetFrame->isValidForApply() == Upgrades::UpgradeValidity::XDR_INVALID); REQUIRE(Upgrades::isValidForApply( @@ -770,7 +773,7 @@ TEST_CASE("config upgrade validation", "[upgrades]") { REQUIRE(Upgrades::isValidForApply( toUpgradeType(makeConfigUpgrade( - *makeMaxContractSizeBytesTestUpgrade(ltx, 0))), + *makeMaxContractSizeBytesTestUpgrade(*app, ltx, 0))), outUpgrade, *app, ltx, header) == Upgrades::UpgradeValidity::INVALID); } @@ -798,9 +801,9 @@ TEST_CASE("config upgrade validation", "[upgrades]") { ConfigUpgradeSetFrameConstPtr upgradeSet; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); upgradeSet = - makeMaxContractSizeBytesTestUpgrade(ltx, 12345); + makeMaxContractSizeBytesTestUpgrade(*app, ltx, 12345); ltx.commit(); } @@ -846,15 +849,15 @@ TEST_CASE("config upgrades applied to ledger", "[soroban][upgrades]") { ConfigUpgradeSetFrameConstPtr configUpgradeSet; { - LedgerTxn ltx2(app->getLedgerTxnRoot()); - configUpgradeSet = makeMaxContractSizeBytesTestUpgrade(ltx2, 32768); + LedgerTxn ltx2(app->getTestLedgerTxn()); + configUpgradeSet = makeMaxContractSizeBytesTestUpgrade(*app, ltx2, 32768); ltx2.commit(); } REQUIRE(configUpgradeSet); executeUpgrade(*app, makeConfigUpgrade(*configUpgradeSet)); - LedgerTxn ltx2(app->getLedgerTxnRoot()); + LedgerTxn ltx2(app->getTestLedgerTxn()); auto maxContractSizeEntry = ltx2.load(getMaxContractSizeKey()).current().data.configSetting(); REQUIRE(maxContractSizeEntry.configSettingID() == @@ -867,7 +870,7 @@ TEST_CASE("config upgrades applied to ledger", "[soroban][upgrades]") auto populateValuesAndUpgradeSize = [&](uint32_t size) { ConfigUpgradeSetFrameConstPtr configUpgradeSet; { - LedgerTxn ltx2(app->getLedgerTxnRoot()); + LedgerTxn ltx2(app->getTestLedgerTxn()); auto& cfg = app->getLedgerManager().getMutableSorobanNetworkConfig(); @@ -944,7 +947,7 @@ TEST_CASE("config upgrades applied to ledger", "[soroban][upgrades]") std::deque initialWindow; ConfigUpgradeSetFrameConstPtr configUpgradeSet; { - LedgerTxn ltx2(app->getLedgerTxnRoot()); + LedgerTxn ltx2(app->getTestLedgerTxn()); auto const& cfg = app->getLedgerManager().getSorobanNetworkConfig(); @@ -1013,8 +1016,8 @@ TEST_CASE("config upgrades applied to ledger", "[soroban][upgrades]") configEntry2.configSettingID( CONFIG_SETTING_CONTRACT_HISTORICAL_DATA_V0); configEntry2.contractHistoricalData().feeHistorical1KB = 555; - LedgerTxn ltx2(app->getLedgerTxnRoot()); - configUpgradeSet = makeConfigUpgradeSet(ltx2, configUpgradeSetXdr); + LedgerTxn ltx2(app->getTestLedgerTxn()); + configUpgradeSet = makeConfigUpgradeSet(*app, ltx2, configUpgradeSetXdr); ltx2.commit(); } executeUpgrade(*app, makeConfigUpgrade(*configUpgradeSet)); @@ -1032,7 +1035,7 @@ TEST_CASE("config upgrades applied to ledger", "[soroban][upgrades]") // This just test one setting. We should test more. auto upgrade = [&](uint32_t min, uint32_t upgradeVal) { ConfigUpgradeSetFrameConstPtr configUpgradeSet; - LedgerTxn ltx2(app->getLedgerTxnRoot()); + LedgerTxn ltx2(app->getTestLedgerTxn()); // Copy current settings LedgerKey key(CONFIG_SETTING); key.configSetting().configSettingID = @@ -1043,7 +1046,7 @@ TEST_CASE("config upgrades applied to ledger", "[soroban][upgrades]") ConfigUpgradeSet configUpgradeSetXdr; configUpgradeSetXdr.updatedEntry.emplace_back(configSetting); - configUpgradeSet = makeConfigUpgradeSet(ltx2, configUpgradeSetXdr); + configUpgradeSet = makeConfigUpgradeSet(*app, ltx2, configUpgradeSetXdr); ltx2.commit(); executeUpgrade(*app, makeConfigUpgrade(*configUpgradeSet)); @@ -1116,7 +1119,7 @@ TEST_CASE("upgrade to version 10", "[upgrades]") auto getLiabilities = [&](TestAccount& acc) { Liabilities res; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto account = stellar::loadAccount(ltx, acc.getPublicKey()); res.selling = getSellingLiabilities(ltx.loadHeader(), account); res.buying = getBuyingLiabilities(ltx.loadHeader(), account); @@ -1126,7 +1129,7 @@ TEST_CASE("upgrade to version 10", "[upgrades]") Liabilities res; if (acc.hasTrustLine(asset)) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto trust = stellar::loadTrustLine(ltx, acc.getPublicKey(), asset); res.selling = trust.getSellingLiabilities(ltx.loadHeader()); res.buying = trust.getBuyingLiabilities(ltx.loadHeader()); @@ -2269,7 +2272,7 @@ TEST_CASE("configuration initialized in version upgrade", "[upgrades]") makeProtocolVersionUpgrade( static_cast(SOROBAN_PROTOCOL_VERSION) - 1)); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!ltx.load(getMaxContractSizeKey())); } @@ -2277,7 +2280,7 @@ TEST_CASE("configuration initialized in version upgrade", "[upgrades]") executeUpgrade(*app, makeProtocolVersionUpgrade( static_cast(SOROBAN_PROTOCOL_VERSION))); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto maxContractSizeEntry = ltx.load(getMaxContractSizeKey()).current().data.configSetting(); REQUIRE(maxContractSizeEntry.configSettingID() == @@ -2315,6 +2318,7 @@ TEST_CASE_VERSIONS("upgrade base reserve", "[upgrades]") { VirtualClock clock; auto cfg = getTestConfig(0); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; auto app = createTestApplication(clock, cfg); @@ -2336,7 +2340,7 @@ TEST_CASE_VERSIONS("upgrade base reserve", "[upgrades]") auto getLiabilities = [&](TestAccount& acc) { Liabilities res; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto account = stellar::loadAccount(ltx, acc.getPublicKey()); res.selling = getSellingLiabilities(ltx.loadHeader(), account); res.buying = getBuyingLiabilities(ltx.loadHeader(), account); @@ -2346,7 +2350,7 @@ TEST_CASE_VERSIONS("upgrade base reserve", "[upgrades]") Liabilities res; if (acc.hasTrustLine(asset)) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto trust = stellar::loadTrustLine(ltx, acc.getPublicKey(), asset); res.selling = trust.getSellingLiabilities(ltx.loadHeader()); res.buying = trust.getBuyingLiabilities(ltx.loadHeader()); @@ -2354,12 +2358,12 @@ TEST_CASE_VERSIONS("upgrade base reserve", "[upgrades]") return res; }; auto getNumSponsoringEntries = [&](TestAccount& acc) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto account = stellar::loadAccount(ltx, acc.getPublicKey()); return getNumSponsoring(account.current()); }; auto getNumSponsoredEntries = [&](TestAccount& acc) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto account = stellar::loadAccount(ltx, acc.getPublicKey()); return getNumSponsored(account.current()); }; @@ -2471,7 +2475,7 @@ TEST_CASE_VERSIONS("upgrade base reserve", "[upgrades]") }); auto submitTx = [&](TransactionFrameBasePtr tx) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->apply(*app, ltx, txm)); @@ -3025,8 +3029,8 @@ TEST_CASE("upgrades serialization roundtrip", "[upgrades]") initUpgrades.mProtocolVersion = std::make_optional(20); { - LedgerTxn ltx(app->getLedgerTxnRoot()); - auto configUpgradeSet = makeMaxContractSizeBytesTestUpgrade(ltx, 32768); + LedgerTxn ltx(app->getTestLedgerTxn()); + auto configUpgradeSet = makeMaxContractSizeBytesTestUpgrade(*app, ltx, 32768); initUpgrades.mConfigUpgradeSetKey = configUpgradeSet->getKey(); ltx.commit(); } diff --git a/src/invariant/test/AccountSubEntriesCountIsValidTests.cpp b/src/invariant/test/AccountSubEntriesCountIsValidTests.cpp index f6eeda78dc..e6539374eb 100644 --- a/src/invariant/test/AccountSubEntriesCountIsValidTests.cpp +++ b/src/invariant/test/AccountSubEntriesCountIsValidTests.cpp @@ -160,7 +160,7 @@ updateAccountSubEntries(Application& app, LedgerEntry& leCurr, auto currPtr = std::make_shared(leCurr); auto prevPtr = std::make_shared(lePrev); updates.push_back(std::make_tuple(currPtr, prevPtr)); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); REQUIRE(!store(app, updates, <x)); } { @@ -340,7 +340,7 @@ TEST_CASE("Create account then add signers and subentries", if (le.data.account().numSubEntries != le.data.account().signers.size()) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!store(*app, makeUpdateList(nullptr, {le}), <x)); } { diff --git a/src/invariant/test/BucketListIsConsistentWithDatabaseTests.cpp b/src/invariant/test/BucketListIsConsistentWithDatabaseTests.cpp index 7a6b0731e3..458565963b 100644 --- a/src/invariant/test/BucketListIsConsistentWithDatabaseTests.cpp +++ b/src/invariant/test/BucketListIsConsistentWithDatabaseTests.cpp @@ -44,6 +44,7 @@ struct BucketListGenerator auto cfg = getTestConfig(0); cfg.OVERRIDE_EVICTION_PARAMS_FOR_TESTING = true; cfg.TESTING_STARTING_EVICTION_SCAN_LEVEL = 1; + //cfg.DEPRECATED_SQL_LEDGER_STATE = true; mAppGenerate = createTestApplication(mClock, cfg); auto skey = SecretKey::fromSeed(mAppGenerate->getNetworkID()); @@ -67,7 +68,7 @@ struct BucketListGenerator } } - LedgerTxn ltx(mAppGenerate->getLedgerTxnRoot(), false); + LedgerTxn ltx(mAppGenerate->getTestLedgerTxn(), false); REQUIRE(mLedgerSeq == ltx.loadHeader().current().ledgerSeq); } @@ -88,8 +89,10 @@ struct BucketListGenerator applyBuckets(Args&&... args) { VirtualClock clock; + auto cfg = getTestConfig(1); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; Application::pointer app = - createTestApplication(clock, getTestConfig(1)); + createTestApplication(clock, cfg); applyBuckets(app, std::forward(args)...); } @@ -97,7 +100,7 @@ struct BucketListGenerator generateLedger() { auto& app = mAppGenerate; - LedgerTxn ltx(app->getLedgerTxnRoot(), false); + LedgerTxn ltx(app->getTestLedgerTxn(), false); REQUIRE(mLedgerSeq == ltx.loadHeader().current().ledgerSeq); mLedgerSeq = ++ltx.loadHeader().current().ledgerSeq; auto vers = ltx.loadHeader().current().ledgerVersion; @@ -194,7 +197,7 @@ struct BucketListGenerator auto& blGenerate = mAppGenerate->getBucketManager().getBucketList(); auto& bmApply = app->getBucketManager(); MergeCounters mergeCounters; - LedgerTxn ltx(mAppGenerate->getLedgerTxnRoot(), false); + LedgerTxn ltx(mAppGenerate->getTestLedgerTxn(), false); auto vers = ltx.loadHeader().current().ledgerVersion; for (uint32_t i = 0; i <= BucketList::kNumLevels - 1; i++) { @@ -340,7 +343,7 @@ class ApplyBucketsWorkAddEntry : public ApplyBucketsWork { uint32_t minLedger = mEntry.lastModifiedLedgerSeq; uint32_t maxLedger = std::numeric_limits::max() - 1; - auto& ltxRoot = mApp.getLedgerTxnRoot(); + auto& ltxRoot = mApp.getTestLedgerTxn(); size_t count = 0; for (auto let : xdr::xdr_traits::enum_values()) @@ -392,7 +395,7 @@ class ApplyBucketsWorkDeleteEntry : public ApplyBucketsWork { if (!mDeleted) { - LedgerTxn ltx(mApp.getLedgerTxnRoot(), false); + LedgerTxn ltx(mApp.getTestLedgerTxn(), false); auto entry = ltx.load(mKey); if (entry && entry.current() == mEntry) { @@ -549,7 +552,7 @@ class ApplyBucketsWorkModifyEntry : public ApplyBucketsWork { if (!mModified) { - LedgerTxn ltx(mApp.getLedgerTxnRoot(), false); + LedgerTxn ltx(mApp.getTestLedgerTxn(), false); auto entry = ltx.load(mKey); while (entry && entry.current() == mEntry) { @@ -919,13 +922,14 @@ TEST_CASE("BucketListIsConsistentWithDatabase merged LIVEENTRY and DEADENTRY", }; auto exists = [](Application& app, LedgerEntry const& le) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); return (bool)ltx.load(LedgerEntryKey(le)); }; auto cfg = getTestConfig(1); cfg.OVERRIDE_EVICTION_PARAMS_FOR_TESTING = true; cfg.TESTING_STARTING_EVICTION_SCAN_LEVEL = 1; + //cfg.DEPRECATED_SQL_LEDGER_STATE = true; testutil::BucketListDepthModifier bldm(3); for (auto t : xdr::xdr_traits::enum_values()) diff --git a/src/invariant/test/ConservationOfLumensTests.cpp b/src/invariant/test/ConservationOfLumensTests.cpp index 9fee45c9ba..8643a4cac8 100644 --- a/src/invariant/test/ConservationOfLumensTests.cpp +++ b/src/invariant/test/ConservationOfLumensTests.cpp @@ -82,7 +82,7 @@ updateBalances(std::vector entries, Application& app, if (updateTotalCoins) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto& current = ltx.loadHeader().current(); REQUIRE(current.totalCoins >= 0); if (netChange > 0) @@ -102,7 +102,7 @@ updateBalances(std::vector const& entries, Application& app) int64_t totalCoins = 0; { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); totalCoins = ltx.loadHeader().current().totalCoins; } @@ -123,7 +123,7 @@ TEST_CASE("Total coins change without inflation", VirtualClock clock; Application::pointer app = createTestApplication(clock, cfg); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ltx.loadHeader().current().totalCoins = dist(gRandomEngine); OperationResult res; REQUIRE_THROWS_AS(app->getInvariantManager().checkOnOperationApply( @@ -142,7 +142,7 @@ TEST_CASE("Fee pool change without inflation", VirtualClock clock; Application::pointer app = createTestApplication(clock, cfg); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ltx.loadHeader().current().feePool = dist(gRandomEngine); OperationResult res; REQUIRE_THROWS_AS(app->getInvariantManager().checkOnOperationApply( @@ -266,7 +266,7 @@ TEST_CASE("Inflation changes are consistent", auto deltaFeePool = deltaFeePoolDist(gRandomEngine); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ltx.loadHeader().current().feePool += deltaFeePool; REQUIRE_THROWS_AS(app->getInvariantManager().checkOnOperationApply( {}, opRes, ltx.getDelta()), @@ -274,7 +274,7 @@ TEST_CASE("Inflation changes are consistent", } { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ltx.loadHeader().current().feePool += deltaFeePool; ltx.loadHeader().current().totalCoins += deltaFeePool + inflationAmount; @@ -285,7 +285,7 @@ TEST_CASE("Inflation changes are consistent", auto entries2 = updateBalances(entries1, *app, inflationAmount, true); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ltx.loadHeader().current().feePool += deltaFeePool; ltx.loadHeader().current().totalCoins += deltaFeePool + inflationAmount; diff --git a/src/invariant/test/InvariantTestUtils.cpp b/src/invariant/test/InvariantTestUtils.cpp index 9eb06227ad..c01706c992 100644 --- a/src/invariant/test/InvariantTestUtils.cpp +++ b/src/invariant/test/InvariantTestUtils.cpp @@ -63,7 +63,7 @@ store(Application& app, UpdateList const& apply, AbstractLedgerTxn* ltxPtr, std::unique_ptr ltxStore; if (ltxPtr == nullptr) { - ltxStore = std::make_unique(app.getLedgerTxnRoot()); + ltxStore = std::make_unique(app.getTestLedgerTxn()); ltxPtr = ltxStore.get(); } for (auto const& toApply : apply) @@ -205,7 +205,7 @@ normalizeSigners(AccountEntry& acc) int64_t getMinBalance(Application& app, AccountEntry const& acc) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); return getMinBalance(ltx.loadHeader().current(), acc); } } diff --git a/src/invariant/test/InvariantTests.cpp b/src/invariant/test/InvariantTests.cpp index c2983e15a3..2375b136d6 100644 --- a/src/invariant/test/InvariantTests.cpp +++ b/src/invariant/test/InvariantTests.cpp @@ -200,7 +200,7 @@ TEST_CASE("onOperationApply fail succeed", "[invariant]") app->getInvariantManager().enableInvariant( TestInvariant::toString(0, true)); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE_THROWS_AS(app->getInvariantManager().checkOnOperationApply( {}, res, ltx.getDelta()), InvariantDoesNotHold); @@ -211,7 +211,7 @@ TEST_CASE("onOperationApply fail succeed", "[invariant]") app->getInvariantManager().enableInvariant( TestInvariant::toString(0, false)); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE_NOTHROW(app->getInvariantManager().checkOnOperationApply( {}, res, ltx.getDelta())); } diff --git a/src/invariant/test/OrderBookIsNotCrossedTests.cpp b/src/invariant/test/OrderBookIsNotCrossedTests.cpp index 0620a1aeb9..6821c6dc56 100644 --- a/src/invariant/test/OrderBookIsNotCrossedTests.cpp +++ b/src/invariant/test/OrderBookIsNotCrossedTests.cpp @@ -121,7 +121,7 @@ TEST_CASE("OrderBookIsNotCrossed in-memory order book is consistent with " auto const cur1 = root.asset("CUR1"); auto const cur2 = root.asset("CUR2"); - LedgerTxn ltxOuter{app->getLedgerTxnRoot()}; + LedgerTxn ltxOuter{app->getTestLedgerTxn()}; auto const invariant = std::make_shared(); auto offer = InvariantTestUtils::generateOffer(cur1, cur2, 3, Price{3, 2}); diff --git a/src/invariant/test/SponsorshipCountIsValidTests.cpp b/src/invariant/test/SponsorshipCountIsValidTests.cpp index e7f3e05063..53476396a7 100644 --- a/src/invariant/test/SponsorshipCountIsValidTests.cpp +++ b/src/invariant/test/SponsorshipCountIsValidTests.cpp @@ -184,7 +184,7 @@ TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]") auto sponsoring = doNumSponsoring(*initSponsoring, 2, updateNumSponsoring); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); prepareState(ltx, {*initSponsoring}); bool res = updateNumSponsoring && updateNumSponsored && updateSponsoring; @@ -208,7 +208,7 @@ TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]") *initSponsored, testutil::computeMultiplier(*entry), updateNumSponsored); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); prepareState(ltx, {*initSponsoring, *initSponsored}); bool res = updateNumSponsoring && updateNumSponsored && updateSponsoring; @@ -228,7 +228,7 @@ TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]") *initSponsoring, testutil::computeMultiplier(*entry), updateNumSponsoring); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); prepareState(ltx, {*initSponsoring}); bool res = updateNumSponsoring && updateSponsoring; REQUIRE(res == check(ltx, {{entry, nullptr}, @@ -265,7 +265,7 @@ TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]") auto sponsoring = doNumSponsoring(*initSponsoring, 1, updateNumSponsoring); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); prepareState(ltx, {*initEntry, *initSponsoring}); bool res = updateNumSponsoring && updateNumSponsored && updateSponsoring; @@ -299,7 +299,7 @@ TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]") auto initSponsoring2 = createAccount(sponsoringID2, true); auto sponsoring2 = doNumSponsoring(*initSponsoring2, 2); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); prepareState(ltx, {*initEntry, *initSponsoring1, *initSponsoring2}); REQUIRE(check( ltx, {{entry1, initEntry}, {sponsoring1, initSponsoring1}})); @@ -325,7 +325,7 @@ TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]") auto sponsored = doNumSponsored( *initSponsored, testutil::computeMultiplier(*entry2)); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); prepareState(ltx, {*initEntry, *initSponsoring1, *initSponsoring2, *initSponsored}); REQUIRE(check(ltx, {{entry1, initEntry}, @@ -351,7 +351,7 @@ TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]") auto sponsoring2 = doNumSponsoring( *initSponsoring2, testutil::computeMultiplier(*entry2)); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); prepareState(ltx, {*initEntry, *initSponsoring1, *initSponsoring2}); REQUIRE(check( ltx, {{entry1, initEntry}, {sponsoring1, initSponsoring1}})); @@ -378,7 +378,7 @@ TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]") auto initSponsoring2 = createAccount(sponsoringID2, true); auto sponsoring2 = doNumSponsoring(*initSponsoring2, 1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); prepareState(ltx, {*initEntry, *initSponsoring1, *initSponsoring2}); REQUIRE( check(ltx, {{entry1, initEntry}, {sponsoring1, initSponsoring1}})); @@ -404,7 +404,7 @@ TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]") auto sponsoring = doNumSponsoring(*initSponsoring, -2, updateNumSponsoring); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); prepareState(ltx, {*initEntry, *initSponsoring}); bool res = updateNumSponsoring && updateNumSponsored && updateSponsoring; @@ -430,7 +430,7 @@ TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]") -testutil::computeMultiplier(*initEntry), updateNumSponsored); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); prepareState(ltx, {*initEntry, *initSponsoring, *initSponsored}); bool res = updateNumSponsoring && updateNumSponsored && @@ -452,7 +452,7 @@ TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]") *initSponsoring, -testutil::computeMultiplier(*initEntry), updateNumSponsoring); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); prepareState(ltx, {*initEntry, *initSponsoring}); bool res = updateNumSponsoring && updateSponsoring; REQUIRE(res == check(ltx, {{nullptr, initEntry}, @@ -489,7 +489,7 @@ TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]") auto initSponsoring = doNumSponsoring(*sponsoring, 1, updateNumSponsoring); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); prepareState(ltx, {*initEntry, *initSponsoring}); bool res = updateNumSponsoring && updateNumSponsored && updateSponsoring; @@ -513,7 +513,7 @@ TEST_CASE("sponsorship invariant", "[invariant][sponsorshipcountisvalid]") auto initEntry2 = createEntry(OFFER, sponsoredID); initEntry2 = doSponsoring(*initEntry2, sponsoringID); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); prepareState(ltx, {*initEntry2}); REQUIRE(check(ltx, {{entry1, nullptr}, {nullptr, initEntry2}})); } diff --git a/src/ledger/LedgerManagerImpl.cpp b/src/ledger/LedgerManagerImpl.cpp index 7a30739598..f191dfa89b 100644 --- a/src/ledger/LedgerManagerImpl.cpp +++ b/src/ledger/LedgerManagerImpl.cpp @@ -277,6 +277,9 @@ LedgerManagerImpl::startNewLedger() static void setLedgerTxnHeader(LedgerHeader const& lh, Application& app) { +#ifdef BUILD_TESTS + app.resetTestLedgerTxn(); +#endif LedgerTxn ltx(app.getLedgerTxnRoot()); ltx.loadHeader().current() = lh; ltx.commit(); @@ -795,7 +798,10 @@ LedgerManagerImpl::closeLedger(LedgerCloseData const& ledgerData) LogSlowExecution closeLedgerTime{"closeLedger", LogSlowExecution::Mode::MANUAL, "", std::chrono::milliseconds::max()}; - +#ifdef BUILD_TESTS + //LedgerTxn ltx(mApp.getTestLedgerTxn()); + mApp.resetTestLedgerTxn(); +#endif LedgerTxn ltx(mApp.getLedgerTxnRoot()); auto header = ltx.loadHeader(); auto initialLedgerVers = header.current().ledgerVersion; diff --git a/src/ledger/LedgerTxn.cpp b/src/ledger/LedgerTxn.cpp index a869193855..dc79d84f66 100644 --- a/src/ledger/LedgerTxn.cpp +++ b/src/ledger/LedgerTxn.cpp @@ -2711,7 +2711,40 @@ LedgerTxnRoot::Impl::commitChild(EntryIterator iter, LedgerTxnConsistency cons) noexcept { ZoneScoped; - + //if (mApp.getConfig().ADD_TO_BUCKETLIST_ON_COMMIT) + /* + std::vector initEntries; + std::vector liveEntries; + std::vector deadEntries; + while ((bool) iter) + { + if (iter.entryExists()) + { + if (iter.entryPtr().isInit()) + { + initEntries.emplace_back(iter.entry().ledgerEntry()); + } + else + { + liveEntries.emplace_back(iter.entry().ledgerEntry()); + } + } + else + { + deadEntries.emplace_back(iter.key().ledgerKey()); + } + ++iter; + } + auto currLedgerVersion = mHeader->ledgerVersion; + auto currLedger = mHeader->ledgerSeq; + // ensure currLedger > 0 + if (currLedger > 0) + { + mApp.getBucketManager().addBatch(mApp, currLedger, currLedgerVersion, initEntries, + liveEntries, + deadEntries); + } + */ // In this mode, where we do not start a SQL transaction, so we crash if // there's an attempt to commit, since the expected behavior is load and // rollback. diff --git a/src/ledger/test/LedgerHeaderTests.cpp b/src/ledger/test/LedgerHeaderTests.cpp index 39a5e15bd8..ace007251c 100644 --- a/src/ledger/test/LedgerHeaderTests.cpp +++ b/src/ledger/test/LedgerHeaderTests.cpp @@ -107,12 +107,12 @@ TEST_CASE_VERSIONS("base reserve", "[ledger]") int64 expectedReserve = 2000200000000ll; for_versions_to(8, *app, [&]() { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(getMinBalance(ltx.loadHeader().current(), n, 0, 0) < expectedReserve); }); for_versions_from(9, *app, [&]() { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(getMinBalance(ltx.loadHeader().current(), n, 0, 0) == expectedReserve); }); diff --git a/src/ledger/test/LedgerTests.cpp b/src/ledger/test/LedgerTests.cpp index cf5a4df3eb..1429b6fb14 100644 --- a/src/ledger/test/LedgerTests.cpp +++ b/src/ledger/test/LedgerTests.cpp @@ -31,14 +31,14 @@ TEST_CASE("cannot close ledger with unsupported ledger version", "[ledger]") applyEmptyLedger(); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ltx.loadHeader().current().ledgerVersion = Config::CURRENT_LEDGER_PROTOCOL_VERSION; ltx.commit(); } applyEmptyLedger(); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ltx.loadHeader().current().ledgerVersion = Config::CURRENT_LEDGER_PROTOCOL_VERSION + 1; ltx.commit(); diff --git a/src/ledger/test/LedgerTxnTests.cpp b/src/ledger/test/LedgerTxnTests.cpp index 3c00e67938..b8863c4d3a 100644 --- a/src/ledger/test/LedgerTxnTests.cpp +++ b/src/ledger/test/LedgerTxnTests.cpp @@ -138,14 +138,14 @@ TEST_CASE("LedgerTxn addChild", "[ledgertxn]") { SECTION("fails if parent has children") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); LedgerTxn ltx2(ltx1); REQUIRE_THROWS_AS(LedgerTxn(ltx1), std::runtime_error); } SECTION("fails if parent is sealed") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); ltx1.getDelta(); REQUIRE_THROWS_AS(LedgerTxn(ltx1), std::runtime_error); } @@ -155,8 +155,8 @@ TEST_CASE("LedgerTxn addChild", "[ledgertxn]") { SECTION("fails if parent has children") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); - REQUIRE_THROWS_AS(LedgerTxn(app->getLedgerTxnRoot()), + LedgerTxn ltx1(app->getTestLedgerTxn()); + REQUIRE_THROWS_AS(LedgerTxn(app->getTestLedgerTxn()), std::runtime_error); } } @@ -178,7 +178,7 @@ TEST_CASE("LedgerTxn commit into LedgerTxn", "[ledgertxn]") { SECTION("created in child") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); LedgerTxn ltx2(ltx1); REQUIRE(ltx2.create(le1)); @@ -191,7 +191,7 @@ TEST_CASE("LedgerTxn commit into LedgerTxn", "[ledgertxn]") SECTION("loaded in child") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le1)); LedgerTxn ltx2(ltx1); @@ -205,7 +205,7 @@ TEST_CASE("LedgerTxn commit into LedgerTxn", "[ledgertxn]") SECTION("modified in child") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le1)); LedgerTxn ltx2(ltx1); @@ -222,7 +222,7 @@ TEST_CASE("LedgerTxn commit into LedgerTxn", "[ledgertxn]") SECTION("erased in child") { le2 = generateLedgerEntryWithSameKey(le1); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le1)); LedgerTxn ltx2(ltx1); @@ -252,7 +252,7 @@ TEST_CASE("LedgerTxn rollback into LedgerTxn", "[ledgertxn]") { SECTION("created in child") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); LedgerTxn ltx2(ltx1); REQUIRE(ltx2.create(le1)); @@ -263,7 +263,7 @@ TEST_CASE("LedgerTxn rollback into LedgerTxn", "[ledgertxn]") SECTION("loaded in child") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le1)); LedgerTxn ltx2(ltx1); @@ -278,7 +278,7 @@ TEST_CASE("LedgerTxn rollback into LedgerTxn", "[ledgertxn]") SECTION("modified in child") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le1)); LedgerTxn ltx2(ltx1); @@ -300,7 +300,7 @@ TEST_CASE("LedgerTxn rollback into LedgerTxn", "[ledgertxn]") le1.lastModifiedLedgerSeq = 1; key = LedgerEntryKey(le1); le2 = generateLedgerEntryWithSameKey(le1); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le1)); LedgerTxn ltx2(ltx1); @@ -452,7 +452,7 @@ TEST_CASE("LedgerTxn round trip", "[ledgertxn]") VirtualClock clock; auto app = createTestApplication(clock, getTestConfig(0, mode)); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); runTest(ltx1); } @@ -463,7 +463,7 @@ TEST_CASE("LedgerTxn round trip", "[ledgertxn]") VirtualClock clock; auto app = createTestApplication(clock, getTestConfig(0, mode)); - runTest(app->getLedgerTxnRoot()); + runTest(app->getTestLedgerTxn()); } SECTION("with no cache") @@ -473,7 +473,7 @@ TEST_CASE("LedgerTxn round trip", "[ledgertxn]") cfg.ENTRY_CACHE_SIZE = 0; auto app = createTestApplication(clock, cfg); - runTest(app->getLedgerTxnRoot()); + runTest(app->getTestLedgerTxn()); } } }; @@ -496,7 +496,7 @@ TEST_CASE("LedgerTxn rollback and commit deactivate", "[ledgertxn]") VirtualClock clock; auto app = createTestApplication(clock, getTestConfig()); - auto& root = app->getLedgerTxnRoot(); + auto& root = app->getTestLedgerTxn(); auto lh = root.getHeader(); LedgerEntry le = LedgerTestUtils::generateValidLedgerEntryWithExclusions( @@ -556,21 +556,21 @@ TEST_CASE("LedgerTxn create", "[ledgertxn]") SECTION("fails with children") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); LedgerTxn ltx2(ltx1); REQUIRE_THROWS_AS(ltx1.create(le), std::runtime_error); } SECTION("fails if sealed") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); ltx1.getDelta(); REQUIRE_THROWS_AS(ltx1.create(le), std::runtime_error); } SECTION("when key does not exist") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); validate(ltx1, {{key, {std::make_shared(le), @@ -579,7 +579,7 @@ TEST_CASE("LedgerTxn create", "[ledgertxn]") SECTION("when key exists in self or parent") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); REQUIRE_THROWS_AS(ltx1.create(le), std::runtime_error); @@ -590,7 +590,7 @@ TEST_CASE("LedgerTxn create", "[ledgertxn]") SECTION("when key exists in grandparent, erased in parent") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); LedgerTxn ltx2(ltx1); @@ -619,7 +619,7 @@ TEST_CASE("LedgerTxn createWithoutLoading and updateWithoutLoading", SECTION("fails with children") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); LedgerTxn ltx2(ltx1); REQUIRE_THROWS_AS(ltx1.createWithoutLoading(le), std::runtime_error); @@ -629,7 +629,7 @@ TEST_CASE("LedgerTxn createWithoutLoading and updateWithoutLoading", SECTION("fails if sealed") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); ltx1.getDelta(); REQUIRE_THROWS_AS(ltx1.createWithoutLoading(le), std::runtime_error); @@ -639,7 +639,7 @@ TEST_CASE("LedgerTxn createWithoutLoading and updateWithoutLoading", SECTION("when key does not exist") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE_NOTHROW(ltx1.createWithoutLoading(le)); validate(ltx1, {{key, {std::make_shared(le), @@ -648,7 +648,7 @@ TEST_CASE("LedgerTxn createWithoutLoading and updateWithoutLoading", SECTION("when key exists in self or parent") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); REQUIRE_NOTHROW(ltx1.updateWithoutLoading(le)); @@ -662,7 +662,7 @@ TEST_CASE("LedgerTxn createWithoutLoading and updateWithoutLoading", SECTION("when key is active during overwrite") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); auto ltxe = ltx1.create(le); REQUIRE(ltxe); REQUIRE_THROWS_AS(ltx1.createWithoutLoading(le), @@ -673,7 +673,7 @@ TEST_CASE("LedgerTxn createWithoutLoading and updateWithoutLoading", SECTION("when key exists in grandparent, erased in parent") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); LedgerTxn ltx2(ltx1); @@ -714,7 +714,7 @@ TEST_CASE("LedgerTxn erase", "[ledgertxn]") SECTION("fails with children") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); LedgerTxn ltx2(ltx1); @@ -723,7 +723,7 @@ TEST_CASE("LedgerTxn erase", "[ledgertxn]") SECTION("fails if sealed") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); ltx1.getDelta(); REQUIRE_THROWS_AS(ltx1.erase(key), std::runtime_error); @@ -733,7 +733,7 @@ TEST_CASE("LedgerTxn erase", "[ledgertxn]") { auto configLe = LedgerTestUtils::generateValidLedgerEntryOfType(CONFIG_SETTING); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); // The config entry should already be present in ledger in starting // with vNext. REQUIRE_THROWS_AS(ltx1.erase(LedgerEntryKey(configLe)), @@ -742,14 +742,14 @@ TEST_CASE("LedgerTxn erase", "[ledgertxn]") SECTION("when key does not exist") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE_THROWS_AS(ltx1.erase(key), std::runtime_error); validate(ltx1, {}); } SECTION("when key exists in parent") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); LedgerTxn ltx2(ltx1); @@ -766,7 +766,7 @@ TEST_CASE("LedgerTxn erase", "[ledgertxn]") {CONFIG_SETTING}); le.lastModifiedLedgerSeq = 1; key = LedgerEntryKey(le); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); LedgerTxn ltx2(ltx1); @@ -804,7 +804,7 @@ TEST_CASE("LedgerTxn eraseWithoutLoading", "[ledgertxn]") SECTION("fails with children") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); LedgerTxn ltx2(ltx1); @@ -814,7 +814,7 @@ TEST_CASE("LedgerTxn eraseWithoutLoading", "[ledgertxn]") SECTION("fails if sealed") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); std::vector init, live; std::vector dead; @@ -827,7 +827,7 @@ TEST_CASE("LedgerTxn eraseWithoutLoading", "[ledgertxn]") { auto configLe = LedgerTestUtils::generateValidLedgerEntryOfType(CONFIG_SETTING); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); // The config entry should already be present in ledger in starting // with vNext. REQUIRE_THROWS_AS(ltx1.erase(LedgerEntryKey(configLe)), @@ -836,7 +836,7 @@ TEST_CASE("LedgerTxn eraseWithoutLoading", "[ledgertxn]") SECTION("when key does not exist") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE_NOTHROW(ltx1.eraseWithoutLoading(key)); REQUIRE_THROWS_AS(ltx1.getDelta(), std::runtime_error); REQUIRE(ltx1.getNewestVersion(key).get() == nullptr); @@ -844,7 +844,7 @@ TEST_CASE("LedgerTxn eraseWithoutLoading", "[ledgertxn]") SECTION("when key exists in parent") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); LedgerTxn ltx2(ltx1); @@ -859,7 +859,7 @@ TEST_CASE("LedgerTxn eraseWithoutLoading", "[ledgertxn]") {CONFIG_SETTING}); le.lastModifiedLedgerSeq = 1; key = LedgerEntryKey(le); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); LedgerTxn ltx2(ltx1); @@ -966,11 +966,11 @@ testInflationWinners( auto testAtRoot = [&](Application& app) { { - LedgerTxn ltx1(app.getLedgerTxnRoot()); + LedgerTxn ltx1(app.getTestLedgerTxn()); applyLedgerTxnUpdates(ltx1, *updates.cbegin()); ltx1.commit(); } - testInflationWinners(app.getLedgerTxnRoot(), maxWinners, minBalance, + testInflationWinners(app.getTestLedgerTxn(), maxWinners, minBalance, expected, ++updates.cbegin(), updates.cend()); }; @@ -999,7 +999,7 @@ testInflationWinners( VirtualClock clock; auto app = createTestApplication(clock, getTestConfig()); - testInflationWinners(app->getLedgerTxnRoot(), maxWinners, minBalance, + testInflationWinners(app->getTestLedgerTxn(), maxWinners, minBalance, expected, updates.cbegin(), updates.cend()); } } @@ -1032,7 +1032,7 @@ TEST_CASE("LedgerTxn queryInflationWinners", "[ledgertxn]") VirtualClock clock; auto app = createTestApplication(clock, getTestConfig()); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); LedgerTxn ltx2(ltx1); REQUIRE_THROWS_AS(ltx1.queryInflationWinners(1, 1), std::runtime_error); } @@ -1042,7 +1042,7 @@ TEST_CASE("LedgerTxn queryInflationWinners", "[ledgertxn]") VirtualClock clock; auto app = createTestApplication(clock, getTestConfig()); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); ltx1.getDelta(); REQUIRE_THROWS_AS(ltx1.queryInflationWinners(1, 1), std::runtime_error); } @@ -1294,21 +1294,21 @@ TEST_CASE("LedgerTxn loadHeader", "[ledgertxn]") SECTION("fails with children") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); LedgerTxn ltx2(ltx1); REQUIRE_THROWS_AS(ltx1.loadHeader(), std::runtime_error); } SECTION("fails if sealed") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); ltx1.getDelta(); REQUIRE_THROWS_AS(ltx1.loadHeader(), std::runtime_error); } SECTION("fails if header already loaded") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); auto lhe = ltx1.loadHeader(); REQUIRE(lhe); REQUIRE_THROWS_AS(ltx1.loadHeader(), std::runtime_error); @@ -1316,7 +1316,7 @@ TEST_CASE("LedgerTxn loadHeader", "[ledgertxn]") SECTION("check after update") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); auto lhPrev = ltx1.loadHeader().current(); ltx1.loadHeader().current() = lh; @@ -1343,7 +1343,9 @@ TEST_CASE_VERSIONS("LedgerTxn load", "[ledgertxn]") { auto runTest = [&](Config::TestDbMode mode) { VirtualClock clock; - auto app = createTestApplication(clock, getTestConfig(0, mode)); + auto cfg = getTestConfig(0, mode); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; + auto app = createTestApplication(clock, cfg); SECTION("use generated entry") { @@ -1356,28 +1358,28 @@ TEST_CASE_VERSIONS("LedgerTxn load", "[ledgertxn]") for_versions_from(18, *app, [&] { SECTION("fails with children") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); LedgerTxn ltx2(ltx1); REQUIRE_THROWS_AS(ltx1.load(key), std::runtime_error); } SECTION("fails if sealed") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); ltx1.getDelta(); REQUIRE_THROWS_AS(ltx1.load(key), std::runtime_error); } SECTION("when key does not exist") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(!ltx1.load(key)); validate(ltx1, {}); } SECTION("when key exists in parent") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); LedgerTxn ltx2(ltx1); @@ -1392,7 +1394,7 @@ TEST_CASE_VERSIONS("LedgerTxn load", "[ledgertxn]") SECTION("when key exists in grandparent, erased in parent") { key = LedgerEntryKey(le); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); LedgerTxn ltx2(ltx1); @@ -1405,7 +1407,7 @@ TEST_CASE_VERSIONS("LedgerTxn load", "[ledgertxn]") SECTION("check for init after child commits") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); LedgerTxn ltx2(ltx1); @@ -1417,7 +1419,7 @@ TEST_CASE_VERSIONS("LedgerTxn load", "[ledgertxn]") SECTION("create, deactivate, and load") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); auto ltxe = ltx1.create(le); ltxe.deactivate(); @@ -1432,12 +1434,13 @@ TEST_CASE_VERSIONS("LedgerTxn load", "[ledgertxn]") for_all_versions(*app, [&]() { SECTION("invalid keys") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); auto acc = txtest::getAccount("acc"); auto acc2 = txtest::getAccount("acc2"); { + // Note: These invariants are not enforced in bucketlist db. auto native = txtest::makeNativeAsset(); UNSCOPED_INFO("native asset on trustline key"); REQUIRE_THROWS_AS( @@ -1515,28 +1518,28 @@ TEST_CASE("LedgerTxn loadWithoutRecord", "[ledgertxn]") SECTION("fails with children") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); LedgerTxn ltx2(ltx1); REQUIRE_THROWS_AS(ltx1.loadWithoutRecord(key), std::runtime_error); } SECTION("fails if sealed") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); ltx1.getDelta(); REQUIRE_THROWS_AS(ltx1.loadWithoutRecord(key), std::runtime_error); } SECTION("when key does not exist") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(!ltx1.loadWithoutRecord(key)); validate(ltx1, {}); } SECTION("when key exists in parent") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); LedgerTxn ltx2(ltx1); @@ -1546,7 +1549,7 @@ TEST_CASE("LedgerTxn loadWithoutRecord", "[ledgertxn]") SECTION("when key exists in grandparent, erased in parent") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(ltx1.create(le)); LedgerTxn ltx2(ltx1); @@ -1659,11 +1662,11 @@ testAllOffers( auto testAtRoot = [&](Application& app) { { - LedgerTxn ltx1(app.getLedgerTxnRoot()); + LedgerTxn ltx1(app.getTestLedgerTxn()); applyLedgerTxnUpdates(ltx1, *updates.cbegin()); ltx1.commit(); } - testAllOffers(app.getLedgerTxnRoot(), expected, ++updates.cbegin(), + testAllOffers(app.getTestLedgerTxn(), expected, ++updates.cbegin(), updates.cend()); }; @@ -1692,7 +1695,7 @@ testAllOffers( VirtualClock clock; auto app = createTestApplication(clock, getTestConfig(0, mode)); - testAllOffers(app->getLedgerTxnRoot(), expected, updates.cbegin(), + testAllOffers(app->getTestLedgerTxn(), expected, updates.cbegin(), updates.cend()); } } @@ -1711,7 +1714,7 @@ TEST_CASE("LedgerTxn loadAllOffers", "[ledgertxn]") VirtualClock clock; auto app = createTestApplication(clock, getTestConfig(0, mode)); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); LedgerTxn ltx2(ltx1); REQUIRE_THROWS_AS(ltx1.loadAllOffers(), std::runtime_error); } @@ -1721,7 +1724,7 @@ TEST_CASE("LedgerTxn loadAllOffers", "[ledgertxn]") VirtualClock clock; auto app = createTestApplication(clock, getTestConfig(0, mode)); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); ltx1.getDelta(); REQUIRE_THROWS_AS(ltx1.loadAllOffers(), std::runtime_error); } @@ -1936,11 +1939,11 @@ testBestOffer( auto testAtRoot = [&](Application& app) { { - LedgerTxn ltx1(app.getLedgerTxnRoot()); + LedgerTxn ltx1(app.getTestLedgerTxn()); applyLedgerTxnUpdates(ltx1, *updates.cbegin()); ltx1.commit(); } - testBestOffer(app.getLedgerTxnRoot(), buying, selling, expected, + testBestOffer(app.getTestLedgerTxn(), buying, selling, expected, ++updates.cbegin(), updates.cend()); }; @@ -1969,7 +1972,7 @@ testBestOffer( VirtualClock clock; auto app = createTestApplication(clock, getTestConfig(0, mode)); - testBestOffer(app->getLedgerTxnRoot(), buying, selling, expected, + testBestOffer(app->getTestLedgerTxn(), buying, selling, expected, updates.cbegin(), updates.cend()); } } @@ -1989,7 +1992,7 @@ TEST_CASE("LedgerTxn loadBestOffer", "[ledgertxn]") VirtualClock clock; auto app = createTestApplication(clock, getTestConfig(0, mode)); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); LedgerTxn ltx2(ltx1); REQUIRE_THROWS_AS(ltx1.loadBestOffer(buying, selling), std::runtime_error); @@ -2000,7 +2003,7 @@ TEST_CASE("LedgerTxn loadBestOffer", "[ledgertxn]") VirtualClock clock; auto app = createTestApplication(clock, getTestConfig(0, mode)); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); ltx1.getDelta(); REQUIRE_THROWS_AS(ltx1.loadBestOffer(buying, selling), std::runtime_error); @@ -2011,7 +2014,7 @@ TEST_CASE("LedgerTxn loadBestOffer", "[ledgertxn]") VirtualClock clock; auto app = createTestApplication(clock, getTestConfig(0, mode)); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); auto ltxe = ltx1.create( LedgerTestUtils::generateValidLedgerEntryWithExclusions( {CONFIG_SETTING})); @@ -2168,9 +2171,10 @@ TEST_CASE("LedgerTxn loadBestOffer", "[ledgertxn]") // Enough space to store an offer, 1002 accounts (to keep a missing // account from evicting a prefetched account), and 2000 trustlines cfg.ENTRY_CACHE_SIZE = 3003; + cfg.DEPRECATED_SQL_LEDGER_STATE = true; auto app = createTestApplication(clock, cfg); - auto& root = app->getLedgerTxnRoot(); + auto& root = app->getTestLedgerTxn(); LedgerEntry offer; offer.data.type(OFFER); @@ -2318,11 +2322,11 @@ testOffersByAccountAndAsset( auto testAtRoot = [&](Application& app) { { - LedgerTxn ltx1(app.getLedgerTxnRoot()); + LedgerTxn ltx1(app.getTestLedgerTxn()); applyLedgerTxnUpdates(ltx1, *updates.cbegin()); ltx1.commit(); } - testOffersByAccountAndAsset(app.getLedgerTxnRoot(), accountID, asset, + testOffersByAccountAndAsset(app.getTestLedgerTxn(), accountID, asset, expected, ++updates.cbegin(), updates.cend()); }; @@ -2352,7 +2356,7 @@ testOffersByAccountAndAsset( VirtualClock clock; auto app = createTestApplication(clock, getTestConfig()); - testOffersByAccountAndAsset(app->getLedgerTxnRoot(), accountID, asset, + testOffersByAccountAndAsset(app->getTestLedgerTxn(), accountID, asset, expected, updates.cbegin(), updates.cend()); } } @@ -2374,7 +2378,7 @@ TEST_CASE("LedgerTxn loadOffersByAccountAndAsset", "[ledgertxn]") VirtualClock clock; auto app = createTestApplication(clock, getTestConfig()); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); LedgerTxn ltx2(ltx1); REQUIRE_THROWS_AS(ltx1.loadOffersByAccountAndAsset(a1, buying), std::runtime_error); @@ -2385,7 +2389,7 @@ TEST_CASE("LedgerTxn loadOffersByAccountAndAsset", "[ledgertxn]") VirtualClock clock; auto app = createTestApplication(clock, getTestConfig()); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); ltx1.getDelta(); REQUIRE_THROWS_AS(ltx1.loadOffersByAccountAndAsset(a1, buying), std::runtime_error); @@ -2481,13 +2485,13 @@ TEST_CASE("LedgerTxn unsealHeader", "[ledgertxn]") SECTION("fails if not sealed") { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE_THROWS_AS(ltx.unsealHeader(doNothing), std::runtime_error); } SECTION("fails if header is active") { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); std::vector init, live; std::vector dead; ltx.getAllEntries(init, live, dead); @@ -2498,7 +2502,7 @@ TEST_CASE("LedgerTxn unsealHeader", "[ledgertxn]") SECTION("deactivates header on completion") { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); std::vector init, live; std::vector dead; ltx.getAllEntries(init, live, dead); @@ -2512,7 +2516,7 @@ TEST_CASE("LedgerTxnEntry and LedgerTxnHeader move assignment", "[ledgertxn]") VirtualClock clock; auto app = createTestApplication(clock, getTestConfig()); - auto& root = app->getLedgerTxnRoot(); + auto& root = app->getTestLedgerTxn(); auto lh = root.getHeader(); LedgerEntry le1 = LedgerTestUtils::generateValidLedgerEntryWithExclusions( @@ -2611,7 +2615,7 @@ TEST_CASE("LedgerTxnRoot prefetch", "[ledgertxn]") UnorderedSet keysToPrefetch; auto app = createTestApplication(clock, cfg); - auto& root = app->getLedgerTxnRoot(); + auto& root = app->getTestLedgerTxn(); auto entries = LedgerTestUtils::generateValidLedgerEntries( cfg.ENTRY_CACHE_SIZE + 1); @@ -2692,7 +2696,7 @@ TEST_CASE("Create performance benchmark", "[!hide][createbench]") // First add some bulking entries so we're not using a // totally empty database. entries = LedgerTestUtils::generateValidLedgerEntries(n); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); for (auto e : entries) { ltx.createWithoutLoading(e); @@ -2706,7 +2710,7 @@ TEST_CASE("Create performance benchmark", "[!hide][createbench]") app->getMetrics().NewMeter({"ledger", "create", "commit"}, "entry"); while (!entries.empty()) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); for (size_t i = 0; !entries.empty() && i < batch; ++i) { if (loading) @@ -2756,7 +2760,7 @@ TEST_CASE("Erase performance benchmark", "[!hide][erasebench]") // First add some bulking entries so we're not using a // totally empty database. entries = LedgerTestUtils::generateValidLedgerEntries(n); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); for (auto e : entries) { ltx.createWithoutLoading(e); @@ -2769,7 +2773,7 @@ TEST_CASE("Erase performance benchmark", "[!hide][erasebench]") app->getMetrics().NewMeter({"ledger", "erase", "commit"}, "entry"); while (!entries.empty()) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); for (size_t i = 0; !entries.empty() && i < batch; ++i) { if (loading) @@ -2821,7 +2825,7 @@ TEST_CASE("Bulk load batch size benchmark", "[!hide][bulkbatchsizebench]") auto app = createTestApplication(clock, cfg); - auto& root = app->getLedgerTxnRoot(); + auto& root = app->getTestLedgerTxn(); auto entries = LedgerTestUtils::generateValidLedgerEntries(50000); LedgerTxn ltx(root); @@ -2931,7 +2935,7 @@ TEST_CASE("Signers performance benchmark", "[!hide][signersbench]") [&getTimeScope](Application& app, uint32_t numSigners, std::vector const& accounts) { CLOG_WARNING(Ledger, "Creating accounts"); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); { auto timer = getTimeScope(app, numSigners, "create"); for (auto const& le : accounts) @@ -2951,7 +2955,7 @@ TEST_CASE("Signers performance benchmark", "[!hide][signersbench]") [&getTimeScope](Application& app, uint32_t numSigners, std::vector const& accounts) { CLOG_WARNING(Ledger, "Reading accounts"); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); { auto timer = getTimeScope(app, numSigners, "read"); for (auto const& key : accounts) @@ -3096,7 +3100,7 @@ TEST_CASE("Load best offers benchmark", "[!hide][bestoffersbench]") auto writeEntries = [&](Application& app, std::vector const& offers) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); { CLOG_WARNING(Ledger, "Creating offers"); auto timer = getTimeScope(app, "create"); @@ -3119,7 +3123,7 @@ TEST_CASE("Load best offers benchmark", "[!hide][bestoffersbench]") auto timer = getTimeScope(app, "load"); size_t numOffers = 0; - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); while (auto le = ltx.loadBestOffer(buying, selling)) { REQUIRE(le.current() == sortedOffers[numOffers]); @@ -3132,6 +3136,7 @@ TEST_CASE("Load best offers benchmark", "[!hide][bestoffersbench]") size_t numIssuers, size_t numOffers) { VirtualClock clock; Config cfg(getTestConfig(0, mode)); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; cfg.ENTRY_CACHE_SIZE = 100000; Application::pointer app = createTestApplication(clock, cfg); @@ -3277,7 +3282,7 @@ TEST_CASE("LedgerTxn in memory order book", "[ledgertxn]") LedgerEntry le2 = generateOfferWithSameKeyAndAssets(le1); AssetPair assets{le1.data.offer().buying, le1.data.offer().selling}; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); { auto lte = ltx.create(le1); checkOrderBook(ltx, {}); @@ -3320,7 +3325,7 @@ TEST_CASE("LedgerTxn in memory order book", "[ledgertxn]") AssetPair assets{le1a.data.offer().buying, le1a.data.offer().selling}; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); { auto lte1 = ltx.create(le1a); auto lte2 = ltx.create(le2a); @@ -3395,7 +3400,7 @@ TEST_CASE("LedgerTxn in memory order book", "[ledgertxn]") le1a.data.offer().selling}; AssetPair swappedAssets{assets.selling, assets.buying}; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); { auto lte1 = ltx.create(le1a); auto lte2 = ltx.create(le2a); @@ -3442,7 +3447,7 @@ TEST_CASE("LedgerTxn in memory order book", "[ledgertxn]") AssetPair assetsB{le1b.data.offer().buying, le1b.data.offer().selling}; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); isCreate ? ltx.createWithoutLoading(le1a) : ltx.updateWithoutLoading(le1a); checkOrderBook(ltx, {{assetsA, {le1a}}}); @@ -3470,7 +3475,7 @@ TEST_CASE("LedgerTxn in memory order book", "[ledgertxn]") le1a.data.offer().selling}; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ltx.eraseWithoutLoading(LedgerEntryKey(le1a)); checkOrderBook(ltx, {}); ltx.create(le1a); @@ -3480,7 +3485,7 @@ TEST_CASE("LedgerTxn in memory order book", "[ledgertxn]") } { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); { LedgerTxn ltxChild(ltx); ltxChild.eraseWithoutLoading(LedgerEntryKey(le1a)); @@ -3498,7 +3503,7 @@ TEST_CASE("LedgerTxn in memory order book", "[ledgertxn]") AssetPair assets{le1a.data.offer().buying, le1a.data.offer().selling}; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); { auto lte = ltx.loadWithoutRecord(LedgerEntryKey(le1a)); checkOrderBook(ltx, {}); @@ -3521,7 +3526,7 @@ TEST_CASE("LedgerTxn in memory order book", "[ledgertxn]") SECTION("parent updates correctly on addChild") { OrderBook orderBook; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); std::vector entries; for (size_t i = 0; i < 20; ++i) @@ -3621,14 +3626,14 @@ TEST_CASE_VERSIONS("LedgerTxn bulk-load offers", "[ledgertxn]") LedgerTestUtils::generateValidOfferEntry().sellerID; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ltx.create(le1); ltx.commit(); } for_all_versions(*app, [&]() { - app->getLedgerTxnRoot().prefetch({lk1, lk2}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + app->getTestLedgerTxn().prefetch({lk1, lk2}); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(ltx.load(lk1)); }); }; @@ -3659,7 +3664,7 @@ TEST_CASE("Access deactivated entry", "[ledgertxn]") LedgerKey lk1 = LedgerEntryKey(le1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ltx.create(le1); ltx.commit(); } @@ -3668,7 +3673,7 @@ TEST_CASE("Access deactivated entry", "[ledgertxn]") LedgerTestUtils::generateValidLedgerEntryWithExclusions( {CONFIG_SETTING})); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); SECTION("load") { @@ -3795,14 +3800,14 @@ TEST_CASE("LedgerTxn generalized ledger entries", "[ledgertxn]") SECTION("create then load") { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(ltx.create(gle)); REQUIRE(ltx.load(gle.toKey())); } SECTION("create then commit then load") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); { LedgerTxn ltx2(ltx1); REQUIRE(ltx2.create(gle)); @@ -3813,7 +3818,7 @@ TEST_CASE("LedgerTxn generalized ledger entries", "[ledgertxn]") SECTION("create then commit then load in child") { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); { LedgerTxn ltx2(ltx1); REQUIRE(ltx2.create(gle)); @@ -3841,7 +3846,7 @@ TEST_CASE("LedgerTxn best offers cache eviction", "[ledgertxn]") // Populate the database with two offers involving the same asset pair { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); LedgerEntry le; le.data.type(OFFER); @@ -3859,7 +3864,7 @@ TEST_CASE("LedgerTxn best offers cache eviction", "[ledgertxn]") } { - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); // If the implementation involves caching, try to churn the cache { @@ -4031,13 +4036,13 @@ testPoolShareTrustLinesByAccountAndAsset( auto testAtRoot = [&](Application& app) { { - LedgerTxn ltx1(app.getLedgerTxnRoot()); + LedgerTxn ltx1(app.getTestLedgerTxn()); applyLedgerTxnUpdates(ltx1, updates.cbegin()->first); applyLedgerTxnUpdates(ltx1, updates.cbegin()->second); ltx1.commit(); } testPoolShareTrustLinesByAccountAndAsset( - app.getLedgerTxnRoot(), accountID, asset, expected, + app.getTestLedgerTxn(), accountID, asset, expected, ++updates.cbegin(), updates.cend()); }; @@ -4068,7 +4073,7 @@ testPoolShareTrustLinesByAccountAndAsset( for_versions_from(18, *app, [&] { testPoolShareTrustLinesByAccountAndAsset( - app->getLedgerTxnRoot(), accountID, asset, expected, + app->getTestLedgerTxn(), accountID, asset, expected, updates.cbegin(), updates.cend()); }); } @@ -4093,7 +4098,7 @@ TEST_CASE_VERSIONS("LedgerTxn loadPoolShareTrustLinesByAccountAndAsset", VirtualClock clock; auto app = createTestApplication(clock, getTestConfig()); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); LedgerTxn ltx2(ltx1); REQUIRE_THROWS_AS( ltx1.loadPoolShareTrustLinesByAccountAndAsset(a1, cur1), @@ -4105,7 +4110,7 @@ TEST_CASE_VERSIONS("LedgerTxn loadPoolShareTrustLinesByAccountAndAsset", VirtualClock clock; auto app = createTestApplication(clock, getTestConfig()); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); ltx1.getDelta(); REQUIRE_THROWS_AS( ltx1.loadPoolShareTrustLinesByAccountAndAsset(a1, cur1), @@ -4200,7 +4205,7 @@ TEST_CASE("InMemoryLedgerTxn simulate buckets", "[ledgertxn]") offer.price = Price{1, 1}; AbstractLedgerTxn* txnRoot = - static_cast(&app->getLedgerTxnRoot()); + static_cast(&app->getTestLedgerTxn()); txnRoot->createWithoutLoading(offerEntry); auto offers = txnRoot->getOffersByAccountAndAsset(a1, cur1); @@ -4249,7 +4254,7 @@ TEST_CASE("InMemoryLedgerTxn getOffersByAccountAndAsset", "[ledgertxn]") a2.manageOffer(0, cur1, native, Price{2, 1}, 1, MANAGE_OFFER_CREATED); a2.manageOffer(0, cur1, cur2, Price{2, 1}, 1, MANAGE_OFFER_CREATED); - auto offers = app->getLedgerTxnRoot().getOffersByAccountAndAsset(a1, cur1); + auto offers = app->getTestLedgerTxn().getOffersByAccountAndAsset(a1, cur1); REQUIRE(offers.size() == 3); for (auto const& kv : offers) @@ -4298,7 +4303,7 @@ TEST_CASE("InMemoryLedgerTxn getPoolShareTrustLinesByAccountAndAsset", a2.changeTrust(shareNative1, 10); auto poolShareTrustlines = - app->getLedgerTxnRoot().getPoolShareTrustLinesByAccountAndAsset(a1, + app->getTestLedgerTxn().getPoolShareTrustLinesByAccountAndAsset(a1, cur1); REQUIRE(poolShareTrustlines.size() == 2); @@ -4355,7 +4360,7 @@ TEST_CASE("InMemoryLedgerTxn filtering", "[ledgertxn]") LedgerEntry le = LedgerTestUtils::generateValidLedgerEntryWithExclusions( {CONFIG_SETTING}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); SECTION("1 entry") { @@ -4363,7 +4368,7 @@ TEST_CASE("InMemoryLedgerTxn filtering", "[ledgertxn]") ltx.commit(); // MAX_SEQ_NUM_TO_APPLY was filtered out on commit to InMemoryLedgerTxn - LedgerTxn ltx2(app->getLedgerTxnRoot()); + LedgerTxn ltx2(app->getTestLedgerTxn()); REQUIRE(!ltx2.load(entry.toKey())); } @@ -4373,7 +4378,7 @@ TEST_CASE("InMemoryLedgerTxn filtering", "[ledgertxn]") ltx.create(entry2); ltx.commit(); - LedgerTxn ltx2(app->getLedgerTxnRoot()); + LedgerTxn ltx2(app->getTestLedgerTxn()); REQUIRE(!ltx2.load(entry.toKey())); REQUIRE(!ltx2.load(entry2.toKey())); } @@ -4385,7 +4390,7 @@ TEST_CASE("InMemoryLedgerTxn filtering", "[ledgertxn]") ltx.create(entry2); ltx.commit(); - LedgerTxn ltx1(app->getLedgerTxnRoot()); + LedgerTxn ltx1(app->getTestLedgerTxn()); REQUIRE(!ltx1.load(entry.toKey())); REQUIRE(!ltx1.load(entry2.toKey())); REQUIRE(ltx1.load(LedgerEntryKey(le))); @@ -4396,7 +4401,7 @@ TEST_CASE("InMemoryLedgerTxn filtering", "[ledgertxn]") ltx.create(le); ltx.commit(); - LedgerTxn ltx2(app->getLedgerTxnRoot()); + LedgerTxn ltx2(app->getTestLedgerTxn()); REQUIRE(ltx2.load(LedgerEntryKey(le))); } } diff --git a/src/ledger/test/LiabilitiesTests.cpp b/src/ledger/test/LiabilitiesTests.cpp index 68a2c58d97..ee4bc27b9b 100644 --- a/src/ledger/test/LiabilitiesTests.cpp +++ b/src/ledger/test/LiabilitiesTests.cpp @@ -60,7 +60,7 @@ TEST_CASE_VERSIONS("liabilities", "[ledger][liabilities]") le.data.type(ACCOUNT); le.data.account() = ae; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto acc = ltx.create(le); bool res = @@ -88,7 +88,7 @@ TEST_CASE_VERSIONS("liabilities", "[ledger][liabilities]") int32_t reserve = lm.getLastReserve(); uint32_t ledgerVersion = 0; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ledgerVersion = ltx.loadHeader().current().ledgerVersion; } @@ -132,7 +132,7 @@ TEST_CASE_VERSIONS("liabilities", "[ledger][liabilities]") le.data.type(ACCOUNT); le.data.account() = ae; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto acc = ltx.create(le); bool res = stellar::addSellingLiabilities(header, acc, @@ -308,7 +308,7 @@ TEST_CASE_VERSIONS("liabilities", "[ledger][liabilities]") le.data.type(ACCOUNT); le.data.account() = ae; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto acc = ltx.create(le); bool res = @@ -336,7 +336,7 @@ TEST_CASE_VERSIONS("liabilities", "[ledger][liabilities]") int64_t deltaLiabilities) { uint32_t ledgerVersion = 0; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ledgerVersion = ltx.loadHeader().current().ledgerVersion; } @@ -373,7 +373,7 @@ TEST_CASE_VERSIONS("liabilities", "[ledger][liabilities]") le.data.type(ACCOUNT); le.data.account() = ae; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto acc = ltx.create(le); bool res = @@ -560,7 +560,7 @@ TEST_CASE_VERSIONS("liabilities", "[ledger][liabilities]") le.data.type(TRUSTLINE); le.data.trustLine() = tl; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto trust = ltx.create(le); bool res = @@ -595,7 +595,7 @@ TEST_CASE_VERSIONS("liabilities", "[ledger][liabilities]") le.data.type(TRUSTLINE); le.data.trustLine() = tl; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto trust = ltx.create(le); bool res = stellar::addSellingLiabilities(header, trust, @@ -703,7 +703,7 @@ TEST_CASE_VERSIONS("liabilities", "[ledger][liabilities]") le.data.type(TRUSTLINE); le.data.trustLine() = tl; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto trust = ltx.create(le); bool res = @@ -738,7 +738,7 @@ TEST_CASE_VERSIONS("liabilities", "[ledger][liabilities]") le.data.type(TRUSTLINE); le.data.trustLine() = tl; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto trust = ltx.create(le); bool res = @@ -860,7 +860,7 @@ TEST_CASE_VERSIONS("balance with liabilities", "[ledger][liabilities]") le.data.type(ACCOUNT); le.data.account() = ae; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto acc = ltx.create(le); bool res = stellar::addBalance(header, acc, deltaBalance); @@ -886,7 +886,7 @@ TEST_CASE_VERSIONS("balance with liabilities", "[ledger][liabilities]") int32_t reserve = lm.getLastReserve(); uint32_t ledgerVersion = 0; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ledgerVersion = ltx.loadHeader().current().ledgerVersion; } @@ -1020,7 +1020,7 @@ TEST_CASE_VERSIONS("balance with liabilities", "[ledger][liabilities]") le.data.type(ACCOUNT); le.data.account() = ae; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto acc = ltx.create(le); @@ -1068,7 +1068,7 @@ TEST_CASE_VERSIONS("balance with liabilities", "[ledger][liabilities]") int32_t reserve = lm.getLastReserve(); uint32_t ledgerVersion = 0; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ledgerVersion = ltx.loadHeader().current().ledgerVersion; } @@ -1172,7 +1172,7 @@ TEST_CASE_VERSIONS("balance with liabilities", "[ledger][liabilities]") le.data.type(TRUSTLINE); le.data.trustLine() = tl; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto trust = ltx.create(le); bool res = stellar::addBalance(header, trust, deltaBalance); @@ -1265,7 +1265,7 @@ TEST_CASE_VERSIONS("available balance and limit", "[ledger][liabilities]") le.data.type(ACCOUNT); le.data.account() = ae; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto acc = ltx.create(le); auto availableBalance = @@ -1280,7 +1280,7 @@ TEST_CASE_VERSIONS("available balance and limit", "[ledger][liabilities]") int32_t reserve = lm.getLastReserve(); uint32_t ledgerVersion = 0; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ledgerVersion = ltx.loadHeader().current().ledgerVersion; } @@ -1365,7 +1365,7 @@ TEST_CASE_VERSIONS("available balance and limit", "[ledger][liabilities]") le.data.type(ACCOUNT); le.data.account() = ae; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto acc = ltx.create(le); auto availableLimit = @@ -1382,7 +1382,7 @@ TEST_CASE_VERSIONS("available balance and limit", "[ledger][liabilities]") int64_t initBuyingLiabilities) { uint32_t ledgerVersion = 0; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ledgerVersion = ltx.loadHeader().current().ledgerVersion; } @@ -1465,7 +1465,7 @@ TEST_CASE_VERSIONS("available balance and limit", "[ledger][liabilities]") le.data.type(TRUSTLINE); le.data.trustLine() = tl; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto trust = ltx.create(le); auto availableBalance = @@ -1511,7 +1511,7 @@ TEST_CASE_VERSIONS("available balance and limit", "[ledger][liabilities]") le.data.type(TRUSTLINE); le.data.trustLine() = tl; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto trust = ltx.create(le); auto availableLimit = @@ -1560,7 +1560,7 @@ TEST_CASE_VERSIONS("available balance and limit", "[ledger][liabilities]") le.data.type(TRUSTLINE); le.data.trustLine() = tl; - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto trust = ltx.create(le); trust.current().data.trustLine().limit = diff --git a/src/main/Application.h b/src/main/Application.h index fcdd55c417..452da18c1a 100644 --- a/src/main/Application.h +++ b/src/main/Application.h @@ -43,6 +43,7 @@ class WorkScheduler; class BanManager; class StatusManager; class AbstractLedgerTxnParent; +class AbstractLedgerTxn; class BasicWork; enum class LoadGenMode; struct GeneratedLoadConfig; @@ -301,6 +302,10 @@ class Application virtual Hash const& getNetworkID() const = 0; virtual AbstractLedgerTxnParent& getLedgerTxnRoot() = 0; +#ifdef BUILD_TESTS + virtual AbstractLedgerTxnParent& getTestLedgerTxn() = 0; + virtual void resetTestLedgerTxn() = 0; +#endif virtual void validateAndLogConfig() = 0; diff --git a/src/main/ApplicationImpl.cpp b/src/main/ApplicationImpl.cpp index 3151271578..5fe6639021 100644 --- a/src/main/ApplicationImpl.cpp +++ b/src/main/ApplicationImpl.cpp @@ -350,6 +350,9 @@ ApplicationImpl::initialize(bool createNewDB, bool forceRebuild) mConfig.BEST_OFFER_DEBUGGING_ENABLED #endif ); +#ifdef BUILD_TESTS + //mTestLedgerTxn = std::make_unique(*mLedgerTxnRoot); +#endif BucketListIsConsistentWithDatabase::registerInvariant(*this); } @@ -1235,6 +1238,31 @@ ApplicationImpl::getLoadGenerator() } return *mLoadGenerator; } + +AbstractLedgerTxnParent& +ApplicationImpl::getTestLedgerTxn() +{ + auto cfg = getConfig(); + if (cfg.MODE_USES_IN_MEMORY_LEDGER) + { + return *mNeverCommittingLedgerTxn; + } + if (!mTestLedgerTxn) + { + mTestLedgerTxn = std::make_unique(*mLedgerTxnRoot); + } + + return *mTestLedgerTxn; +} + +void ApplicationImpl::resetTestLedgerTxn() +{ + if (mTestLedgerTxn) + { + mTestLedgerTxn->commit(); + mTestLedgerTxn.reset(); + } +} #endif void diff --git a/src/main/ApplicationImpl.h b/src/main/ApplicationImpl.h index 0229bc1f42..f52af9eb76 100644 --- a/src/main/ApplicationImpl.h +++ b/src/main/ApplicationImpl.h @@ -114,6 +114,9 @@ class ApplicationImpl : public Application virtual void generateLoad(GeneratedLoadConfig cfg) override; virtual LoadGenerator& getLoadGenerator() override; + + virtual AbstractLedgerTxnParent& getTestLedgerTxn() override; + virtual void resetTestLedgerTxn() override; #endif virtual void applyCfgCommands() override; @@ -196,6 +199,7 @@ class ApplicationImpl : public Application #ifdef BUILD_TESTS std::unique_ptr mLoadGenerator; + std::unique_ptr mTestLedgerTxn; #endif std::vector mWorkerThreads; diff --git a/src/main/CommandHandler.cpp b/src/main/CommandHandler.cpp index 30d941f435..c223c1d62b 100644 --- a/src/main/CommandHandler.cpp +++ b/src/main/CommandHandler.cpp @@ -1474,7 +1474,7 @@ CommandHandler::testAcc(std::string const& params, std::string& retStr) key = getAccount(accName->second.c_str()); } - LedgerTxn ltx(mApp.getLedgerTxnRoot(), + LedgerTxn ltx(mApp.getTestLedgerTxn(), /* shouldUpdateLastModified */ false, TransactionMode::READ_ONLY_WITHOUT_SQL_TXN); diff --git a/src/main/test/ApplicationUtilsTests.cpp b/src/main/test/ApplicationUtilsTests.cpp index 068a39a42b..887e91d1d0 100644 --- a/src/main/test/ApplicationUtilsTests.cpp +++ b/src/main/test/ApplicationUtilsTests.cpp @@ -78,7 +78,7 @@ class TemporarySQLiteDBDamager : public TemporaryFileDamager // Damage a database by bumping the root account's last-modified. VirtualClock clock; auto app = createTestApplication(clock, mConfig, /*newDB=*/false); - LedgerTxn ltx(app->getLedgerTxnRoot(), + LedgerTxn ltx(app->getTestLedgerTxn(), /*shouldUpdateLastModified=*/false); { auto rootKey = accountKey( diff --git a/src/main/test/CommandHandlerTests.cpp b/src/main/test/CommandHandlerTests.cpp index 9d45411a47..a100e0e899 100644 --- a/src/main/test/CommandHandlerTests.cpp +++ b/src/main/test/CommandHandlerTests.cpp @@ -474,14 +474,14 @@ TEST_CASE("manualclose", "[commandhandler]") submitTx(txFrame->getEnvelope(), retStr); { - LedgerTxn lookupTx(app->getLedgerTxnRoot()); + LedgerTxn lookupTx(app->getTestLedgerTxn()); auto entry = lookupTx.load(LedgerEntryKey(dle)); REQUIRE(!entry); } submitClose(noLedgerSeq, noCloseTime, retStr); - LedgerTxn lookupTx(app->getLedgerTxnRoot()); + LedgerTxn lookupTx(app->getTestLedgerTxn()); auto entry = lookupTx.load(LedgerEntryKey(dle)); REQUIRE(entry); } @@ -508,7 +508,7 @@ TEST_CASE("manualclose", "[commandhandler]") txFrame->addSignature(root); { - LedgerTxn checkLtx(app->getLedgerTxnRoot()); + LedgerTxn checkLtx(app->getTestLedgerTxn()); auto valid = txFrame->checkValid(*app, checkLtx, 0, 0, 0); REQUIRE(valid); } @@ -516,7 +516,7 @@ TEST_CASE("manualclose", "[commandhandler]") submitTx(txFrame->getEnvelope(), retStr); { - LedgerTxn lookupTx(app->getLedgerTxnRoot()); + LedgerTxn lookupTx(app->getTestLedgerTxn()); auto entry = lookupTx.load(LedgerEntryKey(dle)); REQUIRE(!entry); } @@ -526,7 +526,7 @@ TEST_CASE("manualclose", "[commandhandler]") submitClose(noLedgerSeq, std::make_optional(maxTime), retStr); - LedgerTxn lookupTx(app->getLedgerTxnRoot()); + LedgerTxn lookupTx(app->getTestLedgerTxn()); auto entry = lookupTx.load(LedgerEntryKey(dle)); REQUIRE(entry); } @@ -536,7 +536,7 @@ TEST_CASE("manualclose", "[commandhandler]") submitClose(noLedgerSeq, std::make_optional(maxTime + 1), retStr); - LedgerTxn lookupTx(app->getLedgerTxnRoot()); + LedgerTxn lookupTx(app->getTestLedgerTxn()); auto entry = lookupTx.load(LedgerEntryKey(dle)); REQUIRE(!entry); } diff --git a/src/overlay/test/FloodTests.cpp b/src/overlay/test/FloodTests.cpp index 43319e4151..afaab19156 100644 --- a/src/overlay/test/FloodTests.cpp +++ b/src/overlay/test/FloodTests.cpp @@ -55,7 +55,7 @@ TEST_CASE("Flooding", "[flood][overlay][acceptance]") { LedgerEntry gen; { - LedgerTxn ltx(app0->getLedgerTxnRoot()); + LedgerTxn ltx(app0->getTestLedgerTxn()); gen = stellar::loadAccount(ltx, root.getPublicKey()).current(); } @@ -68,7 +68,7 @@ TEST_CASE("Flooding", "[flood][overlay][acceptance]") // need to create on all nodes for (auto n : nodes) { - LedgerTxn ltx(n->getLedgerTxnRoot(), false); + LedgerTxn ltx(n->getTestLedgerTxn(), false); ltx.create(gen); ltx.commit(); } diff --git a/src/overlay/test/OverlayTests.cpp b/src/overlay/test/OverlayTests.cpp index 9f7bb749b8..fc8f54a8ac 100644 --- a/src/overlay/test/OverlayTests.cpp +++ b/src/overlay/test/OverlayTests.cpp @@ -346,7 +346,7 @@ TEST_CASE("flow control byte capacity", "[overlay][flowcontrol]") auto upgradeApp = [&](Application::pointer app, uint32 maxTxSize) { ConfigUpgradeSetFrameConstPtr res; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ConfigUpgradeSet configUpgradeSet; auto& configEntry = configUpgradeSet.updatedEntry.emplace_back(); @@ -357,7 +357,7 @@ TEST_CASE("flow control byte capacity", "[overlay][flowcontrol]") configEntry.contractBandwidth().txMaxSizeBytes = maxTxSize; configEntry.contractBandwidth().ledgerMaxTxsSizeBytes = maxTxSize * 10; - res = txtest::makeConfigUpgradeSet(ltx, configUpgradeSet); + res = txtest::makeConfigUpgradeSet(*app, ltx, configUpgradeSet); ltx.commit(); } txtest::executeUpgrade(*app, txtest::makeConfigUpgrade(*res)); diff --git a/src/simulation/test/LoadGeneratorTests.cpp b/src/simulation/test/LoadGeneratorTests.cpp index 15515a1436..5b20fd2e48 100644 --- a/src/simulation/test/LoadGeneratorTests.cpp +++ b/src/simulation/test/LoadGeneratorTests.cpp @@ -253,7 +253,7 @@ TEST_CASE("generate soroban load", "[loadgen][soroban]") ConfigUpgradeSet upgrades; { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto entry = ltx.load(upgradeLK); REQUIRE(entry); xdr::xdr_from_opaque(entry.current().data.contractData().val.bytes(), @@ -467,7 +467,7 @@ TEST_CASE("generate soroban load", "[loadgen][soroban]") auto lk = contractDataKey(contractID, txtest::makeU32(i), ContractDataDurability::PERSISTENT); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto entry = ltx.load(lk); REQUIRE(entry); uint32_t sizeBytes = diff --git a/src/test/TestAccount.cpp b/src/test/TestAccount.cpp index 3e684616f1..8148ed9538 100644 --- a/src/test/TestAccount.cpp +++ b/src/test/TestAccount.cpp @@ -33,7 +33,7 @@ TestAccount::updateSequenceNumber() { if (mSn == 0) { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); auto entry = stellar::loadAccount(ltx, getPublicKey()); if (entry) { @@ -45,7 +45,7 @@ TestAccount::updateSequenceNumber() uint32_t TestAccount::getTrustlineFlags(Asset const& asset) const { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); auto trust = ltx.load(trustlineKey(getPublicKey(), asset)); REQUIRE(trust); return trust.current().data.trustLine().flags; @@ -54,7 +54,7 @@ TestAccount::getTrustlineFlags(Asset const& asset) const int64_t TestAccount::getTrustlineBalance(Asset const& asset) const { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); auto trustLine = stellar::loadTrustLine(ltx, getPublicKey(), asset); REQUIRE(trustLine); return trustLine.getBalance(); @@ -63,7 +63,7 @@ TestAccount::getTrustlineBalance(Asset const& asset) const int64_t TestAccount::getTrustlineBalance(PoolID const& poolID) const { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); TrustLineAsset asset(ASSET_TYPE_POOL_SHARE); asset.liquidityPoolID() = poolID; auto trustLine = ltx.load(trustlineKey(getPublicKey(), asset)); @@ -74,7 +74,7 @@ TestAccount::getTrustlineBalance(PoolID const& poolID) const int64_t TestAccount::getBalance() const { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); auto entry = stellar::loadAccount(ltx, getPublicKey()); return entry.current().data.account().balance; } @@ -82,7 +82,7 @@ TestAccount::getBalance() const int64_t TestAccount::getAvailableBalance() const { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); auto entry = stellar::loadAccount(ltx, getPublicKey()); auto header = ltx.loadHeader(); @@ -92,7 +92,7 @@ TestAccount::getAvailableBalance() const uint32_t TestAccount::getNumSubEntries() const { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); auto entry = stellar::loadAccount(ltx, getPublicKey()); return entry.current().data.account().numSubEntries; } @@ -135,7 +135,7 @@ TestAccount::create(SecretKey const& secretKey, uint64_t initialBalance) std::unique_ptr destBefore; { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); auto entry = stellar::loadAccount(ltx, publicKey); if (entry) { @@ -145,11 +145,13 @@ TestAccount::create(SecretKey const& secretKey, uint64_t initialBalance) try { - applyTx(tx({createAccount(publicKey, initialBalance)}), mApp); + auto createAcc = createAccount(publicKey, initialBalance); + auto txn = tx({createAcc}); + applyTx(txn, mApp); } catch (...) { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); auto destAfter = stellar::loadAccount(ltx, publicKey); // check that the target account didn't change REQUIRE(!!destBefore == !!destAfter); @@ -161,7 +163,7 @@ TestAccount::create(SecretKey const& secretKey, uint64_t initialBalance) } { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); REQUIRE(stellar::loadAccount(ltx, publicKey)); } return TestAccount{mApp, secretKey}; @@ -178,7 +180,7 @@ TestAccount::merge(PublicKey const& into) { applyTx(tx({accountMerge(into)}), mApp); - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); REQUIRE(stellar::loadAccount(ltx, into)); REQUIRE(!stellar::loadAccount(ltx, getPublicKey())); } @@ -295,7 +297,7 @@ TestAccount::loadTrustLine(Asset const& asset) const TrustLineEntry TestAccount::loadTrustLine(TrustLineAsset const& asset) const { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); LedgerKey key(TRUSTLINE); key.trustLine().accountID = getPublicKey(); key.trustLine().asset = asset; @@ -311,7 +313,7 @@ TestAccount::hasTrustLine(Asset const& asset) const bool TestAccount::hasTrustLine(TrustLineAsset const& asset) const { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); LedgerKey key(TRUSTLINE); key.trustLine().accountID = getPublicKey(); key.trustLine().asset = asset; @@ -329,7 +331,7 @@ TestAccount::manageData(std::string const& name, DataValue* value) { applyTx(tx({txtest::manageData(name, value)}), mApp); - LedgerTxn ls(mApp.getLedgerTxnRoot()); + LedgerTxn ls(mApp.getTestLedgerTxn()); auto data = stellar::loadData(ls, getPublicKey(), name); if (value) { @@ -347,7 +349,7 @@ TestAccount::bumpSequence(SequenceNumber to) { applyTx(tx({txtest::bumpSequence(to)}), mApp, false); - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); if (protocolVersionStartsFrom(ltx.loadHeader().current().ledgerVersion, ProtocolVersion::V_19)) { @@ -378,7 +380,7 @@ TestAccount::createClaimableBalance(Asset const& asset, int64_t amount, // validate balanceID returned is what we expect REQUIRE(returnedBalanceID == getBalanceID(0)); - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); auto entry = stellar::loadClaimableBalance(ltx, returnedBalanceID); REQUIRE(entry); @@ -398,7 +400,7 @@ TestAccount::claimClaimableBalance(ClaimableBalanceID const& balanceID) { applyTx(tx({txtest::claimClaimableBalance(balanceID)}), mApp); - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); REQUIRE(!stellar::loadClaimableBalance(ltx, balanceID)); } @@ -457,7 +459,7 @@ TestAccount::pay(PublicKey const& destination, int64_t amount) { std::unique_ptr toAccount; { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); auto toAccountEntry = stellar::loadAccount(ltx, destination); toAccount = toAccountEntry @@ -481,7 +483,7 @@ TestAccount::pay(PublicKey const& destination, int64_t amount) } catch (...) { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); auto toAccountAfter = stellar::loadAccount(ltx, destination); // check that the target account didn't change REQUIRE(!!toAccount == !!toAccountAfter); @@ -494,7 +496,7 @@ TestAccount::pay(PublicKey const& destination, int64_t amount) throw; } - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); auto toAccountAfter = stellar::loadAccount(ltx, destination); REQUIRE(toAccount); REQUIRE(toAccountAfter); @@ -575,7 +577,7 @@ TestAccount::clawbackClaimableBalance(ClaimableBalanceID const& balanceID) { applyTx(tx({txtest::clawbackClaimableBalance(balanceID)}), mApp); - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); REQUIRE(!stellar::loadClaimableBalance(ltx, balanceID)); } diff --git a/src/test/TestMarket.cpp b/src/test/TestMarket.cpp index 028446e802..73d76dc607 100644 --- a/src/test/TestMarket.cpp +++ b/src/test/TestMarket.cpp @@ -250,7 +250,7 @@ void TestMarket::checkState(std::map const& offers, std::vector const& deletedOffers) { - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); for (auto const& o : offers) { auto offer = stellar::loadOffer(ltx, o.first.sellerID, o.first.offerID); diff --git a/src/test/TestUtils.cpp b/src/test/TestUtils.cpp index 3b35dd71d5..a232884807 100644 --- a/src/test/TestUtils.cpp +++ b/src/test/TestUtils.cpp @@ -202,7 +202,7 @@ modifySorobanNetworkConfig(Application& app, { return; } - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); app.getLedgerManager().updateNetworkConfig(ltx); auto& cfg = app.getLedgerManager().getMutableSorobanNetworkConfig(); modifyFn(cfg); @@ -252,7 +252,7 @@ overrideSorobanNetworkConfigForTest(Application& app) bool appProtocolVersionStartsFrom(Application& app, ProtocolVersion fromVersion) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto ledgerVersion = ltx.loadHeader().current().ledgerVersion; return protocolVersionStartsFrom(ledgerVersion, fromVersion); diff --git a/src/test/TxTests.cpp b/src/test/TxTests.cpp index f806cf5720..4ed454ade7 100644 --- a/src/test/TxTests.cpp +++ b/src/test/TxTests.cpp @@ -31,6 +31,9 @@ #include "util/XDROperators.h" #include "util/types.h" #include "xdrpp/autocheck.h" +#include "bucket/BucketManager.h" +#include "util/XDRCereal.h" +#include "xdrpp/printer.h" #include @@ -123,7 +126,7 @@ applyCheck(TransactionFramePtr tx, Application& app, bool checkSeqNum) // Close the ledger here to advance ledgerSeq closeLedger(app); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto ledgerVersion = ltx.loadHeader().current().ledgerVersion; @@ -397,7 +400,7 @@ applyTx(TransactionFramePtr const& tx, Application& app, bool checkSeqNum) checkTransaction(*tx, app); } - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto account = stellar::loadAccount(ltx, tx->getSourceID()); if (protocolVersionStartsFrom(ltx.loadHeader().current().ledgerVersion, ProtocolVersion::V_19) && @@ -420,7 +423,7 @@ validateTxResults(TransactionFramePtr const& tx, Application& app, auto checkedTx = TransactionFrameBase::makeTransactionFromWire( app.getNetworkID(), tx->getEnvelope()); { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); REQUIRE(checkedTx->checkValid(app, ltx, 0, 0, 0) == shouldValidateOk); } REQUIRE(checkedTx->getResult().result.code() == validationResult.code); @@ -453,7 +456,7 @@ checkLiquidityPool(Application& app, PoolID const& poolID, int64_t reserveA, int64_t reserveB, int64_t totalPoolShares, int64_t poolSharesTrustLineCount) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto lp = loadLiquidityPool(ltx, poolID); REQUIRE(lp); auto const& cp = lp.current().data.liquidityPool().body.constantProduct(); @@ -629,14 +632,14 @@ loadAccount(AbstractLedgerTxn& ltx, PublicKey const& k, bool mustExist) bool doesAccountExist(Application& app, PublicKey const& k) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); return (bool)stellar::loadAccountWithoutRecord(ltx, k); } xdr::xvector getAccountSigners(PublicKey const& k, Application& app) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto account = stellar::loadAccount(ltx, k); return account.current().data.account().signers; } @@ -699,7 +702,7 @@ transactionFromOperations(Application& app, SecretKey const& from, { uint32_t ledgerVersion; { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); ledgerVersion = ltx.loadHeader().current().ledgerVersion; } if (protocolVersionIsBefore(ledgerVersion, ProtocolVersion::V_13)) @@ -923,7 +926,7 @@ sorobanResourceFee(Application& app, SorobanResources const& resources, size_t txSize, uint32_t eventsSize) { releaseAssert(txSize <= INT32_MAX); - LedgerTxn ltx(app.getLedgerTxnRoot(), + LedgerTxn ltx(app.getTestLedgerTxn(), /* shouldUpdateLastModified */ true, TransactionMode::READ_ONLY_WITHOUT_SQL_TXN); auto feePair = TransactionFrame::computeSorobanResourceFee( @@ -1068,7 +1071,7 @@ applyCreateOfferHelper(Application& app, int64 offerId, SecretKey const& source, Price const& price, int64_t amount, SequenceNumber seq) { auto getIdPool = [&]() { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); return ltx.loadHeader().current().idPool; }; auto lastGeneratedID = getIdPool(); @@ -1104,11 +1107,14 @@ applyCreateOfferHelper(Application& app, int64 offerId, SecretKey const& source, case MANAGE_OFFER_CREATED: case MANAGE_OFFER_UPDATED: { - LedgerTxn ltx(app.getLedgerTxnRoot()); + REQUIRE(manageSellOfferResult.code() == ManageSellOfferResultCode::MANAGE_SELL_OFFER_SUCCESS); + LedgerTxn ltx(app.getTestLedgerTxn()); auto offer = stellar::loadOffer(ltx, source.getPublicKey(), expectedOfferID); REQUIRE(offer); auto& offerEntry = offer.current().data.offer(); + auto offerEStr = xdr::xdr_to_string(offerEntry); + auto offerRStr = xdr::xdr_to_string(offerResult.offer()); REQUIRE(offerEntry == offerResult.offer()); REQUIRE(offerEntry.price == price); REQUIRE(offerEntry.selling == selling); @@ -1117,7 +1123,7 @@ applyCreateOfferHelper(Application& app, int64 offerId, SecretKey const& source, break; case MANAGE_OFFER_DELETED: { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); REQUIRE( !stellar::loadOffer(ltx, source.getPublicKey(), expectedOfferID)); } @@ -1151,7 +1157,7 @@ applyManageBuyOffer(Application& app, int64 offerId, SecretKey const& source, ManageOfferEffect expectedEffect) { auto getIdPool = [&]() { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); return ltx.loadHeader().current().idPool; }; auto lastGeneratedID = getIdPool(); @@ -1185,7 +1191,7 @@ applyManageBuyOffer(Application& app, int64 offerId, SecretKey const& source, case MANAGE_OFFER_CREATED: case MANAGE_OFFER_UPDATED: { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto offer = stellar::loadOffer(ltx, source.getPublicKey(), expectedOfferID); REQUIRE(offer); @@ -1198,7 +1204,7 @@ applyManageBuyOffer(Application& app, int64 offerId, SecretKey const& source, break; case MANAGE_OFFER_DELETED: { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); REQUIRE( !stellar::loadOffer(ltx, source.getPublicKey(), expectedOfferID)); } @@ -1218,7 +1224,7 @@ applyCreatePassiveOffer(Application& app, SecretKey const& source, ManageOfferEffect expectedEffect) { auto getIdPool = [&]() { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); return ltx.loadHeader().current().idPool; }; auto lastGeneratedID = getIdPool(); @@ -1253,7 +1259,7 @@ applyCreatePassiveOffer(Application& app, SecretKey const& source, case MANAGE_OFFER_CREATED: case MANAGE_OFFER_UPDATED: { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto offer = stellar::loadOffer(ltx, source.getPublicKey(), expectedOfferID); REQUIRE(offer); @@ -1267,7 +1273,7 @@ applyCreatePassiveOffer(Application& app, SecretKey const& source, break; case MANAGE_OFFER_DELETED: { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); REQUIRE(!stellar::loadOffer(ltx, source.getPublicKey(), expectedOfferID)); } @@ -1798,7 +1804,7 @@ executeUpgrade(Application& app, LedgerUpgrade const& lupgrade, }; ConfigUpgradeSetFrameConstPtr -makeConfigUpgradeSet(AbstractLedgerTxn& ltx, ConfigUpgradeSet configUpgradeSet, +makeConfigUpgradeSet(Application& app, AbstractLedgerTxn& ltx, ConfigUpgradeSet configUpgradeSet, bool expireSet, ContractDataDurability type) { // Make entry for the upgrade @@ -1831,9 +1837,12 @@ makeConfigUpgradeSet(AbstractLedgerTxn& ltx, ConfigUpgradeSet configUpgradeSet, ltx.create(InternalLedgerEntry(le)); ltx.create(InternalLedgerEntry(ttl)); + std::vector entries = {le, ttl}; auto upgradeKey = ConfigUpgradeSetKey{contractID, hashOfUpgradeSet}; - return ConfigUpgradeSetFrame::makeFromKey(ltx, upgradeKey); + auto result = ConfigUpgradeSetFrame::makeFromKey(ltx, upgradeKey); + app.getBucketManager().addBatch(app, app.getLedgerManager().getLastClosedLedgerNum() + 1, ltx.loadHeader().current().ledgerVersion, entries, {}, {}); + return result; } LedgerUpgrade @@ -1919,14 +1928,14 @@ depositTradeWithdrawTest(Application& app, TestAccount& root, int depositSize, } } - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); REQUIRE(!loadLiquidityPool(ltx, pool12)); } int64_t getBalance(Application& app, AccountID const& accountID, Asset const& asset) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); if (asset.type() == ASSET_TYPE_NATIVE) { auto entry = stellar::loadAccount(ltx, accountID); diff --git a/src/test/TxTests.h b/src/test/TxTests.h index 990c394693..69c18ff515 100644 --- a/src/test/TxTests.h +++ b/src/test/TxTests.h @@ -311,8 +311,8 @@ TransactionFrameBasePtr sorobanTransactionFrameFromOpsWithTotalFee( std::optional memo = std::nullopt); ConfigUpgradeSetFrameConstPtr makeConfigUpgradeSet( - AbstractLedgerTxn& ltx, ConfigUpgradeSet configUpgradeSet, - bool expireSet = false, + Application& app, AbstractLedgerTxn& ltx, ConfigUpgradeSet configUpgradeSet, + bool expireSet = false, ContractDataDurability type = ContractDataDurability::TEMPORARY); LedgerUpgrade makeConfigUpgrade(ConfigUpgradeSetFrame const& configUpgradeSet); diff --git a/src/test/test.cpp b/src/test/test.cpp index c99192aa9b..f06898ce2f 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -310,7 +310,7 @@ getTestConfig(int instanceNumber, Config::TestDbMode mode) thisConfig.FLOW_CONTROL_SEND_MORE_BATCH_SIZE = 10; // Tests default to using SQL for ledger state - thisConfig.DEPRECATED_SQL_LEDGER_STATE = true; + thisConfig.DEPRECATED_SQL_LEDGER_STATE = false; #ifdef BEST_OFFER_DEBUGGING thisConfig.BEST_OFFER_DEBUGGING_ENABLED = true; @@ -541,7 +541,7 @@ for_versions(std::vector const& versions, Application& app, versions.end()) { { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); REQUIRE(ltx.loadHeader().current().ledgerVersion == gTestingVersion); } diff --git a/src/transactions/test/BeginSponsoringFutureReservesTests.cpp b/src/transactions/test/BeginSponsoringFutureReservesTests.cpp index 20a78900f4..d4efe83b75 100644 --- a/src/transactions/test/BeginSponsoringFutureReservesTests.cpp +++ b/src/transactions/test/BeginSponsoringFutureReservesTests.cpp @@ -49,7 +49,7 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") app->getNetworkID(), root, {root.op(beginSponsoringFutureReserves(a1))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); ltx.commit(); @@ -64,7 +64,7 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") app->getNetworkID(), root, {root.op(beginSponsoringFutureReserves(root))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); ltx.commit(); @@ -83,7 +83,7 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") root.op(beginSponsoringFutureReserves(a1))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(!tx->apply(*app, ltx, txm)); @@ -105,7 +105,7 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") app->getNetworkID(), root, {root.op(beginSponsoringFutureReserves(a1))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(!tx->apply(*app, ltx, txm)); @@ -128,7 +128,7 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1, a2}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(!tx->apply(*app, ltx, txm)); @@ -155,7 +155,7 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1, a2}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(!tx->apply(*app, ltx, txm)); @@ -179,7 +179,7 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->apply(*app, ltx, txm)); @@ -207,7 +207,7 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx1->apply(*app, ltx, txm1)); @@ -249,7 +249,7 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") closeLedger(*app, {tx}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, trustlineKey(a1, cur1), 1, &root.getPublicKey()); } @@ -264,7 +264,7 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") auto tx = transactionWithV2Precondition(*app, a1, 1, 100, cond); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->getResultCode() == txBAD_MIN_SEQ_AGE_OR_GAP); } @@ -272,7 +272,7 @@ TEST_CASE_VERSIONS("sponsor future reserves", "[tx][sponsorship]") { // this increments ledgerSeq closeLedger(*app); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->getResultCode() == txSUCCESS); } diff --git a/src/transactions/test/BumpSequenceTests.cpp b/src/transactions/test/BumpSequenceTests.cpp index 7a2a2b9e24..f7c0637782 100644 --- a/src/transactions/test/BumpSequenceTests.cpp +++ b/src/transactions/test/BumpSequenceTests.cpp @@ -88,7 +88,7 @@ TEST_CASE_VERSIONS("bump sequence", "[tx][bumpsequence]") for_versions_from(10, *app, [&]() { int64_t newSeq = 0; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto ledgerSeq = ltx.loadHeader().current().ledgerSeq + 2; newSeq = getStartingSequenceNumber(ledgerSeq) - 1; } diff --git a/src/transactions/test/ChangeTrustTests.cpp b/src/transactions/test/ChangeTrustTests.cpp index bd490776b4..329534958b 100644 --- a/src/transactions/test/ChangeTrustTests.cpp +++ b/src/transactions/test/ChangeTrustTests.cpp @@ -87,7 +87,7 @@ TEST_CASE_VERSIONS("change trust", "[tx][changetrust]") REQUIRE_THROWS_AS(root.changeTrust(idr, 99), ex_CHANGE_TRUST_NO_ISSUER); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!stellar::loadAccount(ltx, gateway)); } }); @@ -96,7 +96,7 @@ TEST_CASE_VERSIONS("change trust", "[tx][changetrust]") SECTION("trusting self") { auto validateTrustLineIsConst = [&]() { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto trustLine = stellar::loadTrustLine(ltx, gateway.getPublicKey(), idr); REQUIRE(trustLine); @@ -104,7 +104,7 @@ TEST_CASE_VERSIONS("change trust", "[tx][changetrust]") }; auto loadAccount = [&](PublicKey const& k) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto le = stellar::loadAccount(ltx, k).current(); return le.data.account(); }; @@ -292,7 +292,7 @@ TEST_CASE_VERSIONS("change trust", "[tx][changetrust]") {root.op(changeTrust(idr, 100)), root.op(changeTrust(idr, 0))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->apply(*app, ltx, txm)); @@ -303,7 +303,8 @@ TEST_CASE_VERSIONS("change trust", "[tx][changetrust]") TEST_CASE_VERSIONS("change trust pool share trustline", "[tx][changetrust][liquiditypool]") { - Config const& cfg = getTestConfig(); + auto cfg = getTestConfig(); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; VirtualClock clock; auto app = createTestApplication(clock, cfg); @@ -335,7 +336,7 @@ TEST_CASE_VERSIONS("change trust pool share trustline", SECTION("pool trustline") { auto getNumSubEntries = [&](AccountID const& accountID) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto acc = stellar::loadAccount(ltx, accountID); return acc.current().data.account().numSubEntries; }; @@ -431,7 +432,7 @@ TEST_CASE_VERSIONS("change trust pool share trustline", } { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto pool = loadLiquidityPool(ltx, poolShareTlAsset.liquidityPoolID()); REQUIRE(pool); @@ -469,7 +470,7 @@ TEST_CASE_VERSIONS("change trust pool share trustline", REQUIRE(getTrustLineEntryExtensionV2(assetATl) .liquidityPoolUseCount == 2); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto pool = loadLiquidityPool( ltx, changeTrustAssetToTrustLineAsset(poolAZ) .liquidityPoolID()); @@ -528,7 +529,7 @@ TEST_CASE_VERSIONS("change trust pool share trustline", } { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto pool = loadLiquidityPool(ltx, poolShareTlAsset.liquidityPoolID()); REQUIRE(startWithPool == (bool)pool); @@ -698,7 +699,7 @@ TEST_CASE_VERSIONS("change trust pool share trustline", acc1.op(endSponsoringFutureReserves())}, {acc1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -710,7 +711,7 @@ TEST_CASE_VERSIONS("change trust pool share trustline", auto tlAsset = changeTrustAssetToTrustLineAsset(idrUsd); REQUIRE(acc1.hasTrustLine(tlAsset)); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, trustlineKey(acc1, tlAsset), 1, &gateway.getPublicKey()); checkSponsorship(ltx, acc1, 0, nullptr, 4, 2, 0, 2); @@ -728,7 +729,7 @@ TEST_CASE_VERSIONS("change trust pool share trustline", revokeSponsorship(trustlineKey(acc1, tlAsset)))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -753,7 +754,7 @@ TEST_CASE_VERSIONS("change trust pool share trustline", gateway.op(endSponsoringFutureReserves())}, {acc2}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -777,7 +778,7 @@ TEST_CASE_VERSIONS("change trust pool share trustline", revokeSponsorship(trustlineKey(acc1, tlAsset)))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -799,7 +800,7 @@ TEST_CASE_VERSIONS("change trust pool share trustline", gateway.op(endSponsoringFutureReserves())}, {acc2}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -827,7 +828,7 @@ TEST_CASE_VERSIONS("change trust pool share trustline", app->getNetworkID(), root, {acc1.op(changeTrust(idrUsd, 0))}, {acc1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -876,7 +877,7 @@ TEST_CASE_VERSIONS("change trust pool share trustline", acc1.op(endSponsoringFutureReserves())}, {acc1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); diff --git a/src/transactions/test/ClaimableBalanceTests.cpp b/src/transactions/test/ClaimableBalanceTests.cpp index 0a81745004..71b69597ee 100644 --- a/src/transactions/test/ClaimableBalanceTests.cpp +++ b/src/transactions/test/ClaimableBalanceTests.cpp @@ -175,7 +175,7 @@ validateBalancesOnCreateAndClaim(TestAccount& createAcc, TestAccount& claimAcc, createAcc.op(endSponsoringFutureReserves())}, {createAcc}); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(app, ltx, 0, 0, 0)); REQUIRE(tx->apply(app, ltx, txm)); @@ -234,7 +234,7 @@ validateBalancesOnCreateAndClaim(TestAccount& createAcc, TestAccount& claimAcc, createAcc.op(endSponsoringFutureReserves())}, {createAcc}); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(app, ltx, 0, 0, 0)); REQUIRE(tx->apply(app, ltx, txm)); @@ -255,7 +255,7 @@ validateBalancesOnCreateAndClaim(TestAccount& createAcc, TestAccount& claimAcc, claimAcc.op(endSponsoringFutureReserves())}, {claimAcc}); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(app, ltx, 0, 0, 0)); REQUIRE(tx->apply(app, ltx, txm)); @@ -563,7 +563,7 @@ TEST_CASE_VERSIONS("claimableBalance", "[tx][claimablebalance]") uint32_t dayInSeconds = 86400; TimePoint nextCloseTime; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); // closeLedgerOn will move close time forward by a day // (86400 seconds) @@ -878,7 +878,7 @@ TEST_CASE_VERSIONS("claimableBalance", "[tx][claimablebalance]") // check that the original claimable balance still exists. // The balance created in validateBalancesOnCreateAndClaim // is the one that was claimed - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(stellar::loadClaimableBalance(ltx, balanceID)); } } @@ -1017,7 +1017,7 @@ TEST_CASE_VERSIONS("claimableBalance", "[tx][claimablebalance]") auto balanceID1 = acc1.getBalanceID(0); auto balanceID2 = acc1.getBalanceID(1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto entry1 = stellar::loadClaimableBalance(ltx, acc1.getBalanceID(0)); auto entry2 = @@ -1162,7 +1162,7 @@ TEST_CASE_VERSIONS("claimableBalance", "[tx][claimablebalance]") acc1.op(endSponsoringFutureReserves())}, {acc1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->apply(*app, ltx, txm)); @@ -1239,7 +1239,7 @@ TEST_CASE_VERSIONS("claimableBalance", "[tx][claimablebalance]") acc2.op(endSponsoringFutureReserves())}, {acc2}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -1252,7 +1252,7 @@ TEST_CASE_VERSIONS("claimableBalance", "[tx][claimablebalance]") uint32_t lastModifiedLedgerSeq; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); lastModifiedLedgerSeq = loadAccount(ltx, claimAccount.getPublicKey(), true) .current() @@ -1269,7 +1269,7 @@ TEST_CASE_VERSIONS("claimableBalance", "[tx][claimablebalance]") app->getNetworkID(), root, {claimAccount.op(claimOp)}, {claimAccount}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm2( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx2->checkValid(*app, ltx, 0, 0, 0)); @@ -1284,7 +1284,7 @@ TEST_CASE_VERSIONS("claimableBalance", "[tx][claimablebalance]") } // The op source account was loaded in the last transaction { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(lastModifiedLedgerSeq + 1 == loadAccount(ltx, claimAccount.getPublicKey(), true) .current() diff --git a/src/transactions/test/ClawbackClaimableBalanceTests.cpp b/src/transactions/test/ClawbackClaimableBalanceTests.cpp index fe9398b205..4c21096c21 100644 --- a/src/transactions/test/ClawbackClaimableBalanceTests.cpp +++ b/src/transactions/test/ClawbackClaimableBalanceTests.cpp @@ -110,7 +110,7 @@ TEST_CASE_VERSIONS("clawbackClaimableBalance", ClaimableBalanceID balanceID; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -132,7 +132,7 @@ TEST_CASE_VERSIONS("clawbackClaimableBalance", gateway.clawbackClaimableBalance(balanceID); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, account, 0, nullptr, 0, 2, 0, 0); } diff --git a/src/transactions/test/CreateAccountTests.cpp b/src/transactions/test/CreateAccountTests.cpp index e5ced29757..b18152e511 100644 --- a/src/transactions/test/CreateAccountTests.cpp +++ b/src/transactions/test/CreateAccountTests.cpp @@ -51,7 +51,7 @@ TEST_CASE_VERSIONS("create account", "[tx][createaccount]") app->getNetworkID(), root, {root.op(createAccount(key.getPublicKey(), 1))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx1->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(getCreateAccountResultCode(tx1, 0) == CREATE_ACCOUNT_MALFORMED); @@ -69,7 +69,7 @@ TEST_CASE_VERSIONS("create account", "[tx][createaccount]") app->getNetworkID(), root, {root.op(createAccount(key.getPublicKey(), 0))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx1->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(getCreateAccountResultCode(tx1, 0) == CREATE_ACCOUNT_MALFORMED); @@ -85,7 +85,7 @@ TEST_CASE_VERSIONS("create account", "[tx][createaccount]") transactionFrameFromOps(app->getNetworkID(), root, {root.op(createAccount(root, -1))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(getCreateAccountResultCode(tx, 0) == CREATE_ACCOUNT_MALFORMED); @@ -181,7 +181,7 @@ TEST_CASE_VERSIONS("create account", "[tx][createaccount]") {key}); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -190,7 +190,7 @@ TEST_CASE_VERSIONS("create account", "[tx][createaccount]") } { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, key.getPublicKey(), 1, &root.getPublicKey(), 0, 2, 0, 2); checkSponsorship(ltx, root.getPublicKey(), 0, nullptr, 0, 2, 2, diff --git a/src/transactions/test/EndSponsoringFutureReservesTests.cpp b/src/transactions/test/EndSponsoringFutureReservesTests.cpp index 6311de95f5..1dae9d989f 100644 --- a/src/transactions/test/EndSponsoringFutureReservesTests.cpp +++ b/src/transactions/test/EndSponsoringFutureReservesTests.cpp @@ -46,7 +46,7 @@ TEST_CASE_VERSIONS("confirm and clear sponsor", "[tx][sponsorship]") app->getNetworkID(), root, {root.op(endSponsoringFutureReserves())}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(getOperationResultCode(tx, 0) == opNOT_SUPPORTED); @@ -61,7 +61,7 @@ TEST_CASE_VERSIONS("confirm and clear sponsor", "[tx][sponsorship]") app->getNetworkID(), root, {root.op(endSponsoringFutureReserves())}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(!tx->apply(*app, ltx, txm)); diff --git a/src/transactions/test/FeeBumpTransactionTests.cpp b/src/transactions/test/FeeBumpTransactionTests.cpp index ad828142b4..ee9bfdd40d 100644 --- a/src/transactions/test/FeeBumpTransactionTests.cpp +++ b/src/transactions/test/FeeBumpTransactionTests.cpp @@ -79,7 +79,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") for_versions({12}, *app, [&] { auto fb = feeBump(app->getNetworkID(), root, root, root, 2 * fee, fee, 1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!fb->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(fb->getResultCode() == txNOT_SUPPORTED); }); @@ -90,7 +90,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") for_versions_from(13, *app, [&] { auto fb = feeBump(app->getNetworkID(), root, root, root, 2 * fee - 1, 1, 1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!fb->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(fb->getResultCode() == txINSUFFICIENT_FEE); REQUIRE(fb->getResult().feeCharged == 2 * fee); @@ -102,7 +102,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") for_versions_from(13, *app, [&] { auto fb = feeBump(app->getNetworkID(), root, root, root, 2 * fee + 1, 101, 1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!fb->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(fb->getResultCode() == txINSUFFICIENT_FEE); REQUIRE(fb->getResult().feeCharged == 2 * 101); @@ -115,7 +115,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") for_versions_from(13, *app, [&] { auto fb = feeBump(app->getNetworkID(), acc, root, root, 2 * fee, fee, 1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!fb->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(fb->getResultCode() == txNO_ACCOUNT); }); @@ -130,7 +130,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") fbXDR.feeBump().tx.innerTx.v1()); auto fb = TransactionFrameBase::makeTransactionFromWire( app->getNetworkID(), fbXDR); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!fb->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(fb->getResultCode() == txBAD_AUTH); }); @@ -148,7 +148,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") fbXDR.feeBump().tx.innerTx.v1()); auto fb = TransactionFrameBase::makeTransactionFromWire( app->getNetworkID(), fbXDR); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!fb->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(fb->getResultCode() == txBAD_AUTH); }); @@ -160,7 +160,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") for_versions_from(13, *app, [&] { auto fb = feeBump(app->getNetworkID(), acc, root, root, 2 * fee, fee, 1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!fb->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(fb->getResultCode() == txINSUFFICIENT_BALANCE); }); @@ -177,7 +177,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") sign(app->getNetworkID(), root, fbXDR.feeBump()); auto fb = TransactionFrameBase::makeTransactionFromWire( app->getNetworkID(), fbXDR); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!fb->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(fb->getResultCode() == txBAD_AUTH_EXTRA); }); @@ -191,7 +191,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") sign(app->getNetworkID(), acc, fbXDR.feeBump()); auto fb = TransactionFrameBase::makeTransactionFromWire( app->getNetworkID(), fbXDR); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!fb->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_FAILED); auto const& fbRes = fb->getResult(); @@ -208,7 +208,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") for_versions_from(13, *app, [&] { auto fb = feeBump(app->getNetworkID(), acc, root, root, 2 * fee, fee, -1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!fb->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_FAILED); auto const& fbRes = fb->getResult(); @@ -228,7 +228,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") for_versions_from(13, *app, [&] { auto fb = feeBump(app->getNetworkID(), acc, root, root, 2 * fee, fee, 1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(fb->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_SUCCESS); auto const& fbRes = fb->getResult(); @@ -249,7 +249,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") for_versions_from(13, *app, [&] { auto fb = feeBump(app->getNetworkID(), acc, root, root, 2 * fee, fee, 1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); fb->processFeeSeqNum(ltx, fee); auto delta = ltx.getDelta(); REQUIRE(delta.entry.size() == 1); @@ -272,12 +272,12 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = feeBump(app->getNetworkID(), acc, root, root, 2 * fee, fee, 1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(fb->checkValid(*app, ltx, 0, 0, 0)); } acc.merge(root); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); REQUIRE(fb->apply(*app, ltx, meta)); @@ -293,12 +293,12 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = feeBump(app->getNetworkID(), acc, root, root, 2 * fee, fee, 1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(fb->checkValid(*app, ltx, 0, 0, 0)); } acc.setOptions(setMasterWeight(0)); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); REQUIRE(fb->apply(*app, ltx, meta)); @@ -314,12 +314,12 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = feeBump(app->getNetworkID(), acc, root, root, 2 * fee, fee, 1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(fb->checkValid(*app, ltx, 0, 0, 0)); } acc.pay(root, 2 * fee); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); REQUIRE(fb->apply(*app, ltx, meta)); @@ -341,7 +341,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = TransactionFrameBase::makeTransactionFromWire( app->getNetworkID(), fbXDR); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(fb->checkValid(*app, ltx, 0, 0, 0)); } @@ -350,7 +350,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") applyCheck(setOptionsTx, *app); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); REQUIRE(fb->apply(*app, ltx, meta)); @@ -366,7 +366,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = feeBump(app->getNetworkID(), acc, root, acc, 2 * fee, fee, 1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(fb->checkValid(*app, ltx, 0, 0, 0)); } @@ -377,7 +377,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") applyCheck(setOptionsTx, *app); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); REQUIRE(!fb->apply(*app, ltx, meta)); @@ -397,11 +397,11 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") auto fb = feeBump(app->getNetworkID(), acc, root, acc, 2 * fee, fee, INT64_MAX); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(fb->checkValid(*app, ltx, 0, 0, 0)); } { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); REQUIRE(!fb->apply(*app, ltx, meta)); @@ -451,7 +451,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") acc.op(endSponsoringFutureReserves())}, {sponsoring}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -468,12 +468,12 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") } { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(fb->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(fb->getResultCode() == txFEE_BUMP_INNER_SUCCESS); } { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame meta( ltx.loadHeader().current().ledgerVersion); REQUIRE(fb->apply(*app, ltx, meta)); @@ -506,7 +506,7 @@ TEST_CASE_VERSIONS("fee bump transactions", "[tx][feebump]") if (isFbSignerSponsored) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, acc, 0, nullptr, 0, 2, 0, 0); checkSponsorship(ltx, sponsoring, 0, nullptr, 0, 2, 0, 0); } diff --git a/src/transactions/test/InflationTests.cpp b/src/transactions/test/InflationTests.cpp index 6175e2e2f5..5babf8340c 100644 --- a/src/transactions/test/InflationTests.cpp +++ b/src/transactions/test/InflationTests.cpp @@ -53,7 +53,7 @@ createTestAccounts(Application& app, int nbAccounts, SecretKey to = getTestAccount(i); root.create(to, bal); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto account = stellar::loadAccount(ltx, to.getPublicKey()); auto& ae = account.current().data.account(); ae.inflationDest.activate() = @@ -139,7 +139,7 @@ simulateInflation(int ledgerVersion, int nbAccounts, int64& totCoins, bigDivideOrThrow(coinsToDole, votes.at(w), totVotes, ROUND_DOWN); if (protocolVersionStartsFrom(ledgerVersion, ProtocolVersion::V_10)) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto header = ltx.loadHeader(); auto winner = stellar::loadAccount(ltx, getTestAccount(w).getPublicKey()); @@ -177,11 +177,11 @@ doInflation(Application& app, int ledgerVersion, int nbAccounts, std::function getVote, size_t expectedWinnerCount) { auto getFeePool = [&] { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); return ltx.loadHeader().current().feePool; }; auto getTotalCoins = [&] { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); return ltx.loadHeader().current().totalCoins; }; @@ -198,7 +198,7 @@ doInflation(Application& app, int ledgerVersion, int nbAccounts, } else { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto account = stellar::loadAccount(ltx, getTestAccount(i).getPublicKey()); auto const& ae = account.current().data.account(); @@ -254,7 +254,7 @@ doInflation(Application& app, int ledgerVersion, int nbAccounts, else { { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto account = stellar::loadAccount(ltx, k.getPublicKey()); auto const& ae = account.current().data.account(); REQUIRE(expectedBalances[i] == ae.balance); @@ -310,16 +310,16 @@ TEST_CASE_VERSIONS("inflation total coins", "[tx][inflation]") auto root = TestAccount::createRoot(*app); auto getFeePool = [&] { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); return ltx.loadHeader().current().feePool; }; auto getTotalCoins = [&] { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); return ltx.loadHeader().current().totalCoins; }; auto updateVersion = [&] { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ltx.loadHeader().current().ledgerVersion = cfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION; ltx.commit(); @@ -447,19 +447,19 @@ TEST_CASE_VERSIONS("inflation", "[tx][inflation]") auto root = TestAccount::createRoot(*app); auto getFeePool = [&] { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); return ltx.loadHeader().current().feePool; }; auto getInflationSeq = [&] { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); return ltx.loadHeader().current().inflationSeq; }; auto getLedgerVersion = [&] { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); return ltx.loadHeader().current().ledgerVersion; }; auto getTotalCoins = [&] { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); return ltx.loadHeader().current().totalCoins; }; diff --git a/src/transactions/test/InvokeHostFunctionTests.cpp b/src/transactions/test/InvokeHostFunctionTests.cpp index 2c1e6caf10..96d1f9c347 100644 --- a/src/transactions/test/InvokeHostFunctionTests.cpp +++ b/src/transactions/test/InvokeHostFunctionTests.cpp @@ -47,7 +47,7 @@ namespace void overrideNetworkSettingsToMin(Application& app) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); ltx.load(configSettingKey( ConfigSettingID::CONFIG_SETTING_CONTRACT_MAX_SIZE_BYTES)) @@ -181,7 +181,7 @@ TEST_CASE("Trustline stellar asset contract", } { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto tlAsset = assetToTrustLineAsset(idr); checkSponsorship(ltx, trustlineKey(acc, tlAsset), 1, &sponsor.getPublicKey()); @@ -277,7 +277,7 @@ TEST_CASE("Trustline stellar asset contract", // Make sure sponsorship info hasn't changed { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto tlAsset = assetToTrustLineAsset(idr); checkSponsorship(ltx, trustlineKey(acc, tlAsset), 1, &sponsor.getPublicKey()); @@ -311,7 +311,7 @@ TEST_CASE("Native stellar asset contract", REQUIRE(test.invokeTx(tx)); { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); checkSponsorship(ltx, a1.getPublicKey(), 1, &root.getPublicKey(), 0, 2, 0, 2); checkSponsorship(ltx, root.getPublicKey(), 0, nullptr, 0, 2, 2, 0); @@ -378,7 +378,7 @@ TEST_CASE("Native stellar asset contract", // Make sure sponsorship info hasn't changed { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); checkSponsorship(ltx, a1.getPublicKey(), 1, &root.getPublicKey(), 0, 2, 0, 2); checkSponsorship(ltx, root.getPublicKey(), 0, nullptr, 0, 2, 2, 0); @@ -387,7 +387,9 @@ TEST_CASE("Native stellar asset contract", TEST_CASE("basic contract invocation", "[tx][soroban]") { - SorobanTest test; + Config cfg = getTestConfig(); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; + SorobanTest test(cfg); TestContract& addContract = test.deployWasmContract(rust_bridge::get_test_wasm_add_i32()); auto& hostFnExecTimer = @@ -423,7 +425,7 @@ TEST_CASE("basic contract invocation", "[tx][soroban]") uint32_t const surgePricedFee = 300; REQUIRE(tx->getResult().feeCharged == baseCharged); { - LedgerTxn ltx(test.getApp().getLedgerTxnRoot()); + LedgerTxn ltx(test.getApp().getTestLedgerTxn()); tx->processFeeSeqNum(ltx, surgePricedFee); ltx.commit(); } @@ -439,7 +441,7 @@ TEST_CASE("basic contract invocation", "[tx][soroban]") REQUIRE(hostFnExecTimer.count() - timerBefore > 0); { - LedgerTxn ltx(test.getApp().getLedgerTxnRoot()); + LedgerTxn ltx(test.getApp().getTestLedgerTxn()); tx->processPostApply(test.getApp(), ltx, txm); ltx.commit(); } @@ -977,7 +979,9 @@ TEST_CASE("Soroban non-refundable resource fees are stable", "[tx][soroban]") int64_t const baseTxFee = baseHistoricalFee + baseSizeFee; uint32_t const minInclusionFee = 100; - SorobanTest test(getTestConfig(), + auto cfg = getTestConfig(); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; + SorobanTest test(cfg, /*useTestLimits=*/true, cfgModifyFn); auto makeTx = [&test](SorobanResources const& resources, uint32_t inclusionFee, int64_t resourceFee) { @@ -1503,7 +1507,7 @@ TEST_CASE("settings upgrade", "[tx][soroban][upgrades]") continue; } - LedgerTxn ltx(test.getApp().getLedgerTxnRoot()); + LedgerTxn ltx(test.getApp().getTestLedgerTxn()); auto costEntry = ltx.load(configSettingKey(static_cast(i))); updatedEntries.emplace_back( @@ -1607,7 +1611,7 @@ TEST_CASE("settings upgrade", "[tx][soroban][upgrades]") { auto costKey = configSettingKey( ConfigSettingID::CONFIG_SETTING_CONTRACT_LEDGER_COST_V0); - LedgerTxn ltx(test.getApp().getLedgerTxnRoot()); + LedgerTxn ltx(test.getApp().getTestLedgerTxn()); auto costEntry = ltx.load(costKey); REQUIRE(costEntry.current() .data.configSetting() @@ -1666,7 +1670,7 @@ TEST_CASE("loadgen Wasm executes properly", "[tx][soroban][loadgen]") for (auto const& key : keys) { - LedgerTxn ltx(test.getApp().getLedgerTxnRoot()); + LedgerTxn ltx(test.getApp().getTestLedgerTxn()); auto ltxe = ltx.load(key); REQUIRE(ltxe); auto size = xdr::xdr_size(ltxe.current()); @@ -1681,6 +1685,7 @@ TEST_CASE("complex contract", "[tx][soroban]") { auto complexTest = [&](bool enableDiagnostics) { auto cfg = getTestConfig(); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; cfg.ENABLE_SOROBAN_DIAGNOSTIC_EVENTS = enableDiagnostics; SorobanTest test(cfg); auto& contract = @@ -1989,7 +1994,7 @@ TEST_CASE("contract storage", "[tx][soroban]") auto acc = test.getRoot().create( "acc", test.getApp().getLedgerManager().getLastMinBalance(1)); auto loadAccount = [&]() { - LedgerTxn ltx(test.getApp().getLedgerTxnRoot()); + LedgerTxn ltx(test.getApp().getTestLedgerTxn()); auto ltxe = stellar::loadAccountWithoutRecord(ltx, acc); REQUIRE(ltxe); return ltxe.current(); @@ -2580,7 +2585,7 @@ TEST_CASE("temp entry eviction", "[tx][soroban]") closeLedgerOn(test.getApp(), evictionLedger, 2, 1, 2016); { - LedgerTxn ltx(test.getApp().getLedgerTxnRoot()); + LedgerTxn ltx(test.getApp().getTestLedgerTxn()); REQUIRE(!ltx.load(lk)); } @@ -2625,7 +2630,7 @@ TEST_CASE("temp entry eviction", "[tx][soroban]") REQUIRE(client.put("key", ContractDataDurability::TEMPORARY, 234) == INVOKE_HOST_FUNCTION_SUCCESS); { - LedgerTxn ltx(test.getApp().getLedgerTxnRoot()); + LedgerTxn ltx(test.getApp().getTestLedgerTxn()); REQUIRE(ltx.load(lk)); } @@ -2668,7 +2673,9 @@ TEST_CASE("temp entry eviction", "[tx][soroban]") TEST_CASE("state archival operation errors", "[tx][soroban]") { - SorobanTest test; + Config cfg = getTestConfig(); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; + SorobanTest test(cfg); ContractStorageTestClient client(test); auto const& stateArchivalSettings = test.getNetworkCfg().stateArchivalSettings(); @@ -2843,7 +2850,7 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") for (uint32_t i = 0; i < static_cast(CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW); ++i) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto entry = ltx.load(configSettingKey(static_cast(i))); @@ -3085,7 +3092,7 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") .getSorobanNetworkConfig() .getAverageBucketListSize(); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto costKey = configSettingKey( ConfigSettingID::CONFIG_SETTING_CONTRACT_LEDGER_COST_V0); @@ -3111,7 +3118,7 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") auto const& tx = TransactionFrameBase::makeTransactionFromWire( app->getNetworkID(), txEnv); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->apply(*app, ltx, txm)); @@ -3133,7 +3140,7 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") i < static_cast(CONFIG_SETTING_BUCKETLIST_SIZE_WINDOW); ++i) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto entry = ltx.load(configSettingKey(static_cast(i))); @@ -3178,7 +3185,7 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") auto const& txRevertSettings = TransactionFrameBase::makeTransactionFromWire(app->getNetworkID(), invokeRes2.first); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(txRevertSettings->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(txRevertSettings->apply(*app, ltx, txm)); @@ -3209,7 +3216,7 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") // The rest are failure tests, so flip back our cost overrides so we can // check that the initial settings haven't changed. { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto costKey = configSettingKey( ConfigSettingID::CONFIG_SETTING_CONTRACT_LEDGER_COST_V0); @@ -3239,7 +3246,7 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") SECTION("entry expired") { { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto ttl = ltx.load(getTTLKey(proposalKey)); // Expire the entry on the next ledger ttl.current().data.ttl().liveUntilLedgerSeq = lcl.header.ledgerSeq; @@ -3263,7 +3270,7 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") auto updateBytes = [&](SCVal const& bytes) { { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto entry = ltx.load(proposalKey); entry.current().data.contractData().val = bytes; ltx.commit(); @@ -4204,7 +4211,7 @@ TEST_CASE("Vm instantiation tightening", "[tx][soroban]") auto const& addContract = test.deployWasmContract(wasm); auto const& wasmHash = addContract.getKeys().front().contractCode().hash; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto ltxe = loadContractCode(ltx, wasmHash); auto const& code = ltxe.current().data.contractCode(); REQUIRE(code.ext.v() == 0); @@ -4252,7 +4259,7 @@ TEST_CASE("Vm instantiation tightening", "[tx][soroban]") checkTx(0, r, txSUCCESS); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto ltxe = loadContractCode(ltx, wasmHash); auto const& code = ltxe.current().data.contractCode(); REQUIRE(code.ext.v() == 1); @@ -4278,7 +4285,7 @@ TEST_CASE("Vm instantiation tightening", "[tx][soroban]") auto const& contract2 = test.deployWasmContract(rust_bridge::get_hostile_large_val_wasm()); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto ltxe = loadContractCode( ltx, contract2.getKeys().front().contractCode().hash); auto const& code = ltxe.current().data.contractCode(); diff --git a/src/transactions/test/LiquidityPoolDepositTests.cpp b/src/transactions/test/LiquidityPoolDepositTests.cpp index 1268042079..851211bdfc 100644 --- a/src/transactions/test/LiquidityPoolDepositTests.cpp +++ b/src/transactions/test/LiquidityPoolDepositTests.cpp @@ -17,7 +17,9 @@ using namespace stellar::txtest; TEST_CASE_VERSIONS("liquidity pool deposit", "[tx][liquiditypool]") { VirtualClock clock; - auto app = createTestApplication(clock, getTestConfig()); + auto cfg = getTestConfig(); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; + auto app = createTestApplication(clock, cfg); // set up world auto const& lm = app->getLedgerManager(); diff --git a/src/transactions/test/LiquidityPoolTradeTests.cpp b/src/transactions/test/LiquidityPoolTradeTests.cpp index d16a6f1fa3..6254fd3655 100644 --- a/src/transactions/test/LiquidityPoolTradeTests.cpp +++ b/src/transactions/test/LiquidityPoolTradeTests.cpp @@ -1069,7 +1069,7 @@ TEST_CASE_VERSIONS("liquidity pool trade", "[tx][liquiditypool]") REQUIRE(getBalance(a2, fromPoolAsset) == fromPoolBalanceBefore2 + fromPool); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto lp = loadLiquidityPool(ltx, pool); auto const& cp = lp.current().data.liquidityPool().body.constantProduct(); diff --git a/src/transactions/test/ManageBuyOfferTests.cpp b/src/transactions/test/ManageBuyOfferTests.cpp index 4fadecc11e..5e947810dc 100644 --- a/src/transactions/test/ManageBuyOfferTests.cpp +++ b/src/transactions/test/ManageBuyOfferTests.cpp @@ -371,7 +371,7 @@ TEST_CASE_VERSIONS("manage buy offer liabilities", "[tx][offers]") *app, SecretKey::pseudoRandomForTesting(), 1, {op}); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); tx->checkValid(*app, ltx, 0, 0, 0); } @@ -435,7 +435,9 @@ TEST_CASE_VERSIONS("manage buy offer exactly crosses existing offers", "[tx][offers]") { VirtualClock clock; - auto app = createTestApplication(clock, getTestConfig()); + auto cfg = getTestConfig(); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; + auto app = createTestApplication(clock, cfg); int64_t const txfee = app->getLedgerManager().getLastTxFee(); int64_t const minBalancePlusFees = @@ -468,7 +470,7 @@ TEST_CASE_VERSIONS("manage buy offer exactly crosses existing offers", a2.manageBuyOffer(0, cur2, cur1, price, amount, MANAGE_OFFER_DELETED); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!stellar::loadOffer(ltx, a1.getPublicKey(), offerID)); } }; @@ -512,7 +514,7 @@ TEST_CASE_VERSIONS( auto checkOffer = [&](AccountID const& acc, int64_t offerID, Asset const& selling, Asset const& buying, Price const& price) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto offer = stellar::loadOffer(ltx, acc, offerID); auto const& oe = offer.current().data.offer(); REQUIRE(oe.selling == selling); @@ -642,7 +644,7 @@ TEST_CASE_VERSIONS( auto checkOffer = [&](AccountID const& acc, int64_t offerID, Asset const& selling, Asset const& buying, Price const& price) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto offer = stellar::loadOffer(ltx, acc, offerID); auto const& oe = offer.current().data.offer(); REQUIRE(oe.selling == selling); @@ -652,7 +654,7 @@ TEST_CASE_VERSIONS( }; auto checkTrustLine = [&](AccountID const& acc, Asset const& asset) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto trust = stellar::loadTrustLine(ltx, acc, asset); return trust.getBalance(); }; @@ -795,7 +797,7 @@ TEST_CASE_VERSIONS( auto checkOffer = [&](AccountID const& acc, int64_t offerID, Asset const& selling, Asset const& buying, Price const& price) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto offer = stellar::loadOffer(ltx, acc, offerID); auto const& oe = offer.current().data.offer(); REQUIRE(oe.selling == selling); @@ -805,7 +807,7 @@ TEST_CASE_VERSIONS( }; auto checkTrustLine = [&](AccountID const& acc, Asset const& asset) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto trust = stellar::loadTrustLine(ltx, acc, asset); return trust.getBalance(); }; @@ -946,7 +948,7 @@ TEST_CASE_VERSIONS("manage buy offer with zero liabilities", "[tx][offers]") a2.changeTrust(cur1, 100); auto checkTrustLine = [&](AccountID const& acc, Asset const& asset) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto trust = stellar::loadTrustLine(ltx, acc, asset); return trust.getBalance(); }; diff --git a/src/transactions/test/MergeTests.cpp b/src/transactions/test/MergeTests.cpp index cf4898f937..4ad9bae812 100644 --- a/src/transactions/test/MergeTests.cpp +++ b/src/transactions/test/MergeTests.cpp @@ -35,6 +35,7 @@ using namespace stellar::txtest; TEST_CASE_VERSIONS("merge", "[tx][merge]") { Config cfg(getTestConfig()); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; VirtualClock clock; auto app = createTestApplication(clock, cfg); @@ -489,7 +490,7 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") a1.merge(b1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!stellar::loadAccount(ltx, a1.getPublicKey())); } }); @@ -507,7 +508,7 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") checkTx(1, r, txNO_ACCOUNT); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!stellar::loadAccount(ltx, a1.getPublicKey())); } @@ -595,7 +596,7 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") for_versions_from(10, *app, [&]() { SequenceNumber curStartSeqNum; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); // every operation will result in a ledger close, so take the // next bumpSequence into account @@ -634,7 +635,7 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") for_versions_from(19, *app, [&]() { SequenceNumber curStartSeqNum; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ltx.loadHeader().current().ledgerSeq += 1; curStartSeqNum = getStartingSequenceNumber(ltx.loadHeader()); } @@ -725,7 +726,7 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") acc2.merge(acc1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto account = stellar::loadAccount(ltx, acc1.getPublicKey()); auto const& ae = account.current().data.account(); @@ -753,7 +754,7 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") {sponsoringAcc}); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -780,7 +781,7 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") SECTION("into non-sponsoring account") { a1.merge(b1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, sponsoringAcc, 0, nullptr, 0, 2, 0, 0); } @@ -790,14 +791,14 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") ProtocolVersion::V_16)) { REQUIRE_THROWS(a1.merge(sponsoringAcc)); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, sponsoringAcc, 0, nullptr, 0, 2, 1, 0); } else { REQUIRE_NOTHROW(a1.merge(sponsoringAcc)); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, sponsoringAcc, 0, nullptr, 0, 2, 0, 0); } @@ -816,7 +817,7 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") {key}); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -840,7 +841,7 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") { REQUIRE_THROWS(acc1.merge(dest)); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); uint32_t numSponsoring = addSigner ? 3 : 2; checkSponsorship(ltx, sponsoringAcc.getPublicKey(), 0, @@ -850,7 +851,7 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") { REQUIRE_NOTHROW(acc1.merge(dest)); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, sponsoringAcc.getPublicKey(), 0, nullptr, 0, 2, 0, 0); } @@ -888,7 +889,7 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") b1.op(endSponsoringFutureReserves())}, {b1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -911,7 +912,7 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") {sponsoringAcc}); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -925,7 +926,7 @@ TEST_CASE_VERSIONS("merge", "[tx][merge]") REQUIRE_THROWS_AS(sponsoringAcc.merge(b1), ex_ACCOUNT_MERGE_IS_SPONSOR); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, sponsoringAcc, 0, nullptr, 0, 2, 1, 0); } diff --git a/src/transactions/test/OfferTests.cpp b/src/transactions/test/OfferTests.cpp index 53c56da49f..e25a5cfc81 100644 --- a/src/transactions/test/OfferTests.cpp +++ b/src/transactions/test/OfferTests.cpp @@ -433,7 +433,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") for_versions_from(10, *app, [&] { int64_t usdBuyingLiabilities = 0; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto trustLine = stellar::loadTrustLine(ltx, a1, usd); usdBuyingLiabilities = trustLine.getBuyingLiabilities(ltx.loadHeader()); @@ -2350,7 +2350,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") SECTION("modify offer assets with liabilities") { auto getLiabilities = [&](TestAccount& acc) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto account = stellar::loadAccount(ltx, acc.getPublicKey()); Liabilities res; if (account) @@ -2361,7 +2361,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") return res; }; auto getAssetLiabilities = [&](TestAccount& acc, Asset const& asset) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto trust = stellar::loadTrustLine(ltx, acc.getPublicKey(), asset); Liabilities res; if (trust) @@ -3005,7 +3005,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") source.op(endSponsoringFutureReserves())}, {sponsor}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->apply(*app, ltx, txm)); @@ -3030,7 +3030,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") acc.op(endSponsoringFutureReserves())}, {*sponsor}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto expOfferID = ltx.loadHeader().current().idPool + 1; TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); @@ -3114,7 +3114,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o1.sellerID, o1.offerID), 1, &b.getPublicKey()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, @@ -3136,7 +3136,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, &b.getPublicKey()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, @@ -3158,7 +3158,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, &b.getPublicKey()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, @@ -3179,7 +3179,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, &b.getPublicKey()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); @@ -3200,7 +3200,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, &b.getPublicKey()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); @@ -3221,7 +3221,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, a2, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, b, 0, nullptr, 2, 2, 0, 0); @@ -3240,7 +3240,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") {buying, selling, Price{1, 1}, 50}, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, a2, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, b, 0, nullptr, 3, 2, 0, !!sponsor); @@ -3335,7 +3335,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o1.sellerID, o1.offerID), 1, &a2.getPublicKey()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, @@ -3357,7 +3357,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, &a2.getPublicKey()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, @@ -3379,7 +3379,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, &a2.getPublicKey()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, @@ -3400,7 +3400,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, &a1.getPublicKey()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 1, 0); @@ -3421,7 +3421,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, &a1.getPublicKey()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 1, 0); @@ -3442,7 +3442,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, a2, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, b, 0, nullptr, 2, cExt, 0, 0); @@ -3461,7 +3461,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") {buying, selling, Price{1, 1}, 50}, sponsor); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, a2, 0, nullptr, 2, 2, 0, 0); int bExt = 0; @@ -3561,7 +3561,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, &c); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o1.sellerID, o1.offerID), 1, &c.getPublicKey()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, @@ -3583,7 +3583,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, &c); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, &c.getPublicKey()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, @@ -3605,7 +3605,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, &c); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, &c.getPublicKey()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, @@ -3626,7 +3626,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, &c); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, &c.getPublicKey()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); @@ -3647,7 +3647,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, &c); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, &c.getPublicKey()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); @@ -3668,7 +3668,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") OfferState::DELETED, &c); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, a2, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, b, 0, nullptr, 2, 2, 0, 0); @@ -3687,7 +3687,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") {buying, selling, Price{1, 1}, 50}, &c); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, a2, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, b, 0, nullptr, 3, 2, 0, 1); @@ -3740,7 +3740,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") a1.op(endSponsoringFutureReserves())}, {a1, a2}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto expOfferID = ltx.loadHeader().current().idPool + 1; TransactionMetaFrame txm( @@ -3757,7 +3757,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") }); // the offer should still not be sponsored - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o1.sellerID, o1.offerID), 0, nullptr); }); @@ -3785,7 +3785,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -3794,7 +3794,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") } // the offer should still not be sponsored - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o1.sellerID, o1.offerID), 0, nullptr); }); @@ -3843,7 +3843,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") uint64_t offerIdXlmUsd = 0; uint64_t offerIdIdrXlm = 0; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); offerIdUsdXlm = ltx.loadHeader().current().idPool + 1; offerIdXlmUsd = ltx.loadHeader().current().idPool + 2; offerIdIdrXlm = ltx.loadHeader().current().idPool + 3; @@ -3867,7 +3867,7 @@ TEST_CASE_VERSIONS("create offer", "[tx][offers]") issuer.denyTrust(usd, acc1, flagOp); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!loadOffer(ltx, acc1.getPublicKey(), offerIdUsdXlm)); REQUIRE(!loadOffer(ltx, acc1.getPublicKey(), offerIdXlmUsd)); REQUIRE(loadOffer(ltx, acc1.getPublicKey(), offerIdIdrXlm)); @@ -3961,7 +3961,7 @@ TEST_CASE_VERSIONS("liabilities match created offer", "[tx][offers]") Liabilities liabilities; int64_t offerAmount = 0; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto header = ltx.loadHeader(); auto entry = stellar::loadOffer(ltx, a1.getPublicKey(), offer.key.offerID); diff --git a/src/transactions/test/PathPaymentStrictSendTests.cpp b/src/transactions/test/PathPaymentStrictSendTests.cpp index e9a4a61be8..8b58eeb5d8 100644 --- a/src/transactions/test/PathPaymentStrictSendTests.cpp +++ b/src/transactions/test/PathPaymentStrictSendTests.cpp @@ -181,7 +181,7 @@ TEST_CASE_VERSIONS("pathpayment strict send", "[tx][pathpayment]") auto exchanged = [&](TestMarketOffer const& o, int64_t sold, int64_t bought) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); return o.exchanged(ltx.loadHeader().current().ledgerVersion, sold, bought); }; @@ -2103,7 +2103,7 @@ TEST_CASE_VERSIONS("pathpayment strict send", "[tx][pathpayment]") }; auto validateOffer = [&](const TestAccount& account, int64_t offerId, int64_t difference) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto offer = stellar::loadOffer(ltx, account.getPublicKey(), offerId); auto const& oe = offer.current().data.offer(); @@ -2411,7 +2411,7 @@ TEST_CASE_VERSIONS("pathpayment strict send uses all offers in a loop", auto exchanged = [&](TestMarketOffer const& o, int64_t sold, int64_t bought) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); return o.exchanged(ltx.loadHeader().current().ledgerVersion, sold, bought); }; diff --git a/src/transactions/test/PathPaymentTests.cpp b/src/transactions/test/PathPaymentTests.cpp index 4215962f4e..bd0701b60e 100644 --- a/src/transactions/test/PathPaymentTests.cpp +++ b/src/transactions/test/PathPaymentTests.cpp @@ -77,7 +77,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") auto exchanged = [&](TestMarketOffer const& o, int64_t sold, int64_t bought) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); return o.exchanged(ltx.loadHeader().current().ledgerVersion, sold, bought); }; @@ -4159,7 +4159,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") }; auto validateOffer = [&](const TestAccount& account, int64_t offerId, int64_t difference) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto offer = stellar::loadOffer(ltx, account.getPublicKey(), offerId); auto const& oe = offer.current().data.offer(); @@ -4433,7 +4433,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") source.op(endSponsoringFutureReserves())}, {sponsor}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->apply(*app, ltx, txm)); @@ -4504,7 +4504,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") {{o1, {selling, buying, Price{1, 1}, 50}}}, [&] { payor.pay(payee, buying, 50, selling, 50, {}); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o1.sellerID, o1.offerID), 1, &b.getPublicKey()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, @@ -4523,7 +4523,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") payor.pay(payee, buying, 100, selling, 100, {}); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, &b.getPublicKey()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, @@ -4543,7 +4543,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") payor.pay(payee, buying, 150, selling, 150, {}); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, &b.getPublicKey()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, @@ -4562,7 +4562,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") payor.pay(payee, buying, 200, selling, 200, {}); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, &b.getPublicKey()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); @@ -4581,7 +4581,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") payor.pay(payee, buying, 250, selling, 250, {}); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, &b.getPublicKey()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); @@ -4600,7 +4600,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") selling, 300, {}); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, a2, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, b, 0, nullptr, 2, 2, 0, 0); @@ -4687,7 +4687,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") {{o1, {selling, buying, Price{1, 1}, 50}}}, [&] { b.pay(c, buying, 50, selling, 50, {}); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o1.sellerID, o1.offerID), 1, &a2.getPublicKey()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, @@ -4706,7 +4706,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") b.pay(c, buying, 100, selling, 100, {}); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, &a2.getPublicKey()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, @@ -4724,7 +4724,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") {o2, {selling, buying, Price{1, 1}, 50}}}, [&] { b.pay(c, buying, 150, selling, 150, {}); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o2.sellerID, o2.offerID), 1, &a2.getPublicKey()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, @@ -4741,7 +4741,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") {{o1, OfferState::DELETED}, {o2, OfferState::DELETED}}, [&] { b.pay(c, buying, 200, selling, 200, {}); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, &a1.getPublicKey()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 1, 0); @@ -4758,7 +4758,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") {o3, {selling, buying, Price{1, 1}, 50}}}, [&] { b.pay(c, buying, 250, selling, 250, {}); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, offerKey(o3.sellerID, o3.offerID), 1, &a1.getPublicKey()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 1, 0); @@ -4775,7 +4775,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") {o3, OfferState::DELETED}}, [&] { b.pay(c, buying, 300, selling, 300, {}); }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, a1, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, a2, 0, nullptr, 2, 2, 0, 0); checkSponsorship(ltx, b, 0, nullptr, 2, 0, 0, 0); @@ -4825,7 +4825,7 @@ TEST_CASE_VERSIONS("pathpayment", "[tx][pathpayment]") mm.op(endSponsoringFutureReserves())}, {payor, mm}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -4853,7 +4853,7 @@ TEST_CASE_VERSIONS("path payment uses all offers in a loop", auto exchanged = [&](TestMarketOffer const& o, int64_t sold, int64_t bought) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); return o.exchanged(ltx.loadHeader().current().ledgerVersion, sold, bought); }; diff --git a/src/transactions/test/PaymentTests.cpp b/src/transactions/test/PaymentTests.cpp index 449b3ec95d..e39dceb025 100644 --- a/src/transactions/test/PaymentTests.cpp +++ b/src/transactions/test/PaymentTests.cpp @@ -76,7 +76,7 @@ TEST_CASE_VERSIONS("payment", "[tx][payment]") AccountEntry rootAcc, a1Acc; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto rootAccount = txtest::loadAccount(ltx, root); rootAcc = rootAccount.current().data.account(); auto a1Account = txtest::loadAccount(ltx, a1); @@ -187,7 +187,7 @@ TEST_CASE_VERSIONS("payment", "[tx][payment]") root.pay(a1, morePayment); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto rootAccount2 = stellar::loadAccount(ltx, root); auto rootAcc2 = rootAccount2.current().data.account(); auto a1Account2 = stellar::loadAccount(ltx, a1); @@ -210,7 +210,7 @@ TEST_CASE_VERSIONS("payment", "[tx][payment]") ex_PAYMENT_NO_DESTINATION); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto rootAccount2 = stellar::loadAccount(ltx, root); auto rootAcc2 = rootAccount2.current().data.account(); REQUIRE(rootAcc2.balance == (rootAcc.balance - txfee)); @@ -222,7 +222,7 @@ TEST_CASE_VERSIONS("payment", "[tx][payment]") { for_all_versions(*app, [&] { auto getMinBalance = [&] { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); return stellar::getMinBalance(ltx.loadHeader().current(), 0, 0, 0); }; @@ -234,7 +234,7 @@ TEST_CASE_VERSIONS("payment", "[tx][payment]") // raise the reserve uint32 addReserve = 100000; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ltx.loadHeader().current().baseReserve += addReserve; ltx.commit(); } @@ -1509,7 +1509,7 @@ TEST_CASE_VERSIONS("payment", "[tx][payment]") // Since a1 has a trustline, and there is only 1 trustline, we know // that gateway has no trustlines. - REQUIRE(app->getLedgerTxnRoot().countObjects(TRUSTLINE) == 1); + REQUIRE(app->getTestLedgerTxn().countObjects(TRUSTLINE) == 1); }); } SECTION("authorize flag") @@ -1612,7 +1612,7 @@ TEST_CASE_VERSIONS("payment", "[tx][payment]") uint32_t ledgerVersion; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); ledgerVersion = ltx.loadHeader().current().ledgerVersion; } // in ledger versions 1 and 2 each of these payment succeeds @@ -1653,7 +1653,7 @@ TEST_CASE_VERSIONS("payment", "[tx][payment]") { data.payWithoutTrustline(data.asset, 1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto account = txtest::loadAccount(ltx, sendToSelf); auto const& ae = account.current().data.account(); REQUIRE(ae.balance == minBalance3 - txfee); @@ -1692,7 +1692,7 @@ TEST_CASE_VERSIONS("payment", "[tx][payment]") data.payWithTrustLineFull(data.asset, 2000); } - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto account = txtest::loadAccount(ltx, sendToSelf); auto const& ae = account.current().data.account(); REQUIRE(ae.balance == minBalance3 - 4 * txfee); @@ -1719,7 +1719,7 @@ TEST_CASE_VERSIONS("payment", "[tx][payment]") data.payWithTrustLineFull(data.asset, 2000); } - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto account = txtest::loadAccount(ltx, sendToSelf); auto const& ae = account.current().data.account(); REQUIRE(ae.balance == minBalance3 - 4 * txfee); @@ -1746,7 +1746,7 @@ TEST_CASE_VERSIONS("payment", "[tx][payment]") data.payWithTrustLineFull(data.asset, 2000); } - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto account = txtest::loadAccount(ltx, sendToSelf); auto const& ae = account.current().data.account(); REQUIRE(ae.balance == minBalance3 - 4 * txfee); diff --git a/src/transactions/test/RevokeSponsorshipTests.cpp b/src/transactions/test/RevokeSponsorshipTests.cpp index 17cb61ee09..f96cea3913 100644 --- a/src/transactions/test/RevokeSponsorshipTests.cpp +++ b/src/transactions/test/RevokeSponsorshipTests.cpp @@ -62,7 +62,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") app->getNetworkID(), a1, {a1.op(revokeSponsorship(accountKey(a1)))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -82,7 +82,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") app->getNetworkID(), a1, {a1.op(revokeSponsorship(trustlineKey(a1, cur1)))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -103,7 +103,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") app->getNetworkID(), a1, {a1.op(revokeSponsorship(a1, signer.key))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -127,7 +127,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") revokeSponsorship(claimableBalanceKey(balanceID)))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -157,7 +157,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {root}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -181,7 +181,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {root}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -213,7 +213,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -228,7 +228,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {root}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -274,7 +274,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {root}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -304,7 +304,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {key}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -340,7 +340,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -374,7 +374,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -407,7 +407,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -456,7 +456,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {key}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -494,7 +494,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -533,7 +533,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -571,7 +571,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -617,7 +617,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -658,7 +658,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -699,7 +699,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {key}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -737,7 +737,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -773,7 +773,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -810,7 +810,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -848,7 +848,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -888,7 +888,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") app->getNetworkID(), a1, {a1.op(revokeSponsorship(trustlineKey(a1, cur1)))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -909,7 +909,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a2.manageOffer(0, native, cur1, Price{1, 1}, 10); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto offerID = ltx.loadHeader().current().idPool; // put the wrong account on the offerKey @@ -942,7 +942,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") revokeSponsorship(s1.getPublicKey(), signer.key))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -990,7 +990,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -1019,7 +1019,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") auto tx = transactionFrameFromOps(app->getNetworkID(), a2, {op}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -1102,7 +1102,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") middleOpTx1, a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -1144,7 +1144,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") middleOpTx1, a1.op(endSponsoringFutureReserves())}, {a1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm1( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(*app, ltx, 0, 0, 0)); @@ -1194,7 +1194,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") a1.op(endSponsoringFutureReserves())}, {a1, a2}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -1305,7 +1305,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") auto tx = transactionFrameFromOps( app->getNetworkID(), root, {root.op(revokeSponsorship(trustlineKey(root, Asset{})))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(getRevokeSponsorshipResultCode(tx, 0) == @@ -1320,7 +1320,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") auto tx = transactionFrameFromOps( app->getNetworkID(), root, {root.op(revokeSponsorship(trustlineKey(root, cur1)))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(getRevokeSponsorshipResultCode(tx, 0) == @@ -1336,7 +1336,7 @@ TEST_CASE_VERSIONS("update sponsorship", "[tx][sponsorship]") app->getNetworkID(), a1, {a1.op(revokeSponsorship(ledgerKey))}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(getRevokeSponsorshipResultCode(tx, 0) == diff --git a/src/transactions/test/SetOptionsTests.cpp b/src/transactions/test/SetOptionsTests.cpp index d0f2638b5a..fd38742664 100644 --- a/src/transactions/test/SetOptionsTests.cpp +++ b/src/transactions/test/SetOptionsTests.cpp @@ -147,14 +147,14 @@ TEST_CASE_VERSIONS("set options", "[tx][setoptions]") SECTION("non-account signers") { auto countSubEntriesAndSigners = [&](uint32_t expected) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto a1Account = stellar::loadAccount(ltx, a1); auto const& ae = a1Account.current().data.account(); REQUIRE(ae.numSubEntries == expected); REQUIRE(ae.signers.size() == expected); }; auto checkFirstSigner = [&](Signer const& sk) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto a1Account = stellar::loadAccount(ltx, a1); auto const& ae = a1Account.current().data.account(); REQUIRE(ae.signers.size() >= 1); @@ -355,7 +355,7 @@ TEST_CASE_VERSIONS("set options", "[tx][setoptions]") acc1.op(setOptions(setSigner(makeSigner(s2, 1))))}, {acc1.getSecretKey()}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -395,7 +395,7 @@ TEST_CASE_VERSIONS("set options", "[tx][setoptions]") {acc1.op(setOptions(setSigner(makeSigner(s3, 0))))}, {acc1.getSecretKey()}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -426,7 +426,7 @@ TEST_CASE_VERSIONS("set options", "[tx][setoptions]") return lhs.first.key < rhs.first.key; }); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto rootAcc = stellar::loadAccount(ltx, root.getPublicKey()); auto const& ae = rootAcc.current().data.account(); @@ -494,7 +494,7 @@ TEST_CASE_VERSIONS("set options", "[tx][setoptions]") auto tx = transactionFrameFromOps(app->getNetworkID(), root, ops, keys); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); diff --git a/src/transactions/test/SetTrustLineFlagsTests.cpp b/src/transactions/test/SetTrustLineFlagsTests.cpp index dec5d8b788..a852e41000 100644 --- a/src/transactions/test/SetTrustLineFlagsTests.cpp +++ b/src/transactions/test/SetTrustLineFlagsTests.cpp @@ -73,7 +73,7 @@ getBalance(TestAccount const& account, Asset const& asset) static uint32_t getNumSponsoring(Application& app, TestAccount const& account) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto ltxe = loadAccount(ltx, account.getPublicKey(), true); return getNumSponsoring(ltxe.current()); @@ -82,7 +82,7 @@ getNumSponsoring(Application& app, TestAccount const& account) static uint32_t getNumSponsored(Application& app, TestAccount const& account) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto ltxe = loadAccount(ltx, account.getPublicKey(), true); return getNumSponsored(ltxe.current()); @@ -98,14 +98,15 @@ checkNumSponsoring(Application& app, TestAccount const& account, static uint32_t getNumOffers(Application& app, TestAccount const& account, Asset const& asset) { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto s = ltx.getOffersByAccountAndAsset(account, asset).size(); return static_cast(s); } TEST_CASE_VERSIONS("set trustline flags", "[tx][settrustlineflags]") { - auto const& cfg = getTestConfig(); + auto cfg = getTestConfig(); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; VirtualClock clock; auto app = createTestApplication(clock, cfg); @@ -564,7 +565,7 @@ TEST_CASE_VERSIONS("revoke from pool", // Pool should be deleted since the last pool share // trustline was deleted { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!loadLiquidityPool(ltx, poolID)); } @@ -666,7 +667,7 @@ TEST_CASE_VERSIONS("revoke from pool", // Pool should be deleted since the last pool share // trustline was deleted { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!loadLiquidityPool(ltx, poolBtc1)); } @@ -700,7 +701,7 @@ TEST_CASE_VERSIONS("revoke from pool", // Pool should be deleted since the last pool share // trustline was deleted { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!loadLiquidityPool(ltx, pool1Usd)); } @@ -956,7 +957,7 @@ TEST_CASE_VERSIONS("revoke from pool", ex_CLAIM_CLAIMABLE_BALANCE_DOES_NOT_EXIST); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!loadLiquidityPool(ltx, pool12)); // make sure this account isn't sponsoring any claimable @@ -1147,7 +1148,7 @@ TEST_CASE_VERSIONS("revoke from pool", {acc1}); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -1157,7 +1158,7 @@ TEST_CASE_VERSIONS("revoke from pool", } { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); auto tlAsset = changeTrustAssetToTrustLineAsset(share12); checkSponsorship(ltx, @@ -1208,7 +1209,7 @@ TEST_CASE_VERSIONS("revoke from pool", changeTrustAssetToTrustLineAsset(share12))); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!loadLiquidityPool(ltx, pool12)); } }; @@ -1244,7 +1245,7 @@ TEST_CASE_VERSIONS("revoke from pool", getNumSponsored(*app, acc1) > 0; { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -1323,7 +1324,7 @@ TEST_CASE_VERSIONS("revoke from pool", root.denyTrust(cur1, acc1, flagOp); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); // verify that acc1 lost two numSubEntries and 2 // numSponsored due to the deleted sponsored pool share // trustline, while acc3 ends up with the same state due @@ -1418,7 +1419,7 @@ TEST_CASE_VERSIONS("revoke from pool", changeTrustAssetToTrustLineAsset(shareNative1))); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!loadLiquidityPool(ltx, pool12)); REQUIRE(!loadLiquidityPool(ltx, poolNative1)); @@ -1511,7 +1512,7 @@ TEST_CASE_VERSIONS("revoke from pool", acc1.op(endSponsoringFutureReserves())}, {acc1}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); @@ -1547,7 +1548,7 @@ TEST_CASE_VERSIONS("revoke from pool", // Pool should be deleted since the last pool share // trustline was deleted { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!loadLiquidityPool(ltx, poolID)); } diff --git a/src/transactions/test/SorobanTxTestUtils.cpp b/src/transactions/test/SorobanTxTestUtils.cpp index 44928b9521..e5d6a74099 100644 --- a/src/transactions/test/SorobanTxTestUtils.cpp +++ b/src/transactions/test/SorobanTxTestUtils.cpp @@ -133,7 +133,7 @@ getContractBalance(Application& app, SCAddress const& contractID, makeVecSCVal({makeSymbolSCVal("Balance"), accountVal}); balanceKey.contractData().durability = ContractDataDurability::PERSISTENT; - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto ltxe = ltx.load(balanceKey); if (!ltxe) { @@ -751,7 +751,7 @@ SorobanTest::invokeArchivalOp(TransactionFrameBasePtr tx, REQUIRE(tx->getResult().feeCharged == baseCharged); // Charge the fee. { - LedgerTxn ltx(getApp().getLedgerTxnRoot()); + LedgerTxn ltx(getApp().getTestLedgerTxn()); // Imitate surge pricing by charging at a higher rate than base // fee. tx->processFeeSeqNum(ltx, 300); @@ -770,7 +770,7 @@ SorobanTest::invokeArchivalOp(TransactionFrameBasePtr tx, TransactionMetaFrame txm(getLedgerVersion()); REQUIRE(invokeTx(tx, &txm)); { - LedgerTxn ltx(getApp().getLedgerTxnRoot()); + LedgerTxn ltx(getApp().getTestLedgerTxn()); tx->processPostApply(getApp(), ltx, txm); ltx.commit(); } @@ -798,7 +798,7 @@ SorobanTest::uploadWasm(RustBuf const& wasm, SorobanResources& uploadResources) Hash expectedWasmHash = sha256(expectedWasm); auto contractCodeLedgerKey = contractCodeKey(expectedWasmHash); { - LedgerTxn ltx(getApp().getLedgerTxnRoot()); + LedgerTxn ltx(getApp().getTestLedgerTxn()); auto ltxe = ltx.loadWithoutRecord(contractCodeLedgerKey); REQUIRE(ltxe); REQUIRE(ltxe.current().data.contractCode().code == expectedWasm); @@ -825,7 +825,7 @@ SorobanTest::createContract(ContractIDPreimage const& idPreimage, auto contractInstanceKey = makeContractInstanceKey(contractAddress); { // Verify the created instance. - LedgerTxn ltx(getApp().getLedgerTxnRoot()); + LedgerTxn ltx(getApp().getTestLedgerTxn()); auto ltxe = ltx.load(contractInstanceKey); REQUIRE(ltxe); @@ -847,7 +847,7 @@ SorobanTest::getRentFeeForExtension(xdr::xvector const& keys, { rust::Vec rustEntryRentChanges; - LedgerTxn ltx(getApp().getLedgerTxnRoot()); + LedgerTxn ltx(getApp().getTestLedgerTxn()); for (auto const& key : keys) { auto ltxe = ltx.loadWithoutRecord(key); @@ -989,7 +989,7 @@ SorobanTest::createRestoreTx(SorobanResources const& resources, uint32_t fee, bool SorobanTest::isTxValid(TransactionFrameBasePtr tx) { - LedgerTxn ltx(getApp().getLedgerTxnRoot()); + LedgerTxn ltx(getApp().getTestLedgerTxn()); auto ret = tx->checkValid(getApp(), ltx, 0, 0, 0); return ret; } @@ -1012,7 +1012,7 @@ SorobanTest::invokeTx(TransactionFrameBasePtr tx, TransactionMetaFrame* txMeta) } else { - LedgerTxn ltx(getApp().getLedgerTxnRoot()); + LedgerTxn ltx(getApp().getTestLedgerTxn()); REQUIRE(tx->checkValid(getApp(), ltx, 0, 0, 0)); bool res = tx->apply(getApp(), ltx, *txMeta); ltx.commit(); @@ -1023,7 +1023,7 @@ SorobanTest::invokeTx(TransactionFrameBasePtr tx, TransactionMetaFrame* txMeta) uint32_t SorobanTest::getTTL(LedgerKey const& k) { - LedgerTxn ltx(getApp().getLedgerTxnRoot()); + LedgerTxn ltx(getApp().getTestLedgerTxn()); auto ltxe = ltx.loadWithoutRecord(k); REQUIRE(ltxe); @@ -1037,7 +1037,7 @@ bool SorobanTest::isEntryLive(LedgerKey const& k, uint32_t ledgerSeq) { auto ttlKey = getTTLKey(k); - LedgerTxn ltx(getApp().getLedgerTxnRoot()); + LedgerTxn ltx(getApp().getTestLedgerTxn()); auto ttlLtxe = ltx.loadWithoutRecord(ttlKey); REQUIRE(ttlLtxe); return isLive(ttlLtxe.current(), ledgerSeq); @@ -1274,14 +1274,14 @@ AssetContractTestClient::transfer(TestAccount& fromAcc, SCAddress const& toAddr, { // From is an account so it should never have a contract data // balance - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); REQUIRE(!ltx.load(makeContractDataBalanceKey(fromVal.address()))); } if (toIsIssuer) { // make sure we didn't create an entry for the issuer - LedgerTxn ltx(mApp.getLedgerTxnRoot()); + LedgerTxn ltx(mApp.getTestLedgerTxn()); REQUIRE(!ltx.load(makeContractDataBalanceKey(toAddr))); } } diff --git a/src/transactions/test/SponsorshipTestUtils.cpp b/src/transactions/test/SponsorshipTestUtils.cpp index e9ab053758..17064d09be 100644 --- a/src/transactions/test/SponsorshipTestUtils.cpp +++ b/src/transactions/test/SponsorshipTestUtils.cpp @@ -149,7 +149,7 @@ createSponsoredEntryButSponsorHasInsufficientBalance( sponsoredAcc.op(endSponsoringFutureReserves())}, {sponsoringAcc.getSecretKey(), sponsoredAcc.getSecretKey()}); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); TransactionMetaFrame txm(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(app, ltx, 0, 0, 0)); REQUIRE(!tx->apply(app, ltx, txm)); @@ -204,7 +204,7 @@ createModifyAndRemoveSponsoredEntry(Application& app, TestAccount& sponsoredAcc, for_versions_from(ledgerVersionFrom, app, [&] { uint32_t nse; { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto ltxe = loadAccount(ltx, sponsoredAcc); nse = ltxe.current().data.account().numSubEntries; } @@ -253,7 +253,7 @@ createModifyAndRemoveSponsoredEntry(Application& app, TestAccount& sponsoredAcc, auto numReserves = getNumReservesRequiredForOperation(opCreate); { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(tx->checkValid(app, ltx, 0, 0, 0)); @@ -268,7 +268,7 @@ createModifyAndRemoveSponsoredEntry(Application& app, TestAccount& sponsoredAcc, // Modify sponsored entry { - LedgerTxn ltx2(app.getLedgerTxnRoot()); + LedgerTxn ltx2(app.getTestLedgerTxn()); TransactionMetaFrame txm2( ltx2.loadHeader().current().ledgerVersion); REQUIRE(tx2->checkValid(app, ltx2, 0, 0, 0)); @@ -283,7 +283,7 @@ createModifyAndRemoveSponsoredEntry(Application& app, TestAccount& sponsoredAcc, // Modify sponsored entry while sponsored { - LedgerTxn ltx3(app.getLedgerTxnRoot()); + LedgerTxn ltx3(app.getTestLedgerTxn()); TransactionMetaFrame txm3(2); REQUIRE(tx3->checkValid(app, ltx3, 0, 0, 0)); REQUIRE(tx3->apply(app, ltx3, txm3)); @@ -298,7 +298,7 @@ createModifyAndRemoveSponsoredEntry(Application& app, TestAccount& sponsoredAcc, // Remove sponsored entry { - LedgerTxn ltx4(app.getLedgerTxnRoot()); + LedgerTxn ltx4(app.getTestLedgerTxn()); TransactionMetaFrame txm4(2); REQUIRE(tx4->checkValid(app, ltx4, 0, 0, 0)); REQUIRE(tx4->apply(app, ltx4, txm4)); @@ -396,7 +396,7 @@ submitTooManySponsoringTxs(Application& app, TestAccount& successfulOpAcc, successfulOp, successfulOpAcc.op(endSponsoringFutureReserves())}, {successfulOpAcc}); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); TransactionMetaFrame txm1(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(app, ltx, 0, 0, 0)); REQUIRE(tx1->apply(app, ltx, txm1)); @@ -410,7 +410,7 @@ submitTooManySponsoringTxs(Application& app, TestAccount& successfulOpAcc, failOpAcc.op(endSponsoringFutureReserves())}, {failOpAcc}); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); TransactionMetaFrame txm2(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx2->checkValid(app, ltx, 0, 0, 0)); REQUIRE(!tx2->apply(app, ltx, txm2)); @@ -435,7 +435,7 @@ tooManySponsoring(Application& app, TestAccount& successfulOpAcc, { for_versions_from(minVersion, app, [&] { { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto acc = stellar::loadAccount(ltx, root.getPublicKey()); auto& le = acc.current(); auto& ae = le.data.account(); @@ -457,7 +457,7 @@ tooManySponsoring(Application& app, TestAccount& successfulOpAcc, { for_versions(minVersion, 17, app, [&] { { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto acc = stellar::loadAccount(ltx, root.getPublicKey()); auto& le = acc.current(); auto& ae = le.data.account(); @@ -484,7 +484,7 @@ tooManySponsoring(Application& app, TestAccount& successfulOpAcc, { for_versions_from(18, app, [&] { { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto acc = stellar::loadAccount(ltx, root.getPublicKey()); auto& le = acc.current(); auto& ae = le.data.account(); @@ -539,7 +539,7 @@ submitTooManyNumSubEntries(Application& app, TestAccount& testAcc, auto tx1 = transactionFrameFromOps(app.getNetworkID(), testAcc, {successfulOp}, {}); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); TransactionMetaFrame txm1(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx1->checkValid(app, ltx, 0, 0, 0)); REQUIRE(tx1->apply(app, ltx, txm1)); @@ -550,7 +550,7 @@ submitTooManyNumSubEntries(Application& app, TestAccount& testAcc, auto tx2 = transactionFrameFromOps(app.getNetworkID(), testAcc, {failOp}, {}); - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); TransactionMetaFrame txm2(ltx.loadHeader().current().ledgerVersion); REQUIRE(tx2->checkValid(app, ltx, 0, 0, 0)); REQUIRE(!tx2->apply(app, ltx, txm2)); @@ -576,7 +576,7 @@ tooManySubentries(Application& app, TestAccount& testAcc, { for_versions_from(minVersion, app, [&] { { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto acc = stellar::loadAccount(ltx, testAcc.getPublicKey()); auto& le = acc.current(); @@ -595,7 +595,7 @@ tooManySubentries(Application& app, TestAccount& testAcc, { for_versions_from(18, app, [&] { { - LedgerTxn ltx(app.getLedgerTxnRoot()); + LedgerTxn ltx(app.getTestLedgerTxn()); auto acc = stellar::loadAccount(ltx, testAcc.getPublicKey()); auto& le = acc.current(); diff --git a/src/transactions/test/TxEnvelopeTests.cpp b/src/transactions/test/TxEnvelopeTests.cpp index 4e2a8ebadc..8e63ca2fae 100644 --- a/src/transactions/test/TxEnvelopeTests.cpp +++ b/src/transactions/test/TxEnvelopeTests.cpp @@ -829,7 +829,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") for_versions(3, 9, *app, [&] { setup(); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); } REQUIRE(tx->getResultCode() == txBAD_SEQ); @@ -1082,7 +1082,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") REQUIRE(getAccountSigners(a1, *app).size() == 0); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!stellar::loadAccount(ltx, b1)); } }); @@ -1432,7 +1432,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") a1.op(endSponsoringFutureReserves())}, {a1}); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(insideSignerTx->checkValid(*app, ltx, 0, @@ -1451,7 +1451,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") a1.op(endSponsoringFutureReserves())}, {a1}); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); TransactionMetaFrame txm( ltx.loadHeader().current().ledgerVersion); REQUIRE(outsideSignerTx->checkValid(*app, ltx, @@ -1463,7 +1463,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") } { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, a1.getPublicKey(), signer1.key, 2, &root.getPublicKey()); @@ -1491,7 +1491,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") if (alternative.autoRemove) { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); checkSponsorship(ltx, root.getPublicKey(), 0, nullptr, 0, 2, 2, 0); checkSponsorship(ltx, a2.getPublicKey(), 0, @@ -1678,7 +1678,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") setFullFee(tx, 1000); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); } @@ -1702,7 +1702,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") tx->addSignature(a1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); } applyCheck(tx, *app); @@ -1716,7 +1716,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") tx->addSignature(a1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); } applyCheck(tx, *app); @@ -1733,7 +1733,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") tx->addSignature(b1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); } applyCheck(tx, *app); @@ -1758,7 +1758,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") tx->addSignature(b1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); } @@ -1785,7 +1785,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") tx->addSignature(b1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); } @@ -1811,7 +1811,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") tx->addSignature(b1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); } @@ -1903,7 +1903,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") for_versions_to(9, *app, [&] { setup(); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!txFrame->checkValid(*app, ltx, 0, 0, 0)); } REQUIRE(txFrame->getResultCode() == txBAD_SEQ); @@ -1991,7 +1991,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") getSignatures(txFrame).clear(); txFrame->addSignature(root); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(txFrame->checkValid( *app, ltx, 0, lowerBound, 0) == expectSuccess); @@ -2072,7 +2072,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") txFrame->addSignature(root); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(txFrame->checkValid(*app, ltx, 0, 0, offset)); } @@ -2085,7 +2085,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") setMaxTime(txFrame, upperBoundCloseTime - 1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!txFrame->checkValid(*app, ltx, 0, 0, offset)); } @@ -2114,7 +2114,7 @@ TEST_CASE_VERSIONS("txenvelope", "[tx][envelope]") root.tx({payment(a1.getPublicKey(), paymentAmount)}); setSeqNum(txFrame, txFrame->getSeqNum() - 1); { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!txFrame->checkValid(*app, ltx, 0, 0, 0)); } @@ -2478,7 +2478,7 @@ TEST_CASE("soroban txs not allowed before protocol upgrade", auto tx = sorobanTransactionFrameFromOps(app->getNetworkID(), root, {op}, {}, SorobanResources(), 1000, 1'000'000); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txMALFORMED); } @@ -2500,7 +2500,7 @@ TEST_CASE_VERSIONS("Soroban extension for non-Soroban tx", payment.asset.type(ASSET_TYPE_NATIVE); auto tx = sorobanTransactionFrameFromOps(app->getNetworkID(), root, {op}, {}, resources, 100, 100); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); if (protocolVersionStartsFrom(app->getLedgerManager() .getLastClosedLedgerHeader() .header.ledgerVersion, @@ -2530,7 +2530,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") bool valid) { auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op0}, {}, resources, 100, 3'500'000); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0) == valid); if (!valid) { @@ -2541,7 +2541,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") SECTION("no soroban extension") { auto tx = transactionFrameFromOps(app->getNetworkID(), root, {op0}, {}); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txMALFORMED); } @@ -2609,7 +2609,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") { auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 4'000'000); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); } SECTION("limit exceeded") @@ -2618,7 +2618,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") InitialSorobanNetworkConfig::TX_MAX_SIZE_BYTES); auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 4'000'000); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txSOROBAN_INVALID); } @@ -2630,7 +2630,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = sorobanTransactionFrameFromOpsWithTotalFee( app->getNetworkID(), root, {op0}, {}, resources, 1'000, 100'000); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txSOROBAN_INVALID); } @@ -2639,7 +2639,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = sorobanTransactionFrameFromOpsWithTotalFee( app->getNetworkID(), root, {op0}, {}, resources, 1'000'099, 1'000'000); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txINSUFFICIENT_FEE); } @@ -2647,7 +2647,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") { auto tx = sorobanTransactionFrameFromOpsWithTotalFee( app->getNetworkID(), root, {op0}, {}, resources, 1'000'000, 10); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txSOROBAN_INVALID); } @@ -2656,7 +2656,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = sorobanTransactionFrameFromOpsWithTotalFee( app->getNetworkID(), root, {op0}, {}, resources, 1'000'000, std::numeric_limits::min()); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); // Negative resource fee is handled before we get to // Soroban-specific checks. @@ -2668,7 +2668,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") app->getNetworkID(), root, {op0}, {}, resources, std::numeric_limits::max(), static_cast(std::numeric_limits::max()) + 1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txSOROBAN_INVALID); } @@ -2678,7 +2678,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") app->getNetworkID(), root, {op0}, {}, resources, std::numeric_limits::max(), std::numeric_limits::max()); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txMALFORMED); } @@ -2689,7 +2689,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") std::numeric_limits::max(), static_cast(std::numeric_limits::max()) - 100); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); } SECTION("total fee exceeds uint32 after adding base fee") @@ -2699,7 +2699,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") std::numeric_limits::max(), static_cast(std::numeric_limits::max()) - 100 + 1); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); // This gets rejected due to insufficient inclusion fee, so // we have the respective error code (even though the fee is @@ -2714,7 +2714,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") std::numeric_limits::max(), resourceFee); auto tx = feeBump(*app, root, innerTx, resourceFee + 200, /* useInclusionAsFullFee */ true); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); // This could work in theory (because the fee bump has enough // fee to cover the inner tx), it can't work because we still // consider the inner tx invalid due to negative inclusion fee. @@ -2729,7 +2729,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = feeBump(*app, root, innerTx, std::numeric_limits::max(), /* useInclusionAsFullFee */ true); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txMALFORMED); } @@ -2742,7 +2742,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") auto tx = feeBump(*app, root, innerTx, std::numeric_limits::max(), /* useInclusionAsFullFee */ true); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txMALFORMED); } @@ -2752,7 +2752,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") { auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op0, op0}, {}, resources, 100, 100'000); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); REQUIRE(tx->getResult().result.code() == txMALFORMED); } @@ -2767,7 +2767,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") { auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 3'500'000); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); } SECTION("over limit") @@ -2776,7 +2776,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") 1); auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 3'500'000); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); } } @@ -2800,7 +2800,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") ContractDataDurability::PERSISTENT); auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 3'500'000); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(tx->checkValid(*app, ltx, 0, 0, 0)); } SECTION("read-only key over size limit") @@ -2814,7 +2814,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") }); auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 3'500'000); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); } SECTION("read-write key over size limit") @@ -2828,7 +2828,7 @@ TEST_CASE("soroban transaction validation", "[tx][envelope][soroban]") }); auto tx = sorobanTransactionFrameFromOps( app->getNetworkID(), root, {op}, {}, resources, 100, 3'500'000); - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); REQUIRE(!tx->checkValid(*app, ltx, 0, 0, 0)); } } diff --git a/src/transactions/test/TxResultsTests.cpp b/src/transactions/test/TxResultsTests.cpp index 98a9a0d3f9..f54c98f2a0 100644 --- a/src/transactions/test/TxResultsTests.cpp +++ b/src/transactions/test/TxResultsTests.cpp @@ -55,7 +55,8 @@ enum class PaymentValidity TEST_CASE_VERSIONS("txresults", "[tx][txresults]") { - auto const& cfg = getTestConfig(); + auto cfg = getTestConfig(); + cfg.DEPRECATED_SQL_LEDGER_STATE = true; VirtualClock clock; auto app = createTestApplication(clock, cfg); @@ -68,7 +69,7 @@ TEST_CASE_VERSIONS("txresults", "[tx][txresults]") closeLedgerOn(*app, 1, 1, 2016); auto getCloseTime = [&] { - LedgerTxn ltx(app->getLedgerTxnRoot()); + LedgerTxn ltx(app->getTestLedgerTxn()); return lm.getLastClosedLedgerHeader().header.scpValue.closeTime; };