Project-wide reorganisation of namespaces.

This commit is contained in:
Gav Wood 2014-09-05 17:09:58 +02:00
parent d0d1e91a68
commit 38dd3fb050
19 changed files with 79 additions and 56 deletions

View File

@ -25,9 +25,10 @@
#include <libethcore/SHA3.h>
#include <libethcore/CommonEth.h>
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)
}
}

View File

@ -24,7 +24,7 @@
#include <libethential/Common.h>
#include <libethential/FixedHash.h>
namespace eth
namespace dev
{
class MemTrieNode;

View File

@ -19,11 +19,14 @@
* @date 2014
*/
#include "TestHelper.h"
#include <thread>
#include <chrono>
#include <libethereum/Client.h>
#include "TestHelper.h"
namespace dev
{
namespace eth
{
@ -47,3 +50,4 @@ void connectClients(Client& c1, Client& c2)
}
}
}

View File

@ -21,10 +21,15 @@
#pragma once
namespace dev
{
namespace eth
{
class Client;
void mine(Client& c, int numBlocks);
void connectClients(Client& c1, Client& c2);
}
}

View File

@ -25,9 +25,10 @@
#include <libethcore/SHA3.h>
#include <libethcore/CommonEth.h>
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);
}

View File

@ -24,7 +24,7 @@
#include <libethential/Common.h>
#include <libethential/FixedHash.h>
namespace eth
namespace dev
{
bytes rlp256(StringMap const& _s);

View File

@ -29,7 +29,8 @@
#include <boost/test/unit_test.hpp>
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;

View File

@ -25,7 +25,8 @@
#include <libethcore/Dagger.h>
using namespace std;
using namespace std::chrono;
using namespace eth;
using namespace dev;
using namespace dev::eth;
int daggerTest()
{

View File

@ -27,7 +27,8 @@
#include <libethereum/EthereumHost.h>
#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.
/*

View File

@ -28,7 +28,8 @@
#include <boost/test/unit_test.hpp>
using namespace std;
using namespace eth;
using namespace dev;
using namespace dev::eth;
namespace js = json_spirit;

View File

@ -27,7 +27,8 @@
#include <boost/test/unit_test.hpp>
using namespace std;
using namespace eth;
using namespace dev;
using namespace dev::eth;
namespace js = json_spirit;
BOOST_AUTO_TEST_CASE(hexPrefix_test)

View File

@ -38,7 +38,8 @@ int peerTest(int argc, char** argv);
#include <libethential/Log.h>
#include <libethcore/BlockInfo.h>
using namespace std;
using namespace eth;
using namespace dev;
using namespace dev::eth;
BOOST_AUTO_TEST_CASE(basic_tests)
{

View File

@ -27,7 +27,8 @@
#include <libethereum/EthereumHost.h>
#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).
/*

View File

@ -24,8 +24,8 @@
#include <thread>
#include <libp2p/Host.h>
using namespace std;
using namespace eth;
using namespace p2p;
using namespace dev;
using namespace dev::p2p;
int peerTest(int argc, char** argv)
{

18
rlp.cpp
View File

@ -30,10 +30,10 @@
#include <algorithm>
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);
}
}

View File

@ -26,7 +26,8 @@
#include <libethereum/State.h>
#include <libethereum/Defaults.h>
using namespace std;
using namespace eth;
using namespace dev;
using namespace dev::eth;
int stateTest()
{

View File

@ -29,22 +29,23 @@
#include <boost/test/unit_test.hpp>
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;

View File

@ -27,7 +27,8 @@
#include <libethereum/EthereumHost.h>
#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)

13
vm.cpp
View File

@ -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)
{