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.
501str.clear();502uint8_t c{0};503while (!s.empty()) {504s >> c;505str.push_back(c);506}507}508};510BOOST_AUTO_TEST_CASE(iterator_string_ordering)511{512fs::path ph = m_args.GetDataDirBase() / "iterator_string_ordering";513CDBWrapper dbw({.path = ph, .cache_bytes = 1_MiB, .memory_only = true, .wipe_data = false, .obfuscate = false});514for (int x = 0; x < 10; ++x) {515for (int y = 0; y < 10; ++y) {516std::string key{ToString(x)};517for (int z = 0; z < y; ++z)518key += key;519uint32_t value = x*x;520dbw.Write(StringContentsSerializer{key}, value);521}522}524std::unique_ptr<CDBIterator> it(const_cast<CDBWrapper&>(dbw).NewIterator());525for (const int seek_start : {0, 5}) {526it->Seek(StringContentsSerializer{ToString(seek_start)});527for (unsigned int x = seek_start; x < 10; ++x) {528for (int y = 0; y < 10; ++y) {529std::string exp_key{ToString(x)};530for (int z = 0; z < y; ++z)531exp_key += exp_key;532StringContentsSerializer key;533uint32_t value;534BOOST_CHECK(it->Valid());535if (!it->Valid()) // Avoid spurious errors about invalid iterator's key and value in case of failure536break;537BOOST_CHECK(it->GetKey(key));538BOOST_CHECK(it->GetValue(value));539BOOST_CHECK_EQUAL(key.str, exp_key);540BOOST_CHECK_EQUAL(value, x*x);541it->Next();542}543}544BOOST_CHECK(!it->Valid());545}546}548BOOST_AUTO_TEST_CASE(unicodepath)549{550// Attempt to create a database with a UTF8 character in the path.551// On Windows this test will fail if the directory is created using552// the ANSI CreateDirectoryA call and the code page isn't UTF8.553// It will succeed if created with CreateDirectoryW.554fs::path ph = m_args.GetDataDirBase() / "test_runner_₿_🏃_20191128_104644";555CDBWrapper dbw({.path = ph, .cache_bytes = 1_MiB});557fs::path lockPath = ph / "LOCK";558BOOST_CHECK(fs::exists(lockPath));559}562BOOST_AUTO_TEST_SUITE_END()
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.