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.
251compaction_files_.push_back(f2);252compaction_files_.push_back(f3);254AddBoundaryInputs(icmp_, level_files_, &compaction_files_);255ASSERT_EQ(2, compaction_files_.size());256}258TEST(AddBoundaryInputsTest, TestOneBoundaryFiles) {259FileMetaData* f1 =260CreateFileMetaData(1, InternalKey("100", 3, kTypeValue),261InternalKey(InternalKey("100", 2, kTypeValue)));262FileMetaData* f2 =263CreateFileMetaData(1, InternalKey("100", 1, kTypeValue),264InternalKey(InternalKey("200", 3, kTypeValue)));265FileMetaData* f3 =266CreateFileMetaData(1, InternalKey("300", 2, kTypeValue),267InternalKey(InternalKey("300", 1, kTypeValue)));269level_files_.push_back(f3);270level_files_.push_back(f2);271level_files_.push_back(f1);272compaction_files_.push_back(f1);274AddBoundaryInputs(icmp_, level_files_, &compaction_files_);275ASSERT_EQ(2, compaction_files_.size());276ASSERT_EQ(f1, compaction_files_[0]);277ASSERT_EQ(f2, compaction_files_[1]);278}280TEST(AddBoundaryInputsTest, TestTwoBoundaryFiles) {281FileMetaData* f1 =282CreateFileMetaData(1, InternalKey("100", 6, kTypeValue),283InternalKey(InternalKey("100", 5, kTypeValue)));284FileMetaData* f2 =285CreateFileMetaData(1, InternalKey("100", 2, kTypeValue),286InternalKey(InternalKey("300", 1, kTypeValue)));287FileMetaData* f3 =288CreateFileMetaData(1, InternalKey("100", 4, kTypeValue),289InternalKey(InternalKey("100", 3, kTypeValue)));291level_files_.push_back(f2);292level_files_.push_back(f3);293level_files_.push_back(f1);294compaction_files_.push_back(f1);296AddBoundaryInputs(icmp_, level_files_, &compaction_files_);297ASSERT_EQ(3, compaction_files_.size());298ASSERT_EQ(f1, compaction_files_[0]);299ASSERT_EQ(f3, compaction_files_[1]);300ASSERT_EQ(f2, compaction_files_[2]);301}303TEST(AddBoundaryInputsTest, TestDisjoinFilePointers) {304FileMetaData* f1 =305CreateFileMetaData(1, InternalKey("100", 6, kTypeValue),306InternalKey(InternalKey("100", 5, kTypeValue)));307FileMetaData* f2 =308CreateFileMetaData(1, InternalKey("100", 6, kTypeValue),309InternalKey(InternalKey("100", 5, kTypeValue)));310FileMetaData* f3 =311CreateFileMetaData(1, InternalKey("100", 2, kTypeValue),312InternalKey(InternalKey("300", 1, kTypeValue)));313FileMetaData* f4 =314CreateFileMetaData(1, InternalKey("100", 4, kTypeValue),315InternalKey(InternalKey("100", 3, kTypeValue)));317level_files_.push_back(f2);318level_files_.push_back(f3);319level_files_.push_back(f4);321compaction_files_.push_back(f1);323AddBoundaryInputs(icmp_, level_files_, &compaction_files_);324ASSERT_EQ(3, compaction_files_.size());325ASSERT_EQ(f1, compaction_files_[0]);326ASSERT_EQ(f4, compaction_files_[1]);327ASSERT_EQ(f3, compaction_files_[2]);328}330} // namespace leveldb332int 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.