Skip to content
This repository has been archived by the owner on Dec 30, 2024. It is now read-only.

testclient: setChainParams #177

Merged
merged 2 commits into from
Jun 9, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion eth/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,11 @@ int main(int argc, char** argv)

AddressHash allowedDestinations;

auto authenticator = [&](TransactionSkeleton const& _t, bool isProxy) -> bool {
std::function<bool(TransactionSkeleton const&, bool)> authenticator;
if (testingMode)
authenticator = [](TransactionSkeleton const&, bool) -> bool { return true; };
else
authenticator = [&](TransactionSkeleton const& _t, bool isProxy) -> bool {
// "unlockAccount" functionality is done in the AccountHolder.
Copy link
Contributor

@chriseth chriseth Jun 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still has to be properly indented.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean put it inside {} ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, shift the body of the function one tab to the right.

if (!alwaysConfirm || allowedDestinations.count(_t.to))
return true;
Expand Down
17 changes: 17 additions & 0 deletions libweb3jsonrpc/Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <jsonrpccpp/common/errors.h>
#include <jsonrpccpp/common/exception.h>
#include <libethereum/ClientTest.h>
#include <libethereum/ChainParams.h>

using namespace std;
using namespace dev;
Expand All @@ -32,6 +33,22 @@ using namespace jsonrpc;

Test::Test(eth::Client& _eth): m_eth(_eth) {}

bool Test::test_setChainParams(Json::Value const& param1)
{
try
{
Json::FastWriter fastWriter;
std::string output = fastWriter.write(param1);
asClientTest(m_eth).setChainParams(output);
}
catch (std::exception const&)
{
BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INTERNAL_ERROR));
}

return true;
}

bool Test::test_mineBlocks(int _number)
{
try
Expand Down
1 change: 1 addition & 0 deletions libweb3jsonrpc/Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Test: public TestFace
return RPCModules{RPCModule{"test", "1.0"}};
}

virtual bool test_setChainParams(const Json::Value &param1) override;
virtual bool test_mineBlocks(int _number) override;
virtual bool test_modifyTimestamp(int _timestamp) override;
virtual bool test_addBlock(std::string const& _rlp) override;
Expand Down
6 changes: 6 additions & 0 deletions libweb3jsonrpc/TestFace.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ namespace dev {
public:
TestFace()
{
this->bindAndAddMethod(jsonrpc::Procedure("test_setChainParams", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_OBJECT, NULL), &dev::rpc::TestFace::test_setChainParamsI);
this->bindAndAddMethod(jsonrpc::Procedure("test_mineBlocks", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &dev::rpc::TestFace::test_mineBlocksI);
this->bindAndAddMethod(jsonrpc::Procedure("test_modifyTimestamp", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &dev::rpc::TestFace::test_modifyTimestampI);
this->bindAndAddMethod(jsonrpc::Procedure("test_addBlock", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_STRING, NULL), &dev::rpc::TestFace::test_addBlockI);
this->bindAndAddMethod(jsonrpc::Procedure("test_rewindToBlock", jsonrpc::PARAMS_BY_POSITION, jsonrpc::JSON_BOOLEAN, "param1",jsonrpc::JSON_INTEGER, NULL), &dev::rpc::TestFace::test_rewindToBlockI);
}

inline virtual void test_setChainParamsI(const Json::Value &request, Json::Value &response)
{
response = this->test_setChainParams(request[0u]);
}
inline virtual void test_mineBlocksI(const Json::Value &request, Json::Value &response)
{
response = this->test_mineBlocks(request[0u].asInt());
Expand All @@ -36,6 +41,7 @@ namespace dev {
{
response = this->test_rewindToBlock(request[0u].asInt());
}
virtual bool test_setChainParams(const Json::Value& param1) = 0;
virtual bool test_mineBlocks(int param1) = 0;
virtual bool test_modifyTimestamp(int param1) = 0;
virtual bool test_addBlock(const std::string& param1) = 0;
Expand Down
1 change: 1 addition & 0 deletions libweb3jsonrpc/test.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
{ "name": "test_setChainParams", "params": [{}], "order": [], "returns": false},
{ "name": "test_mineBlocks", "params": [0], "returns": false },
{ "name": "test_modifyTimestamp", "params": [0], "returns": false },
{ "name": "test_addBlock", "params": [""], "returns": false },
Expand Down