| 14 | BOOST_FIXTURE_TEST_SUITE(skiplist_tests, BasicTestingSetup) |
| 15 | |
| 16 | BOOST_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 | |
| 45 | BOOST_AUTO_TEST_CASE(getlocator_test) |
| 46 | { |
nothing calls this directly
no test coverage detected