mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
removed unnecessary methods from jsonrpc and added contract call tests
This commit is contained in:
parent
8e5b6d67cc
commit
5c67fd341b
28
jsonrpc.cpp
28
jsonrpc.cpp
@ -237,7 +237,35 @@ BOOST_AUTO_TEST_CASE(jsonrpc_transact)
|
||||
BOOST_CHECK_EQUAL(jsToDecimal(balanceString2), "750000000000000000");
|
||||
BOOST_CHECK_EQUAL(txAmount, balance2);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(simple_contract)
|
||||
{
|
||||
cnote << "Testing jsonrpc contract...";
|
||||
KeyPair kp = KeyPair::create();
|
||||
web3->ethereum()->setAddress(kp.address());
|
||||
jsonrpcServer->setAccounts({kp});
|
||||
|
||||
dev::eth::mine(*(web3->ethereum()), 1);
|
||||
|
||||
char const* sourceCode = "contract test {\n"
|
||||
" function f(uint a) returns(uint d) { return a * 7; }\n"
|
||||
"}\n";
|
||||
|
||||
string compiled = jsonrpcClient->eth_solidity(sourceCode);
|
||||
|
||||
Json::Value create;
|
||||
create["code"] = compiled;
|
||||
string contractAddress = jsonrpcClient->eth_transact(create);
|
||||
dev::eth::mine(*(web3->ethereum()), 1);
|
||||
|
||||
Json::Value call;
|
||||
call["to"] = contractAddress;
|
||||
call["data"] = "0x00000000000000000000000000000000000000000000000000000000000000001";
|
||||
string result = jsonrpcClient->eth_call(call);
|
||||
BOOST_CHECK_EQUAL(result, "0x0000000000000000000000000000000000000000000000000000000000000007");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
|
@ -191,33 +191,6 @@ p.append(param3);
|
||||
|
||||
}
|
||||
|
||||
std::string eth_contractCall(const std::string& param1, const std::string& param2) throw (jsonrpc::JsonRpcException)
|
||||
{
|
||||
Json::Value p;
|
||||
p.append(param1);
|
||||
p.append(param2);
|
||||
|
||||
Json::Value result = this->client->CallMethod("eth_contractCall",p);
|
||||
if (result.isString())
|
||||
return result.asString();
|
||||
else
|
||||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
|
||||
|
||||
}
|
||||
|
||||
std::string eth_contractCreate(const std::string& param1) throw (jsonrpc::JsonRpcException)
|
||||
{
|
||||
Json::Value p;
|
||||
p.append(param1);
|
||||
|
||||
Json::Value result = this->client->CallMethod("eth_contractCreate",p);
|
||||
if (result.isString())
|
||||
return result.asString();
|
||||
else
|
||||
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_CLIENT_INVALID_RESPONSE, result.toStyledString());
|
||||
|
||||
}
|
||||
|
||||
double eth_countAt(const std::string& param1) throw (jsonrpc::JsonRpcException)
|
||||
{
|
||||
Json::Value p;
|
||||
|
Loading…
Reference in New Issue
Block a user