Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
501ASSERT_OK(Verify(0, num_pre_sync, FaultInjectionTest::VAL_EXPECT_NO_ERROR));502ASSERT_OK(Verify(num_pre_sync, num_post_sync,503FaultInjectionTest::VAL_EXPECT_ERROR));504}506void NoWriteTestPreFault() {}508void NoWriteTestReopenWithFault(ResetMethod reset_method) {509CloseDB();510ResetDBState(reset_method);511ASSERT_OK(OpenDB());512}514void DoTest() {515Random rnd(0);516ASSERT_OK(OpenDB());517for (size_t idx = 0; idx < kNumIterations; idx++) {518int num_pre_sync = rnd.Uniform(kMaxNumValues);519int num_post_sync = rnd.Uniform(kMaxNumValues);521PartialCompactTestPreFault(num_pre_sync, num_post_sync);522PartialCompactTestReopenWithFault(RESET_DROP_UNSYNCED_DATA, num_pre_sync,523num_post_sync);525NoWriteTestPreFault();526NoWriteTestReopenWithFault(RESET_DROP_UNSYNCED_DATA);528PartialCompactTestPreFault(num_pre_sync, num_post_sync);529// No new files created so we expect all values since no files will be530// dropped.531PartialCompactTestReopenWithFault(RESET_DELETE_UNSYNCED_FILES,532num_pre_sync + num_post_sync, 0);534NoWriteTestPreFault();535NoWriteTestReopenWithFault(RESET_DELETE_UNSYNCED_FILES);536}537}538};540TEST(FaultInjectionTest, FaultTestNoLogReuse) {541ReuseLogs(false);542DoTest();543}545TEST(FaultInjectionTest, FaultTestWithLogReuse) {546ReuseLogs(true);547DoTest();548}550} // namespace leveldb552int main(int argc, char** argv) { return leveldb::test::RunAllTests(); }
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.