mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
storage dump test
This commit is contained in:
parent
385408f038
commit
ae062ac119
38
jsonrpc.cpp
38
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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user