diff options
author | Gav Wood <i@gavwood.com> | 2014-10-17 00:43:48 +0800 |
---|---|---|
committer | Gav Wood <i@gavwood.com> | 2014-10-17 00:43:48 +0800 |
commit | 165e9780f7b79bdead6eb6af7f5a857398159eb2 (patch) | |
tree | 87cb03af4af6a10b6160086c6774fe6add8d103d /trie.cpp | |
parent | ea27fbe5f33e982babf13df25334dccd112dd96b (diff) | |
download | dexon-solidity-165e9780f7b79bdead6eb6af7f5a857398159eb2.tar.gz dexon-solidity-165e9780f7b79bdead6eb6af7f5a857398159eb2.tar.zst dexon-solidity-165e9780f7b79bdead6eb6af7f5a857398159eb2.zip |
Correct namespace for a few things in devcrypto.
Added lower_bound to TrieDB.
Added nextActiveAddress to State.
Diffstat (limited to 'trie.cpp')
-rw-r--r-- | trie.cpp | 46 |
1 files changed, 45 insertions, 1 deletions
@@ -31,7 +31,6 @@ using namespace std; using namespace dev; -using namespace dev::eth; namespace js = json_spirit; @@ -236,6 +235,51 @@ BOOST_AUTO_TEST_CASE(moreTrieTests) } } +BOOST_AUTO_TEST_CASE(trieLowerBound) +{ + cnote << "Stress-testing Trie.lower_bound..."; + { + MemoryDB dm; + EnforceRefs e(dm, true); + GenericTrieDB<MemoryDB> d(&dm); + d.init(); // initialise as empty tree. + for (int a = 0; a < 20; ++a) + { + StringMap m; + for (int i = 0; i < 50; ++i) + { + auto k = randomWord(); + auto v = toString(i); + m[k] = v; + d.insert(k, v); + } + + for (auto i: d) + { + auto it = d.lower_bound(i.first); + for (auto iit = d.begin(); iit != d.end(); ++iit) + if ((*iit).first.toString() >= i.first.toString()) + { + BOOST_REQUIRE(it == iit); + break; + } + } + for (unsigned i = 0; i < 100; ++i) + { + auto k = randomWord(); + auto it = d.lower_bound(k); + for (auto iit = d.begin(); iit != d.end(); ++iit) + if ((*iit).first.toString() >= k) + { + BOOST_REQUIRE(it == iit); + break; + } + } + + } + } +} + BOOST_AUTO_TEST_CASE(trieStess) { cnote << "Stress-testing Trie..."; |