From bef3c0c47dcd05e633fe377fa28b2c8f3215323b Mon Sep 17 00:00:00 2001 From: DanS Date: Sun, 19 Jul 2026 12:28:04 -0500 Subject: [PATCH] fix(tests): use the per-variant config dir so the lite ctest doesn't segfault testAddressBookScope hardcoded ".config/ObsidianDragon" for its pre-scoping addressbook.json, but AddressBook::load() reads the per-variant config dir (Lite -> ObsidianDragonLite/). In a --lite build the write and read diverged, so load() found nothing, size()==0, and the following entries()[0] read out of bounds -> SIGSEGV, taking the whole suite down. Write to dragonx::util::Platform::getConfigDir() (the same path load() uses, resolved under the test's temp HOME) and guard the entries()[0] access so a non-aborting EXPECT can never SIGSEGV the suite. Verified: ctest now passes 100% in BOTH the full-node and --lite builds. Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/test_phase4.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/test_phase4.cpp b/tests/test_phase4.cpp index 1484b3d..f355501 100644 --- a/tests/test_phase4.cpp +++ b/tests/test_phase4.cpp @@ -6357,8 +6357,11 @@ void testAddressBookScope() fs::create_directories(tmp); setenv("HOME", tmp.string().c_str(), 1); - // A pre-scoping addressbook.json (no "scope" field) migrates to global on load. - fs::path cfg = tmp / ".config" / "ObsidianDragon"; + // A pre-scoping addressbook.json (no "scope" field) migrates to global on load. Write to the + // SAME per-variant config dir AddressBook::load() reads from (Lite -> ObsidianDragonLite/), + // resolved under the temp HOME set above. Hardcoding ".config/ObsidianDragon" made the lite-build + // ctest write where load() never looks -> 0 entries -> the entries()[0] below segfaulted. + fs::path cfg = dragonx::util::Platform::getConfigDir(); fs::create_directories(cfg); std::ofstream(cfg / "addressbook.json") << R"({"entries":[{"label":"Legacy","address":"zs1legacy","notes":""}]})"; @@ -6366,7 +6369,9 @@ void testAddressBookScope() AddressBook book; EXPECT_TRUE(book.load()); EXPECT_EQ(book.size(), (size_t)1); - EXPECT_TRUE(book.entries()[0].isGlobal()); // migrated -> global + // Guard the [0] access — EXPECT_EQ doesn't abort this harness, so an empty book here must not + // SIGSEGV the whole suite (it would take every later test down with it). + EXPECT_TRUE(!book.entries().empty() && book.entries()[0].isGlobal()); // migrated -> global } // Same address may be a contact in two DIFFERENT wallets, but not twice in one; and a global