Bitcoin Core 28.99.0
P2P Digital Currency
Functions | Variables
uint256_tests.cpp File Reference
#include <streams.h>
#include <test/util/setup_common.h>
#include <uint256.h>
#include <util/strencodings.h>
#include <util/transaction_identifier.h>
#include <boost/test/unit_test.hpp>
#include <iomanip>
#include <sstream>
#include <string>
#include <string_view>
#include <vector>
Include dependency graph for uint256_tests.cpp:

Go to the source code of this file.

Functions

static std::string ArrayToString (const unsigned char A[], unsigned int width)
 
 BOOST_AUTO_TEST_CASE (basics)
 
 BOOST_AUTO_TEST_CASE (comparison)
 
 BOOST_AUTO_TEST_CASE (methods)
 
template<typename T >
void TestFromHex ()
 Implemented as a templated function so it can be reused by other classes that have a FromHex() method that wraps base_blob::FromHex(), such as transaction_identifier::FromHex(). More...
 
 BOOST_AUTO_TEST_CASE (from_hex)
 
 BOOST_AUTO_TEST_CASE (from_user_hex)
 
 BOOST_AUTO_TEST_CASE (check_ONE)
 
 BOOST_AUTO_TEST_CASE (FromHex_vs_uint256)
 

Variables

const unsigned char R1Array []
 
const char R1ArrayHex [] = "7D1DE5EAF9B156D53208F033B5AA8122D2d2355d5e12292b121156cfdb4a529c"
 
const uint256 R1L = uint256(std::vector<unsigned char>(R1Array,R1Array+32))
 
const uint160 R1S = uint160(std::vector<unsigned char>(R1Array,R1Array+20))
 
const unsigned char R2Array []
 
const uint256 R2L = uint256(std::vector<unsigned char>(R2Array,R2Array+32))
 
const uint160 R2S = uint160(std::vector<unsigned char>(R2Array,R2Array+20))
 
const unsigned char ZeroArray []
 
const uint256 ZeroL = uint256(std::vector<unsigned char>(ZeroArray,ZeroArray+32))
 
const uint160 ZeroS = uint160(std::vector<unsigned char>(ZeroArray,ZeroArray+20))
 
const unsigned char OneArray []
 
const uint256 OneL = uint256(std::vector<unsigned char>(OneArray,OneArray+32))
 
const uint160 OneS = uint160(std::vector<unsigned char>(OneArray,OneArray+20))
 
const unsigned char MaxArray []
 
const uint256 MaxL = uint256(std::vector<unsigned char>(MaxArray,MaxArray+32))
 
const uint160 MaxS = uint160(std::vector<unsigned char>(MaxArray,MaxArray+20))
 

Function Documentation

◆ ArrayToString()

static std::string ArrayToString ( const unsigned char  A[],
unsigned int  width 
)
static

Definition at line 52 of file uint256_tests.cpp.

Here is the caller graph for this function:

◆ BOOST_AUTO_TEST_CASE() [1/7]

BOOST_AUTO_TEST_CASE ( basics  )

Definition at line 63 of file uint256_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/7]

BOOST_AUTO_TEST_CASE ( check_ONE  )

Definition at line 329 of file uint256_tests.cpp.

◆ BOOST_AUTO_TEST_CASE() [3/7]

BOOST_AUTO_TEST_CASE ( comparison  )

Definition at line 108 of file uint256_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/7]

BOOST_AUTO_TEST_CASE ( from_hex  )

Definition at line 292 of file uint256_tests.cpp.

◆ BOOST_AUTO_TEST_CASE() [5/7]

BOOST_AUTO_TEST_CASE ( from_user_hex  )

Definition at line 300 of file uint256_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/7]

BOOST_AUTO_TEST_CASE ( FromHex_vs_uint256  )

Definition at line 335 of file uint256_tests.cpp.

Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [7/7]

BOOST_AUTO_TEST_CASE ( methods  )

Definition at line 150 of file uint256_tests.cpp.

Here is the call graph for this function:

◆ TestFromHex()

template<typename T >
void TestFromHex ( )

Implemented as a templated function so it can be reused by other classes that have a FromHex() method that wraps base_blob::FromHex(), such as transaction_identifier::FromHex().

Definition at line 252 of file uint256_tests.cpp.

Here is the call graph for this function:

Variable Documentation

◆ MaxArray

const unsigned char MaxArray[]
Initial value:
=
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"

Definition at line 46 of file uint256_tests.cpp.

◆ MaxL

const uint256 MaxL = uint256(std::vector<unsigned char>(MaxArray,MaxArray+32))

Definition at line 49 of file uint256_tests.cpp.

◆ MaxS

const uint160 MaxS = uint160(std::vector<unsigned char>(MaxArray,MaxArray+20))

Definition at line 50 of file uint256_tests.cpp.

◆ OneArray

const unsigned char OneArray[]
Initial value:
=
"\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"

Definition at line 40 of file uint256_tests.cpp.

◆ OneL

const uint256 OneL = uint256(std::vector<unsigned char>(OneArray,OneArray+32))

Definition at line 43 of file uint256_tests.cpp.

◆ OneS

const uint160 OneS = uint160(std::vector<unsigned char>(OneArray,OneArray+20))

Definition at line 44 of file uint256_tests.cpp.

◆ R1Array

const unsigned char R1Array[]
Initial value:
=
"\x9c\x52\x4a\xdb\xcf\x56\x11\x12\x2b\x29\x12\x5e\x5d\x35\xd2\xd2"
"\x22\x81\xaa\xb5\x33\xf0\x08\x32\xd5\x56\xb1\xf9\xea\xe5\x1d\x7d"

Definition at line 21 of file uint256_tests.cpp.

◆ R1ArrayHex

const char R1ArrayHex[] = "7D1DE5EAF9B156D53208F033B5AA8122D2d2355d5e12292b121156cfdb4a529c"

Definition at line 24 of file uint256_tests.cpp.

◆ R1L

const uint256 R1L = uint256(std::vector<unsigned char>(R1Array,R1Array+32))

Definition at line 25 of file uint256_tests.cpp.

◆ R1S

const uint160 R1S = uint160(std::vector<unsigned char>(R1Array,R1Array+20))

Definition at line 26 of file uint256_tests.cpp.

◆ R2Array

const unsigned char R2Array[]
Initial value:
=
"\x70\x32\x1d\x7c\x47\xa5\x6b\x40\x26\x7e\x0a\xc3\xa6\x9c\xb6\xbf"
"\x13\x30\x47\xa3\x19\x2d\xda\x71\x49\x13\x72\xf0\xb4\xca\x81\xd7"

Definition at line 28 of file uint256_tests.cpp.

◆ R2L

const uint256 R2L = uint256(std::vector<unsigned char>(R2Array,R2Array+32))

Definition at line 31 of file uint256_tests.cpp.

◆ R2S

const uint160 R2S = uint160(std::vector<unsigned char>(R2Array,R2Array+20))

Definition at line 32 of file uint256_tests.cpp.

◆ ZeroArray

const unsigned char ZeroArray[]
Initial value:
=
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"

Definition at line 34 of file uint256_tests.cpp.

◆ ZeroL

const uint256 ZeroL = uint256(std::vector<unsigned char>(ZeroArray,ZeroArray+32))

Definition at line 37 of file uint256_tests.cpp.

◆ ZeroS

const uint160 ZeroS = uint160(std::vector<unsigned char>(ZeroArray,ZeroArray+20))

Definition at line 38 of file uint256_tests.cpp.