aboutsummaryrefslogtreecommitdiffstats
path: root/trie.cpp
diff options
context:
space:
mode:
authorGav Wood <i@gavwood.com>2014-10-17 00:43:48 +0800
committerGav Wood <i@gavwood.com>2014-10-17 00:43:48 +0800
commit165e9780f7b79bdead6eb6af7f5a857398159eb2 (patch)
tree87cb03af4af6a10b6160086c6774fe6add8d103d /trie.cpp
parentea27fbe5f33e982babf13df25334dccd112dd96b (diff)
downloaddexon-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.cpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/trie.cpp b/trie.cpp
index fb74ebe2..899eb1f6 100644
--- a/trie.cpp
+++ b/trie.cpp
@@ -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...";