From d3a9cc83ec678b58ea21e3c3f8baa0a281b6249c Mon Sep 17 00:00:00 2001 From: Nate Brune <newton@Andromeda.home> Date: Sun, 15 Jan 2017 14:12:42 -0500 Subject: [PATCH] Add test for environment check --- test/test.cpp | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/test/test.cpp b/test/test.cpp index 11417f827..27b0ff17b 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -149,11 +149,41 @@ BOOST_AUTO_TEST_CASE( lock_test ) { BOOST_TEST_MESSAGE( "Creating Databases"); chainbase::database db, db2; db.open( temp, database::read_write, 1024*1024*8 ); - BOOST_CHECK_THROW(db2.open( temp, database::read_write ), bip::interprocess_exception)3221; + BOOST_CHECK_THROW(db2.open( temp, database::read_write ), bip::interprocess_exception); } catch ( ... ) { bfs::remove_all ( temp ); throw; } } +BOOST_AUTO_TEST_CASE( schema_test ) { + boost::filesystem::path temp = boost::filesystem::unique_path(); + + try { + std::cerr << temp.native() << " \n"; + auto abs_path = bfs::absolute( temp / "shared_memory.bin" ); + BOOST_TEST_MESSAGE( "Creating Databases"); + class database2 : chainbase::database + { + public: + void ruin_segments(boost::filesystem::absolute path) { + _segment.reset( new bip::managed_mapped_file( bip::create_only, + path.generic_string().c_str(), shared_file_size + ) ); + } + }; + + database2 db; + db.open( temp, database::read_write, 1024*1024*8 ); + db.ruin_segments(abs_path); + db.commit(); + db.close(); + BOOST_CHECK_THROW(db.open( temp, database::read_write), std::runtime_error); + + + } catch ( ... ) { + bfs::remove_all ( temp ); + throw; + } +} // BOOST_AUTO_TEST_SUITE_END() -- GitLab