aboutsummaryrefslogtreecommitdiffstats
path: root/jsonrpc.cpp
diff options
context:
space:
mode:
authorMarek Kotewicz <marek.kotewicz@gmail.com>2014-11-14 01:52:21 +0800
committerMarek Kotewicz <marek.kotewicz@gmail.com>2014-11-14 01:52:21 +0800
commitae062ac119a5656fa4eb81ffb0b5984b350b7efe (patch)
tree63a9b55723ab08570c8d79695e6193d9355373ec /jsonrpc.cpp
parent385408f0386d9b1f99ad37f288a72f6ab612f2fe (diff)
downloaddexon-solidity-ae062ac119a5656fa4eb81ffb0b5984b350b7efe.tar.gz
dexon-solidity-ae062ac119a5656fa4eb81ffb0b5984b350b7efe.tar.zst
dexon-solidity-ae062ac119a5656fa4eb81ffb0b5984b350b7efe.zip
storage dump test
Diffstat (limited to 'jsonrpc.cpp')
-rw-r--r--jsonrpc.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/jsonrpc.cpp b/jsonrpc.cpp
index 3f552d47..d17c5a59 100644
--- a/jsonrpc.cpp
+++ b/jsonrpc.cpp
@@ -266,6 +266,44 @@ BOOST_AUTO_TEST_CASE(simple_contract)
BOOST_CHECK_EQUAL(result, "0x0000000000000000000000000000000000000000000000000000000000000007");
}
+BOOST_AUTO_TEST_CASE(contract_storage)
+{
+ cnote << "Testing jsonrpc contract storage...";
+ KeyPair kp = KeyPair::create();
+ web3->ethereum()->setAddress(kp.address());
+ jsonrpcServer->setAccounts({kp});
+
+ dev::eth::mine(*(web3->ethereum()), 1);
+
+ char const* sourceCode = R"(
+ contract test {
+ uint hello;
+ function writeHello(uint value) returns(bool d){
+ hello = value;
+ return true;
+ }
+ }
+ )";
+
+ 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 transact;
+ transact["to"] = contractAddress;
+ transact["data"] = "0x00000000000000000000000000000000000000000000000000000000000000003";
+ jsonrpcClient->eth_transact(transact);
+ dev::eth::mine(*(web3->ethereum()), 1);
+
+ Json::Value storage = jsonrpcClient->eth_storageAt(contractAddress);
+ BOOST_CHECK_EQUAL(storage.getMemberNames().size(), 1);
+ for (auto name: storage.getMemberNames())
+ BOOST_CHECK_EQUAL(storage[name].asString(), "0x03");
+}
+
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_SUITE_END()