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