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.
1// Copyright (c) 2011 The LevelDB Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file. See the AUTHORS file for names of contributors.5#include "db/version_edit.h"6#include "util/testharness.h"8namespace leveldb {10static void TestEncodeDecode(const VersionEdit& edit) {11std::string encoded, encoded2;12edit.EncodeTo(&encoded);13VersionEdit parsed;14Status s = parsed.DecodeFrom(encoded);15ASSERT_TRUE(s.ok()) << s.ToString();16parsed.EncodeTo(&encoded2);17ASSERT_EQ(encoded, encoded2);18}20class VersionEditTest {};22TEST(VersionEditTest, EncodeDecode) {23static const uint64_t kBig = 1ull << 50;25VersionEdit edit;26for (int i = 0; i < 4; i++) {27TestEncodeDecode(edit);28edit.AddFile(3, kBig + 300 + i, kBig + 400 + i,29InternalKey("foo", kBig + 500 + i, kTypeValue),30InternalKey("zoo", kBig + 600 + i, kTypeDeletion));31edit.DeleteFile(4, kBig + 700 + i);32edit.SetCompactPointer(i, InternalKey("x", kBig + 900 + i, kTypeValue));33}35edit.SetComparatorName("foo");36edit.SetLogNumber(kBig + 100);37edit.SetNextFile(kBig + 200);38edit.SetLastSequence(kBig + 1000);39TestEncodeDecode(edit);40}42} // namespace leveldb44int 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.