Converting release_assert to exception if the ledger file cannot be opened. (#4314)

This commit is contained in:
clemahieu 2023-10-17 18:11:56 +01:00 committed by GitHub
commit 4b7f91f191
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 9 deletions

View file

@ -674,8 +674,20 @@ TEST (mdb_block_store, bad_path)
GTEST_SKIP ();
}
nano::logger_mt logger;
nano::store::lmdb::component store (logger, boost::filesystem::path ("///"), nano::dev::constants);
ASSERT_TRUE (store.init_error ());
try
{
auto path = nano::unique_path ();
{
std::ofstream stream (path.c_str ());
}
boost::filesystem::permissions (path, boost::filesystem::perms::no_perms);
nano::store::lmdb::component store (logger, path, nano::dev::constants);
}
catch (std::runtime_error &)
{
return;
}
ASSERT_TRUE (false);
}
TEST (block_store, DISABLED_already_open) // File can be shared

View file

@ -55,13 +55,8 @@ void nano::store::lmdb::env::init (bool & error_a, boost::filesystem::path const
auto status4 (mdb_env_open (environment, path_a.string ().c_str (), environment_flags, 00600));
if (status4 != 0)
{
std::cerr << "Could not open lmdb environment: " << status4;
char * error_str (mdb_strerror (status4));
if (error_str)
{
std::cerr << ", " << error_str;
}
std::cerr << std::endl;
std::string message = "Could not open lmdb environment(" + std::to_string (status4) + "): " + mdb_strerror (status4);
throw std::runtime_error (message);
}
release_assert (status4 == 0);
error_a = status4 != 0;