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/hash.h"6#include "util/testharness.h"8namespace leveldb {10class HASH {};12TEST(HASH, SignedUnsignedIssue) {13const uint8_t data1[1] = {0x62};14const uint8_t data2[2] = {0xc3, 0x97};15const uint8_t data3[3] = {0xe2, 0x99, 0xa5};16const uint8_t data4[4] = {0xe1, 0x80, 0xb9, 0x32};17const uint8_t data5[48] = {180x01, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,190x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,200x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x18, 0x28, 0x00, 0x00, 0x00,210x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,22};24ASSERT_EQ(Hash(0, 0, 0xbc9f1d34), 0xbc9f1d34);25ASSERT_EQ(26Hash(reinterpret_cast<const char*>(data1), sizeof(data1), 0xbc9f1d34),270xef1345c4);28ASSERT_EQ(29Hash(reinterpret_cast<const char*>(data2), sizeof(data2), 0xbc9f1d34),300x5b663814);31ASSERT_EQ(32Hash(reinterpret_cast<const char*>(data3), sizeof(data3), 0xbc9f1d34),330x323c078f);34ASSERT_EQ(35Hash(reinterpret_cast<const char*>(data4), sizeof(data4), 0xbc9f1d34),360xed21633a);37ASSERT_EQ(38Hash(reinterpret_cast<const char*>(data5), sizeof(data5), 0x12345678),390xf333dabb);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.