From 36652af46ad56e25b62c33ff957d160e2f901e9e Mon Sep 17 00:00:00 2001 From: Functionhx <2994114386@qq.com> Date: Sat, 11 Jul 2026 16:06:30 +0800 Subject: [PATCH 1/3] Test catchup and Soroban across protocols These cases previously ran only at the current ledger protocol, leaving previous-protocol behavior uncovered. Keep Soroban-only settings and auto-restore expectations aligned with the protocol that introduced them. Signed-off-by: Functionhx <2994114386@qq.com> --- src/history/test/HistoryTests.cpp | 2 +- .../test/InvokeHostFunctionTests.cpp | 28 ++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/history/test/HistoryTests.cpp b/src/history/test/HistoryTests.cpp index a81a988d8d..cf6c585b78 100644 --- a/src/history/test/HistoryTests.cpp +++ b/src/history/test/HistoryTests.cpp @@ -1250,7 +1250,7 @@ dbModeName(Config::TestDbMode mode) } } -TEST_CASE("History catchup", "[history][catchup][acceptance]") +TEST_CASE_VERSIONS("History catchup", "[history][catchup][acceptance]") { auto runTest = [](bool skipKnownResults) { // needs REAL_TIME here, as resolve-snapshot works will fail for one of diff --git a/src/transactions/test/InvokeHostFunctionTests.cpp b/src/transactions/test/InvokeHostFunctionTests.cpp index 13166c0c8a..3b6bacd474 100644 --- a/src/transactions/test/InvokeHostFunctionTests.cpp +++ b/src/transactions/test/InvokeHostFunctionTests.cpp @@ -1101,7 +1101,7 @@ TEST_CASE("version test", "[tx][soroban]") } } -TEST_CASE("Soroban footprint validation", "[tx][soroban]") +TEST_CASE_VERSIONS("Soroban footprint validation", "[tx][soroban]") { auto appCfg = getTestConfig(); if (protocolVersionIsBefore(appCfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION, @@ -1381,7 +1381,10 @@ TEST_CASE("Soroban footprint validation", "[tx][soroban]") resources.footprint.readWrite.emplace_back(persistentKey); resources.footprint.readWrite.emplace_back(persistentKey2); resources.footprint.readWrite.emplace_back(persistentKey3); - testValidInvoke(true, std::vector{0, 2}); + testValidInvoke(protocolVersionStartsFrom( + appCfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION, + AUTO_RESTORE_PROTOCOL_VERSION), + std::vector{0, 2}); } SECTION("entry in readOnly footprint") @@ -5623,10 +5626,16 @@ TEST_CASE("autorestore with storage resize", "[tx][soroban][archival]") get-settings-upgrade-txs command to make sure the transactions have the proper resources set. */ -TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") +TEST_CASE_VERSIONS("settings upgrade command line utils", + "[tx][soroban][upgrades]") { VirtualClock clock; auto cfg = getTestConfig(0, Config::TESTDB_IN_MEMORY); + if (protocolVersionIsBefore(cfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION, + SOROBAN_PROTOCOL_VERSION)) + { + return; + } cfg.ENABLE_SOROBAN_DIAGNOSTIC_EVENTS = true; auto app = createTestApplication(clock, cfg); auto root = app->getRoot(); @@ -5683,6 +5692,12 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") LedgerTxn ltx(app->getLedgerTxnRoot()); auto entry = ltx.load(configSettingKey(type)); + // Config setting IDs introduced by later protocols do not have ledger + // entries yet. + if (!entry) + { + continue; + } // Store the initial entries before we modify the cost types below initialEntries.emplace_back(entry.current().data.configSetting()); @@ -5940,7 +5955,7 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") REQUIRE(ret == ""); auto checkSettings = [&](xdr::xvector const& entries) { - auto expectedIndex = 0; + size_t expectedIndex = 0; for (auto t : xdr::xdr_traits::enum_values()) { auto type = static_cast(t); @@ -5959,11 +5974,16 @@ TEST_CASE("settings upgrade command line utils", "[tx][soroban][upgrades]") LedgerTxn ltx(app->getLedgerTxnRoot()); auto entry = ltx.load(configSettingKey(type)); + if (!entry) + { + continue; + } REQUIRE(entry.current().data.configSetting() == entries.at(expectedIndex)); ++expectedIndex; } + REQUIRE(expectedIndex == entries.size()); }; SECTION("success") From b7f1033c60b8936a1007146485d33b030b476e50 Mon Sep 17 00:00:00 2001 From: Functionhx <2994114386@qq.com> Date: Sat, 11 Jul 2026 23:38:14 +0800 Subject: [PATCH 2/3] Convert settings upgrade and 3 autorestore tests to TEST_CASE_VERSIONS Missed in initial audit: settings upgrade sibling test and autorestore contract instance/storage resize/from another contract all test protocol-dependent Soroban behavior and need cross-version coverage with protocolVersionIsBefore guards. Signed-off-by: Functionhx <2994114386@qq.com> --- .../test/InvokeHostFunctionTests.cpp | 28 ++++++++++++++++--- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/transactions/test/InvokeHostFunctionTests.cpp b/src/transactions/test/InvokeHostFunctionTests.cpp index 3b6bacd474..762a3fa12b 100644 --- a/src/transactions/test/InvokeHostFunctionTests.cpp +++ b/src/transactions/test/InvokeHostFunctionTests.cpp @@ -2489,9 +2489,14 @@ TEST_CASE("contract errors cause transaction to fail", "[tx][soroban]") } } -TEST_CASE("settings upgrade", "[tx][soroban][upgrades]") +TEST_CASE_VERSIONS("settings upgrade", "[tx][soroban][upgrades]") { auto cfg = getTestConfig(); + if (protocolVersionIsBefore(cfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION, + SOROBAN_PROTOCOL_VERSION)) + { + return; + } cfg.ENABLE_SOROBAN_DIAGNOSTIC_EVENTS = true; SorobanTest test(cfg, /* useTestLimits*/ false); auto runTest = [&]() { @@ -5256,9 +5261,14 @@ TEST_CASE("persistent entry archival", "[tx][soroban][archival]") } } -TEST_CASE("autorestore contract instance", "[tx][soroban][archival]") +TEST_CASE_VERSIONS("autorestore contract instance", "[tx][soroban][archival]") { auto cfg = getTestConfig(); + if (protocolVersionIsBefore(cfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION, + AUTO_RESTORE_PROTOCOL_VERSION)) + { + return; + } cfg.ENABLE_SOROBAN_DIAGNOSTIC_EVENTS = true; SorobanTest test(cfg, true, [](SorobanNetworkConfig& cfg) { cfg.mStateArchivalSettings.minPersistentTTL = @@ -5457,9 +5467,14 @@ TEST_CASE("autorestore contract instance", "[tx][soroban][archival]") } } -TEST_CASE("autorestore with storage resize", "[tx][soroban][archival]") +TEST_CASE_VERSIONS("autorestore with storage resize", "[tx][soroban][archival]") { auto cfg = getTestConfig(); + if (protocolVersionIsBefore(cfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION, + AUTO_RESTORE_PROTOCOL_VERSION)) + { + return; + } cfg.ENABLE_SOROBAN_DIAGNOSTIC_EVENTS = true; SorobanTest test(cfg, true, [](SorobanNetworkConfig& cfg) { cfg.mStateArchivalSettings.minPersistentTTL = @@ -10458,9 +10473,14 @@ TEST_CASE_VERSIONS("validate return values", "[tx][soroban][parallelapply]") // Test that autorestore works when keys aren't explicitly written and // belong to another uncalled contractID. -TEST_CASE("autorestore from another contract", "[tx][soroban][archival]") +TEST_CASE_VERSIONS("autorestore from another contract", "[tx][soroban][archival]") { auto cfg = getTestConfig(); + if (protocolVersionIsBefore(cfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION, + AUTO_RESTORE_PROTOCOL_VERSION)) + { + return; + } cfg.ENABLE_SOROBAN_DIAGNOSTIC_EVENTS = true; SorobanTest test(cfg, true, [](SorobanNetworkConfig& sorobanCfg) { sorobanCfg.mStateArchivalSettings.minPersistentTTL = From eb447ac4a69cd237f72e43466f06d77176cdf408 Mon Sep 17 00:00:00 2001 From: Functionhx <2994114386@qq.com> Date: Sun, 12 Jul 2026 00:12:44 +0800 Subject: [PATCH 3/3] Add null entry guard for ConfigSettingID values introduced at V23 in settings upgrade test ConfigSettingIDs 14/15/16 (introduced at V23) have no ledger entries at protocols V20-V22, causing null-pointer dereference when the test iterates across all protocol versions. Added if (!costEntry) continue guard matching the pattern in settings upgrade command line utils. Signed-off-by: Functionhx <2994114386@qq.com> --- src/transactions/test/InvokeHostFunctionTests.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/transactions/test/InvokeHostFunctionTests.cpp b/src/transactions/test/InvokeHostFunctionTests.cpp index 762a3fa12b..b0da96a092 100644 --- a/src/transactions/test/InvokeHostFunctionTests.cpp +++ b/src/transactions/test/InvokeHostFunctionTests.cpp @@ -2555,6 +2555,10 @@ TEST_CASE_VERSIONS("settings upgrade", "[tx][soroban][upgrades]") LedgerTxn ltx(test.getApp().getLedgerTxnRoot()); auto costEntry = ltx.load(configSettingKey(type)); + if (!costEntry) + { + continue; + } updatedEntries.emplace_back( costEntry.current().data.configSetting()); }