Fabcoin Core  0.16.2
P2P Digital Currency
Test.cpp
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 */
23 #include "Test.h"
24 #include <jsonrpccpp/common/errors.h>
25 #include <jsonrpccpp/common/exception.h>
26 #include <libethereum/ClientTest.h>
28 
29 using namespace std;
30 using namespace dev;
31 using namespace dev::rpc;
32 using namespace jsonrpc;
33 
34 Test::Test(eth::Client& _eth): m_eth(_eth) {}
35 
37 {
38  try
39  {
40  Json::FastWriter fastWriter;
41  std::string output = fastWriter.write(param1);
43  }
44  catch (std::exception const&)
45  {
46  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INTERNAL_ERROR));
47  }
48 
49  return true;
50 }
51 
52 bool Test::test_mineBlocks(int _number)
53 {
54  try
55  {
56  asClientTest(m_eth).mineBlocks(_number);
57  }
58  catch (std::exception const&)
59  {
60  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INTERNAL_ERROR));
61  }
62 
63  return true;
64 }
65 
66 bool Test::test_modifyTimestamp(int _timestamp)
67 {
68  try
69  {
70  asClientTest(m_eth).modifyTimestamp(u256(_timestamp));
71  }
72  catch (std::exception const&)
73  {
74  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INTERNAL_ERROR));
75  }
76  return true;
77 }
78 
79 bool Test::test_addBlock(std::string const& _rlp)
80 {
81  try
82  {
84  }
85  catch (std::exception const&)
86  {
87  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INTERNAL_ERROR));
88  }
89  return true;
90 }
91 
92 bool Test::test_rewindToBlock(int _number)
93 {
94  try
95  {
96  m_eth.rewind(_number);
98  }
99  catch (std::exception const&)
100  {
101  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INTERNAL_ERROR));
102  }
103  return true;
104 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
void rewind(unsigned _n)
Rewind to a prior head.
Definition: Client.cpp:834
virtual bool test_modifyTimestamp(int _timestamp) override
Definition: Test.cpp:66
void modifyTimestamp(u256 const &_timestamp)
Definition: ClientTest.cpp:80
virtual bool test_rewindToBlock(int _number) override
Definition: Test.cpp:92
bool addBlock(std::string const &_rlp)
Definition: ClientTest.cpp:70
std::hash for asio::adress
Definition: Common.h:323
void mineBlocks(unsigned _count)
Definition: ClientTest.cpp:106
virtual bool test_addBlock(std::string const &_rlp) override
Definition: Test.cpp:79
ClientTest & asClientTest(Interface &_c)
Definition: ClientTest.cpp:30
Config::Value_type Value
Main API hub for interfacing with Ethereum.
Definition: Client.h:75
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Definition: Common.h:125
eth::Client & m_eth
Definition: Test.h:53
virtual bool test_mineBlocks(int _number) override
Definition: Test.cpp:52
virtual bool test_setChainParams(const Json::Value &param1) override
Definition: Test.cpp:36
void setChainParams(std::string const &_genesis)
Definition: ClientTest.cpp:52