MCPcopy Create free account
hub / github.com/ElementsProject/elements / BOOST_AUTO_TEST_CASE

Function BOOST_AUTO_TEST_CASE

src/test/skiplist_tests.cpp:16–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14BOOST_FIXTURE_TEST_SUITE(skiplist_tests, BasicTestingSetup)
15
16BOOST_AUTO_TEST_CASE(skiplist_test)
17{
18 std::vector<CBlockIndex> vIndex(SKIPLIST_LENGTH);
19
20 for (int i=0; i<SKIPLIST_LENGTH; i++) {
21 vIndex[i].nHeight = i;
22 vIndex[i].pprev = (i == 0) ? nullptr : &vIndex[i - 1];
23 vIndex[i].BuildSkip();
24 }
25
26 for (int i=0; i<SKIPLIST_LENGTH; i++) {
27 if (i > 0) {
28 BOOST_CHECK(vIndex[i].pskip == &vIndex[vIndex[i].pskip->nHeight]);
29 BOOST_CHECK(vIndex[i].pskip->nHeight < i);
30 } else {
31 BOOST_CHECK(vIndex[i].pskip == nullptr);
32 }
33 }
34
35 for (int i=0; i < 1000; i++) {
36 int from = InsecureRandRange(SKIPLIST_LENGTH - 1);
37 int to = InsecureRandRange(from + 1);
38
39 BOOST_CHECK(vIndex[SKIPLIST_LENGTH - 1].GetAncestor(from) == &vIndex[from]);
40 BOOST_CHECK(vIndex[from].GetAncestor(to) == &vIndex[to]);
41 BOOST_CHECK(vIndex[from].GetAncestor(0) == vIndex.data());
42 }
43}
44
45BOOST_AUTO_TEST_CASE(getlocator_test)
46{

Callers

nothing calls this directly

Calls 15

InsecureRandRangeFunction · 0.85
ArithToUint256Function · 0.85
UintToArith256Function · 0.85
arith_uint256Class · 0.85
BuildSkipMethod · 0.80
GetAncestorMethod · 0.80
GetLow64Method · 0.80
SetTipMethod · 0.80
GetLocatorMethod · 0.80
GetMedianTimePastMethod · 0.80
FindEarliestAtLeastMethod · 0.80
emplace_backMethod · 0.80

Tested by

no test coverage detected