aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2014-10-17 21:49:27 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2014-10-17 21:49:27 +0800
commitd5502aee4866b8f321a85d1bd9b320cf574f5378 (patch)
tree0c9cad6262f7f0ff0a1769d89238f7820d5a2573
parent31359aa253317b50bc47e1f8468977918bcbd4a4 (diff)
parent693fe08bc996ff8403c75a770a735916dae4fc5b (diff)
downloaddexon-solidity-d5502aee4866b8f321a85d1bd9b320cf574f5378.tar.gz
dexon-solidity-d5502aee4866b8f321a85d1bd9b320cf574f5378.tar.zst
dexon-solidity-d5502aee4866b8f321a85d1bd9b320cf574f5378.zip
Merge branch 'develop' into mk_jsonrpc
Conflicts: libqethereum/QEthereum.h
-rw-r--r--MemTrie.cpp4
-rw-r--r--TestHelperCrypto.h11
-rw-r--r--crypto.cpp2
-rw-r--r--hexPrefix.cpp1
-rw-r--r--jsonrpc.cpp2
-rw-r--r--rlp.cpp2
-rw-r--r--trie.cpp46
-rw-r--r--vm.cpp11
8 files changed, 67 insertions, 12 deletions
diff --git a/MemTrie.cpp b/MemTrie.cpp
index d654179f..4879f267 100644
--- a/MemTrie.cpp
+++ b/MemTrie.cpp
@@ -55,7 +55,7 @@ public:
#endif
/// 256-bit hash of the node - this is a SHA-3/256 hash of the RLP of the node.
- h256 hash256() const { RLPStream s; makeRLP(s); return dev::eth::sha3(s.out()); }
+ h256 hash256() const { RLPStream s; makeRLP(s); return dev::sha3(s.out()); }
bytes rlp() const { RLPStream s; makeRLP(s); return s.out(); }
void mark() { m_hash256 = h256(); }
@@ -200,7 +200,7 @@ void MemTrieNode::putRLP(RLPStream& _parentStream) const
if (s.out().size() < 32)
_parentStream.APPEND_CHILD(s.out());
else
- _parentStream << dev::eth::sha3(s.out());
+ _parentStream << dev::sha3(s.out());
}
void TrieBranchNode::makeRLP(RLPStream& _intoStream) const
diff --git a/TestHelperCrypto.h b/TestHelperCrypto.h
index 6feeeb97..cdc22ec3 100644
--- a/TestHelperCrypto.h
+++ b/TestHelperCrypto.h
@@ -22,11 +22,22 @@
#pragma once
//#include <ostream>
+
+#pragma warning(push)
+#pragma warning(disable:4100 4244)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wconversion"
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
+#pragma GCC diagnostic ignored "-Wextra"
#include <eccrypto.h>
#include <ecp.h>
#include <files.h>
#include <osrng.h>
#include <oids.h>
+#pragma warning(pop)
+#pragma GCC diagnostic pop
using namespace std;
using namespace CryptoPP;
diff --git a/crypto.cpp b/crypto.cpp
index 25106a77..e71ee228 100644
--- a/crypto.cpp
+++ b/crypto.cpp
@@ -307,7 +307,7 @@ int cryptoTest()
int ret = secp256k1_ecdsa_recover_compact((byte const*)hmsg.data(), (int)hmsg.size(), (byte const*)sig64.data(), pubkey.data(), &pubkeylen, 0, (int)t.vrs.v - 27);
pubkey.resize(pubkeylen);
cout << "RECPUB: " << dec << ret << " " << pubkeylen << " " << toHex(pubkey) << endl;
- cout << "SENDER: " << hex << toAddress(dev::eth::sha3(bytesConstRef(&pubkey).cropped(1))) << dec << endl;
+ cout << "SENDER: " << hex << toAddress(dev::sha3(bytesConstRef(&pubkey).cropped(1))) << dec << endl;
}
#endif
return 0;
diff --git a/hexPrefix.cpp b/hexPrefix.cpp
index 6ced839d..fb2fbc82 100644
--- a/hexPrefix.cpp
+++ b/hexPrefix.cpp
@@ -29,7 +29,6 @@
using namespace std;
using namespace dev;
-using namespace dev::eth;
namespace js = json_spirit;
BOOST_AUTO_TEST_CASE(hexPrefix_test)
diff --git a/jsonrpc.cpp b/jsonrpc.cpp
index 0e14fab8..72cbc9f0 100644
--- a/jsonrpc.cpp
+++ b/jsonrpc.cpp
@@ -254,7 +254,7 @@ BOOST_AUTO_TEST_CASE(jsonrpc_sha3)
cnote << "Testing jsonrpc sha3...";
string testString = "1234567890987654";
string sha3 = jsonrpcClient->sha3(testString);
- BOOST_CHECK_EQUAL(jsToFixed<32>(sha3), dev::eth::sha3(jsToBytes(testString)));
+ BOOST_CHECK_EQUAL(jsToFixed<32>(sha3), dev::sha3(jsToBytes(testString)));
}
BOOST_AUTO_TEST_CASE(jsonrpc_stateAt)
diff --git a/rlp.cpp b/rlp.cpp
index 95d40ada..69360ad6 100644
--- a/rlp.cpp
+++ b/rlp.cpp
@@ -79,7 +79,7 @@ namespace dev
if ( v.type() == js::str_type )
{
const std::string& expectedText = v.get_str();
- if ( expectedText.front() == '#' )
+ if ( !expectedText.empty() && expectedText.front() == '#' )
{
// Deal with bigint instead of a raw string
std::string bigIntStr = expectedText.substr(1,expectedText.length()-1);
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...";
diff --git a/vm.cpp b/vm.cpp
index cc87866d..d7790673 100644
--- a/vm.cpp
+++ b/vm.cpp
@@ -493,7 +493,6 @@ void doTests(json_spirit::mValue& v, bool _fillin)
BOOST_REQUIRE(o.count("pre") > 0);
BOOST_REQUIRE(o.count("exec") > 0);
- VM vm;
dev::test::FakeExtVM fev;
fev.importEnv(o["env"].get_obj());
fev.importState(o["pre"].get_obj());
@@ -508,11 +507,13 @@ void doTests(json_spirit::mValue& v, bool _fillin)
fev.code = &fev.thisTxCode;
}
- vm.reset(fev.gas);
bytes output;
+ u256 gas;
try
{
- output = vm.go(fev).toBytes();
+ VM vm(fev.gas);
+ output = vm.go(fev).toVector();
+ gas = vm.gas(); // Get the remaining gas
}
catch (Exception const& _e)
{
@@ -549,7 +550,7 @@ void doTests(json_spirit::mValue& v, bool _fillin)
o["post"] = mValue(fev.exportState());
o["callcreates"] = fev.exportCallCreates();
o["out"] = "0x" + toHex(output);
- fev.push(o, "gas", vm.gas());
+ fev.push(o, "gas", gas);
}
else
{
@@ -573,7 +574,7 @@ void doTests(json_spirit::mValue& v, bool _fillin)
else
BOOST_CHECK(output == fromHex(o["out"].get_str()));
- BOOST_CHECK(test.toInt(o["gas"]) == vm.gas());
+ BOOST_CHECK(test.toInt(o["gas"]) == gas);
BOOST_CHECK(test.addresses == fev.addresses);
BOOST_CHECK(test.callcreates == fev.callcreates);
}