Fabcoin Core  0.16.2
P2P Digital Currency
TestUtils.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16  */
20 #pragma once
21 
22 #include <functional>
23 #include <string>
24 #include <json/json.h>
26 #include <libethereum/BlockChain.h>
27 #include <libethereum/ClientBase.h>
28 
29 namespace dev
30 {
31 namespace test
32 {
33 
34 // should be used for multithread tests
35 static SharedMutex x_boostTest;
36 #define ETH_CHECK_EQUAL(x, y) { dev::WriteGuard(x_boostTest); BOOST_CHECK_EQUAL(x, y); }
37 #define ETH_CHECK_EQUAL_COLLECTIONS(xb, xe, yb, ye) { dev::WriteGuard(x_boostTest); BOOST_CHECK_EQUAL_COLLECTIONS(xb, xe, yb, ye); }
38 #define ETH_REQUIRE(x) { dev::WriteGuard(x_boostTest); BOOST_REQUIRE(x); }
39 
41 {
43 
44 protected:
46 };
47 
49 {
50  void enumerateThreads(std::function<void()> callback) const;
51 };
52 
54 {
55  void enumerateBlockchains(std::function<void(Json::Value const&, dev::eth::BlockChain const&, dev::eth::State state)> callback) const;
56 };
57 
59 {
60  void enumerateClients(std::function<void(Json::Value const&, dev::eth::ClientBase&)> callback) const;
61 };
62 
63 // important BOOST TEST do have problems with thread safety!!!
64 // BOOST_CHECK is not thread safe
65 // BOOST_MESSAGE is not thread safe
66 // http://boost.2283326.n4.nabble.com/Is-boost-test-thread-safe-td3471644.html
67 // http://lists.boost.org/boost-users/2010/03/57691.php
68 // worth reading
69 // https://codecrafter.wordpress.com/2012/11/01/c-unit-test-framework-adapter-part-3/
71 {
72  void enumerateClients(std::function<void(Json::Value const&, dev::eth::ClientBase&)> callback) const;
73 };
74 
76 {
77 
78 };
79 
80 }
81 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
#define function(a, b, c, d, k, s)
Implements the blockchain database.
Definition: BlockChain.h:105
Model of an Ethereum state, essentially a facade for the trie.
Definition: State.h:161
Config::Value_type Value
boost::shared_mutex SharedMutex
Definition: Guards.h:39