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 "util/testharness.h"7#include <stdlib.h>8#include <sys/stat.h>9#include <sys/types.h>11#include <string>12#include <vector>14#include "leveldb/env.h"16namespace leveldb {17namespace test {19namespace {20struct Test {21const char* base;22const char* name;23void (*func)();24};25std::vector<Test>* tests;26} // namespace28bool RegisterTest(const char* base, const char* name, void (*func)()) {29if (tests == nullptr) {30tests = new std::vector<Test>;31}32Test t;33t.base = base;34t.name = name;35t.func = func;36tests->push_back(t);37return true;38}40int RunAllTests() {41const char* matcher = getenv("LEVELDB_TESTS");43int num = 0;44if (tests != nullptr) {45for (size_t i = 0; i < tests->size(); i++) {46const Test& t = (*tests)[i];47if (matcher != nullptr) {48std::string name = t.base;49name.push_back('.');50name.append(t.name);51if (strstr(name.c_str(), matcher) == nullptr) {52continue;53}54}55fprintf(stderr, "==== Test %s.%s\n", t.base, t.name);56(*t.func)();57++num;58}59}60fprintf(stderr, "==== PASSED %d tests\n", num);61return 0;62}64std::string TmpDir() {65std::string dir;66Status s = Env::Default()->GetTestDirectory(&dir);67ASSERT_TRUE(s.ok()) << s.ToString();68return dir;69}71int RandomSeed() {72const char* env = getenv("TEST_RANDOM_SEED");73int result = (env != nullptr ? atoi(env) : 301);74if (result <= 0) {75result = 301;76}77return result;78}80} // namespace test81} // namespace leveldb
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.