diff --git a/MemTrie.cpp b/MemTrie.cpp index 5c819ffbd..b5d875acb 100644 --- a/MemTrie.cpp +++ b/MemTrie.cpp @@ -25,9 +25,10 @@ #include #include using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; -namespace eth +namespace dev { #define ENABLE_DEBUG_PRINT 0 @@ -54,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 eth::sha3(s.out()); } + h256 hash256() const { RLPStream s; makeRLP(s); return dev::eth::sha3(s.out()); } bytes rlp() const { RLPStream s; makeRLP(s); return s.out(); } void mark() { m_hash256 = h256(); } @@ -199,7 +200,7 @@ void MemTrieNode::putRLP(RLPStream& _parentStream) const if (s.out().size() < 32) _parentStream.APPEND_CHILD(s.out()); else - _parentStream << eth::sha3(s.out()); + _parentStream << dev::eth::sha3(s.out()); } void TrieBranchNode::makeRLP(RLPStream& _intoStream) const @@ -228,7 +229,7 @@ void TrieInfixNode::makeRLP(RLPStream& _intoStream) const MemTrieNode* MemTrieNode::newBranch(bytesConstRef _k1, std::string const& _v1, bytesConstRef _k2, std::string const& _v2) { - uint prefix = commonPrefix(_k1, _k2); + unsigned prefix = commonPrefix(_k1, _k2); MemTrieNode* ret; if (_k1.size() == prefix) @@ -347,7 +348,7 @@ MemTrieNode* TrieInfixNode::insert(bytesConstRef _key, std::string const& _value } else { - uint prefix = commonPrefix(_key, m_ext); + unsigned prefix = commonPrefix(_key, m_ext); if (prefix) { // one infix becomes two infixes, then insert into the second @@ -478,3 +479,4 @@ void MemTrie::remove(std::string const& _key) } } + diff --git a/MemTrie.h b/MemTrie.h index 8c90f2f3f..66669653c 100644 --- a/MemTrie.h +++ b/MemTrie.h @@ -24,7 +24,7 @@ #include #include -namespace eth +namespace dev { class MemTrieNode; diff --git a/TestHelper.cpp b/TestHelper.cpp index 06f188a89..02a883dbc 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -19,11 +19,14 @@ * @date 2014 */ +#include "TestHelper.h" + #include #include #include -#include "TestHelper.h" +namespace dev +{ namespace eth { @@ -47,3 +50,4 @@ void connectClients(Client& c1, Client& c2) } } +} diff --git a/TestHelper.h b/TestHelper.h index 748373baa..d6924a17c 100644 --- a/TestHelper.h +++ b/TestHelper.h @@ -21,10 +21,15 @@ #pragma once +namespace dev +{ namespace eth { +class Client; + void mine(Client& c, int numBlocks); void connectClients(Client& c1, Client& c2); } +} diff --git a/TrieHash.cpp b/TrieHash.cpp index 8f4161a17..b2ebce731 100644 --- a/TrieHash.cpp +++ b/TrieHash.cpp @@ -25,9 +25,10 @@ #include #include using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; -namespace eth +namespace dev { /*/ @@ -67,12 +68,12 @@ void hash256rlp(HexMap const& _s, HexMap::const_iterator _begin, HexMap::const_i { // find the number of common prefix nibbles shared // i.e. the minimum number of nibbles shared at the beginning between the first hex string and each successive. - uint sharedPre = (uint)-1; - uint c = 0; + unsigned sharedPre = (unsigned)-1; + unsigned c = 0; for (auto i = std::next(_begin); i != _end && sharedPre; ++i, ++c) { - uint x = std::min(sharedPre, std::min((uint)_begin->first.size(), (uint)i->first.size())); - uint shared = _preLen; + unsigned x = std::min(sharedPre, std::min((unsigned)_begin->first.size(), (unsigned)i->first.size())); + unsigned shared = _preLen; for (; shared < x && _begin->first[shared] == i->first[shared]; ++shared) {} sharedPre = std::min(shared, sharedPre); } diff --git a/TrieHash.h b/TrieHash.h index 391c42633..4d86c4dbf 100644 --- a/TrieHash.h +++ b/TrieHash.h @@ -24,7 +24,7 @@ #include #include -namespace eth +namespace dev { bytes rlp256(StringMap const& _s); diff --git a/crypto.cpp b/crypto.cpp index c39de78d7..2e4ffa055 100644 --- a/crypto.cpp +++ b/crypto.cpp @@ -29,7 +29,8 @@ #include using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; BOOST_AUTO_TEST_CASE(crypto_tests) @@ -145,7 +146,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(eth::sha3(bytesConstRef(&pubkey).cropped(1))) << dec << endl; + cout << "SENDER: " << hex << toAddress(dev::eth::sha3(bytesConstRef(&pubkey).cropped(1))) << dec << endl; } #endif return 0; diff --git a/dagger.cpp b/dagger.cpp index 4f65b47aa..fd60a8efa 100644 --- a/dagger.cpp +++ b/dagger.cpp @@ -25,7 +25,8 @@ #include using namespace std; using namespace std::chrono; -using namespace eth; +using namespace dev; +using namespace dev::eth; int daggerTest() { diff --git a/fork.cpp b/fork.cpp index f0edb702f..1cdb8822c 100644 --- a/fork.cpp +++ b/fork.cpp @@ -27,7 +27,8 @@ #include #include "TestHelper.h" using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; // Disabled since tests shouldn't block. Need a short cut to avoid real mining. /* diff --git a/genesis.cpp b/genesis.cpp index 441826e78..be6655aba 100644 --- a/genesis.cpp +++ b/genesis.cpp @@ -28,7 +28,8 @@ #include using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; namespace js = json_spirit; diff --git a/hexPrefix.cpp b/hexPrefix.cpp index 5ea670923..7dbe80a57 100644 --- a/hexPrefix.cpp +++ b/hexPrefix.cpp @@ -27,7 +27,8 @@ #include using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; namespace js = json_spirit; BOOST_AUTO_TEST_CASE(hexPrefix_test) diff --git a/main.cpp b/main.cpp index 1497f2981..08142095c 100644 --- a/main.cpp +++ b/main.cpp @@ -38,7 +38,8 @@ int peerTest(int argc, char** argv); #include #include using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; BOOST_AUTO_TEST_CASE(basic_tests) { diff --git a/network.cpp b/network.cpp index 978d68934..acdd649d9 100644 --- a/network.cpp +++ b/network.cpp @@ -27,7 +27,8 @@ #include #include "TestHelper.h" using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; // Disabled since tests shouldn't block (not the worst offender, but timeout should be reduced anyway). /* diff --git a/peer.cpp b/peer.cpp index f903d0429..821aab514 100644 --- a/peer.cpp +++ b/peer.cpp @@ -24,8 +24,8 @@ #include #include using namespace std; -using namespace eth; -using namespace p2p; +using namespace dev; +using namespace dev::p2p; int peerTest(int argc, char** argv) { diff --git a/rlp.cpp b/rlp.cpp index 548be8d9b..963d61091 100644 --- a/rlp.cpp +++ b/rlp.cpp @@ -30,10 +30,10 @@ #include using namespace std; -using namespace eth; +using namespace dev; namespace js = json_spirit; -namespace eth +namespace dev { namespace test { @@ -116,7 +116,7 @@ namespace eth BOOST_CHECK( !u.isData() ); js::mArray& arr = v.get_array(); BOOST_CHECK( u.itemCount() == arr.size() ); - uint i; + unsigned i; for( i = 0; i < arr.size(); i++ ) { RLP item = u[i]; @@ -137,16 +137,16 @@ BOOST_AUTO_TEST_CASE(rlp_encoding_test) { cnote << "Testing RLP Encoding..."; js::mValue v; - eth::test::getRLPTestCases(v); + dev::test::getRLPTestCases(v); for (auto& i: v.get_obj()) { js::mObject& o = i.second.get_obj(); cnote << i.first; - eth::test::checkRLPTestCase(o); + dev::test::checkRLPTestCase(o); RLPStream s; - eth::test::buildRLP(o["in"], s); + dev::test::buildRLP(o["in"], s); std::string expectedText(o["out"].get_str()); std::transform(expectedText.begin(), expectedText.end(), expectedText.begin(), ::tolower ); @@ -173,19 +173,19 @@ BOOST_AUTO_TEST_CASE(rlp_decoding_test) // and then compare the output structure to the json of the // input object. js::mValue v; - eth::test::getRLPTestCases(v); + dev::test::getRLPTestCases(v); for (auto& i: v.get_obj()) { js::mObject& o = i.second.get_obj(); cnote << i.first; - eth::test::checkRLPTestCase(o); + dev::test::checkRLPTestCase(o); js::mValue& inputData = o["in"]; bytes payloadToDecode = fromHex(o["out"].get_str()); RLP payload(payloadToDecode); - eth::test::checkRLPAgainstJson(inputData, payload); + dev::test::checkRLPAgainstJson(inputData, payload); } } diff --git a/state.cpp b/state.cpp index 8d82b0c2b..99ce30957 100644 --- a/state.cpp +++ b/state.cpp @@ -26,7 +26,8 @@ #include #include using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; int stateTest() { diff --git a/trie.cpp b/trie.cpp index b28be8b18..4ddf30a61 100644 --- a/trie.cpp +++ b/trie.cpp @@ -29,22 +29,23 @@ #include using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; namespace js = json_spirit; -namespace eth -{ - namespace test - { - static unsigned fac(unsigned _i) - { - return _i > 2 ? _i * fac(_i - 1) : _i; - } +namespace dev +{ +namespace test +{ - } +static unsigned fac(unsigned _i) +{ + return _i > 2 ? _i * fac(_i - 1) : _i; } +} +} BOOST_AUTO_TEST_CASE(trie_tests) { @@ -66,7 +67,7 @@ BOOST_AUTO_TEST_CASE(trie_tests) if (!ss.back().second.find("0x")) ss.back().second = asString(fromHex(ss.back().second.substr(2))); } - for (unsigned j = 0; j < min(1000u, eth::test::fac((unsigned)ss.size())); ++j) + for (unsigned j = 0; j < min(1000u, dev::test::fac((unsigned)ss.size())); ++j) { next_permutation(ss.begin(), ss.end()); MemoryDB m; diff --git a/txTest.cpp b/txTest.cpp index 314cf9644..cc78c26a2 100644 --- a/txTest.cpp +++ b/txTest.cpp @@ -27,7 +27,8 @@ #include #include "TestHelper.h" using namespace std; -using namespace eth; +using namespace dev; +using namespace dev::eth; // Disabled since tests shouldn't block. Need a short cut to avoid real mining. /* @@ -46,7 +47,7 @@ BOOST_AUTO_TEST_CASE(mine_local_simple_tx) //send c2 some eth from c1 auto txAmount = c1bal / 2u; auto gasPrice = 10 * szabo; - auto gas = eth::c_callGas; + auto gas = dev::eth::c_callGas; c1.transact(kp1.secret(), txAmount, kp2.address(), bytes(), gas, gasPrice); //mine some more to include the transaction on chain @@ -74,7 +75,7 @@ BOOST_AUTO_TEST_CASE(mine_and_send_to_peer) //send c2 some eth from c1 auto txAmount = c1bal / 2u; auto gasPrice = 10 * szabo; - auto gas = eth::c_callGas; + auto gas = dev::eth::c_callGas; c1.transact(kp1.secret(), txAmount, kp2.address(), bytes(), gas, gasPrice); //mine some more to include the transaction on chain @@ -105,7 +106,7 @@ BOOST_AUTO_TEST_CASE(mine_and_send_to_peer_fee_check) //send c2 some eth from c1 auto txAmount = c1StartBalance / 2u; auto gasPrice = 10 * szabo; - auto gas = eth::c_callGas; + auto gas = dev::eth::c_callGas; c1.transact(kp1.secret(), txAmount, c2.address(), bytes(), gas, gasPrice); //mine some more, this time with second client (so he can get fees from first client's tx) diff --git a/vm.cpp b/vm.cpp index 0647849a0..2b75f0b3d 100644 --- a/vm.cpp +++ b/vm.cpp @@ -33,9 +33,10 @@ using namespace std; using namespace json_spirit; -using namespace eth; +using namespace dev; +using namespace dev::eth; -namespace eth { namespace test { +namespace dev { namespace test { class FakeExtVM: public ExtVMFace { @@ -387,7 +388,7 @@ void doTests(json_spirit::mValue& v, bool _fillin) BOOST_REQUIRE(o.count("exec") > 0); VM vm; - eth::test::FakeExtVM fev; + dev::test::FakeExtVM fev; fev.importEnv(o["env"].get_obj()); fev.importState(o["pre"].get_obj()); @@ -419,7 +420,7 @@ void doTests(json_spirit::mValue& v, bool _fillin) BOOST_REQUIRE(o.count("out") > 0); BOOST_REQUIRE(o.count("gas") > 0); - eth::test::FakeExtVM test; + dev::test::FakeExtVM test; test.importState(o["post"].get_obj()); test.importCallCreates(o["callcreates"].get_array()); int i = 0; @@ -481,7 +482,7 @@ BOOST_AUTO_TEST_CASE(vm_tests) string s = asString(contents("../../../cpp-ethereum/test/vmtests.json")); BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'vmtests.json' is empty."); json_spirit::read_string(s, v); - eth::test::doTests(v, true); + dev::test::doTests(v, true); writeFile("../../../tests/vmtests.json", asBytes(json_spirit::write_string(v, true))); } /* catch (std::exception const& e) @@ -496,7 +497,7 @@ BOOST_AUTO_TEST_CASE(vm_tests) string s = asString(contents("../../../tests/vmtests.json")); BOOST_REQUIRE_MESSAGE(s.length() > 0, "Contents of 'vmtests.json' is empty. Have you cloned the 'tests' repo branch develop?"); json_spirit::read_string(s, v); - eth::test::doTests(v, false); + dev::test::doTests(v, false); } catch (std::exception const& e) {