diff --git a/include.lll b/include.lll index 857def4d4..2752bd7c4 100644 --- a/include.lll +++ b/include.lll @@ -13,10 +13,7 @@ (def 'sha3 (val) { [0]:val (sha3 0 32) }) (def 'return (val) { [0]:val (return 0 32) }) -(def 'makesvar (name pos) { (def name (sload pos)) (def name (v) (sstore pos v)) } ) -(def 'svarcount 0) -(def 'svar (name) { (makesvar name svarcount) (def 'svarcount (+ svarcount 1)) } ) -(def 'makevar (name pos) { (def name (mload pos)) (def name (v) (mstore pos v)) } ) -(def 'varcount 128) ;; Allow 4 x 32 byte slots for us to use. -(def 'var (name) { (makevar name varcount) (def 'varcount (+ varcount 32)) } ) +(def 'makeperm (name pos) { (def name (sload pos)) (def name (v) (sstore pos v)) } ) +(def 'permcount 0) +(def 'perm (name) { (makeperm name permcount) (def 'permcount (+ permcount 1)) } ) } diff --git a/test/hexPrefix.cpp b/test/hexPrefix.cpp index 565ef50c2..871e86f09 100644 --- a/test/hexPrefix.cpp +++ b/test/hexPrefix.cpp @@ -34,7 +34,7 @@ BOOST_AUTO_TEST_CASE(hexPrefix_test) { cnote << "Testing Hex-Prefix-Encode..."; js::mValue v; - string s = asString(contents("../../tests/hexencodetest.json")); + string s = asString(contents("../../../tests/hexencodetest.json")); BOOST_REQUIRE_MESSAGE(s.length() > 0, "Content from 'hexencodetest.json' is empty. Have you cloned the 'tests' repo branch develop?"); js::read_string(s, v); for (auto& i: v.get_obj()) diff --git a/test/main.cpp b/test/main.cpp index f30d5e89e..35e56d191 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -20,6 +20,10 @@ * Main test functions. */ +#include +#include "TrieHash.h" +#include "MemTrie.h" + #include int trieTest(); @@ -38,7 +42,35 @@ using namespace eth; BOOST_AUTO_TEST_CASE(basic_tests) { - cnote << "Hello"; + { + BasicMap m; + GenericTrieDB d(&m); + d.init(); // initialise as empty tree. + MemTrie t; + for (int a = 0; a < 20; ++a) + { + StringMap m; + for (int i = 0; i < 20; ++i) + { + auto k = randomWord(); + auto v = toString(i); + m.insert(make_pair(k, v)); + t.insert(k, v); + d.insert(k, v); + assert(hash256(m) == t.hash256()); + assert(hash256(m) == d.root()); + } + while (!m.empty()) + { + auto k = m.begin()->first; + d.remove(k); + t.remove(k); + m.erase(k); + assert(hash256(m) == t.hash256()); + assert(hash256(m) == d.root()); + } + } + } /* RLPStream s; BlockInfo::genesis().fillStream(s, false); diff --git a/test/rlp.cpp b/test/rlp.cpp index 5adebeabd..0a62df9e3 100644 --- a/test/rlp.cpp +++ b/test/rlp.cpp @@ -60,7 +60,7 @@ namespace eth static void getRLPTestCases(js::mValue& v) { - string s = asString(contents("../../tests/rlptest.json")); + string s = asString(contents("../../../tests/rlptest.json")); BOOST_REQUIRE_MESSAGE( s.length() > 0, "Contents of 'rlptest.json' is empty. Have you cloned the 'tests' repo branch develop?"); js::read_string(s, v); diff --git a/test/trie.cpp b/test/trie.cpp index 4a18a650e..f3ff3ef4a 100644 --- a/test/trie.cpp +++ b/test/trie.cpp @@ -51,7 +51,7 @@ BOOST_AUTO_TEST_CASE(trie_tests) cnote << "Testing Trie..."; js::mValue v; - string s = asString(contents("../../tests/trietest.json")); + string s = asString(contents("../../../tests/trietest.json")); BOOST_REQUIRE_MESSAGE( s.length() > 0, "Contents of 'trietest.json' is empty. Have you cloned the 'tests' repo branch develop?"); js::read_string(s, v); for (auto& i: v.get_obj()) @@ -83,7 +83,7 @@ inline h256 stringMapHash256(StringMap const& _s) int trieTest() { - +#if 0 // More tests... { BasicMap m; @@ -218,6 +218,13 @@ int trieTest() remove("do"); remove("doge"); remove("doe"); + } +#endif + { + BasicMap m; + GenericTrieDB d(&m); + d.init(); // initialise as empty tree. + MemTrie t; for (int a = 0; a < 20; ++a) { StringMap m; diff --git a/test/vm.cpp b/test/vm.cpp index c2dc27910..0d2d2d1e4 100644 --- a/test/vm.cpp +++ b/test/vm.cpp @@ -156,7 +156,7 @@ public: previousBlock.hash = h256(_o["previousHash"].get_str()); currentBlock.number = toInt(_o["currentNumber"]); - currentBlock.gasLimit = toInt(_o["gasLimit"]); + currentBlock.gasLimit = toInt(_o["currentGasLimit"]); currentBlock.difficulty = toInt(_o["currentDifficulty"]); currentBlock.timestamp = toInt(_o["currentTimestamp"]); currentBlock.coinbaseAddress = Address(_o["currentCoinbase"].get_str()); @@ -250,7 +250,7 @@ public: mArray d; for (auto const& i: get<3>(a.second)) push(d, i); - ret["code"] = d; + o["code"] = d; } ret[toString(a.first)] = o;