aboutsummaryrefslogtreecommitdiffstats
path: root/jsonrpc.cpp
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2014-11-13 19:25:49 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2014-11-13 19:26:52 +0800
commit5c67fd341b99e53d8b80a2db13007ee1a73cabf9 (patch)
treeb4b487d99d455662b510c4fca9b62ea828f25998 /jsonrpc.cpp
parent8e5b6d67cc691ab102fcee85348ad290ebef9cd6 (diff)
downloaddexon-solidity-5c67fd341b99e53d8b80a2db13007ee1a73cabf9.tar.gz
dexon-solidity-5c67fd341b99e53d8b80a2db13007ee1a73cabf9.tar.zst
dexon-solidity-5c67fd341b99e53d8b80a2db13007ee1a73cabf9.zip
removed unnecessary methods from jsonrpc and added contract call tests
Diffstat (limited to 'jsonrpc.cpp')
-rw-r--r--jsonrpc.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/jsonrpc.cpp b/jsonrpc.cpp
index 4c748a95..3f552d47 100644
--- a/jsonrpc.cpp
+++ b/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()