mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
jsornrpc tests in progress
This commit is contained in:
parent
d47f9be775
commit
95a3a06f33
179
jsonrpc.cpp
179
jsonrpc.cpp
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
#if ETH_JSONRPC && 1
|
||||
//#if ETH_JSONRPC && 1
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <libdevcore/Log.h>
|
||||
@ -21,6 +21,10 @@ namespace js = json_spirit;
|
||||
|
||||
namespace jsonrpc_tests {
|
||||
|
||||
string name = "Ethereum(++) tests";
|
||||
string dbPath;
|
||||
dev::WebThreeDirect web3(name, dbPath);
|
||||
|
||||
KeyPair us;
|
||||
auto_ptr<EthStubServer> jsonrpcServer;
|
||||
auto_ptr<EthStubClient> jsonrpcClient;
|
||||
@ -30,9 +34,7 @@ struct JsonrpcFixture {
|
||||
JsonrpcFixture()
|
||||
{
|
||||
cnote << "setup jsonrpc";
|
||||
string name = "Ethereum(++) tests";
|
||||
string dbPath;
|
||||
dev::WebThreeDirect web3(name, dbPath);
|
||||
|
||||
web3.setIdealPeerCount(5);
|
||||
|
||||
us = KeyPair::create();
|
||||
@ -50,6 +52,71 @@ struct JsonrpcFixture {
|
||||
|
||||
BOOST_GLOBAL_FIXTURE(JsonrpcFixture)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_balanceAt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_block)
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_call)
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_coinbase)
|
||||
{
|
||||
cnote << "Testing jsonrpc coinbase...";
|
||||
string coinbase = jsonrpcClient->coinbase();
|
||||
BOOST_CHECK_EQUAL(jsToAddress(coinbase), web3.ethereum()->address());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_countAt)
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_defaultBlock)
|
||||
{
|
||||
cnote << "Testing jsonrpc defaultBlock...";
|
||||
int defaultBlock = jsonrpcClient->defaultBlock();
|
||||
BOOST_CHECK_EQUAL(defaultBlock, web3.ethereum()->getDefault());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_fromAscii)
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_fromFixed)
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_gasPrice)
|
||||
{
|
||||
cnote << "Testing jsonrpc gasPrice...";
|
||||
string gasPrice = jsonrpcClient->gasPrice();
|
||||
BOOST_CHECK_EQUAL(gasPrice, toJS(10 * dev::eth::szabo));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_isListening)
|
||||
{
|
||||
//TODO
|
||||
cnote << "Testing jsonrpc isListening...";
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_isMining)
|
||||
{
|
||||
cnote << "Testing jsonrpc isMining...";
|
||||
|
||||
web3.ethereum()->startMining();
|
||||
bool miningOn = jsonrpcClient->isMining();
|
||||
BOOST_CHECK_EQUAL(miningOn, web3.ethereum()->isMining());
|
||||
|
||||
web3.ethereum()->stopMining();
|
||||
bool miningOff = jsonrpcClient->isMining();
|
||||
BOOST_CHECK_EQUAL(miningOff, web3.ethereum()->isMining());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_key)
|
||||
{
|
||||
cnote << "Testing jsonrpc key...";
|
||||
@ -67,10 +134,112 @@ BOOST_AUTO_TEST_CASE(jsonrpc_keys)
|
||||
BOOST_CHECK_EQUAL(jsToSecret(keys[0u].asString()) , us.secret());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_lll)
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_messages)
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_number)
|
||||
{
|
||||
cnote << "Testing jsonrpc number...";
|
||||
int number = jsonrpcClient->number();
|
||||
BOOST_CHECK_EQUAL(number, web3.ethereum()->number() + 1);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_peerCount)
|
||||
{
|
||||
cnote << "Testing jsonrpc peerCount...";
|
||||
//TODO
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_secretToAddress)
|
||||
{
|
||||
cnote << "Testing jsonrpc secretToAddress...";
|
||||
string address = jsonrpcClient->secretToAddress(toJS(us.secret()));
|
||||
BOOST_CHECK_EQUAL(jsToAddress(address), us.address());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_setListening)
|
||||
{
|
||||
cnote << "Testing jsonrpc setListening...";
|
||||
//TODO
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_setMining)
|
||||
{
|
||||
cnote << "Testing jsonrpc setMining...";
|
||||
|
||||
jsonrpcClient->setMining(true);
|
||||
BOOST_CHECK_EQUAL(web3.ethereum()->isMining(), true);
|
||||
|
||||
jsonrpcClient->setMining(false);
|
||||
BOOST_CHECK_EQUAL(web3.ethereum()->isMining(), false);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_sha3)
|
||||
{
|
||||
cnote << "Testing jsonrpc sha3...";
|
||||
string testString = "1234567890987654";
|
||||
string sha3 = jsonrpcClient->sha3(testString);
|
||||
BOOST_CHECK_EQUAL(jsToFixed<32>(sha3), dev::eth::sha3(jsToBytes(testString)));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_stateAt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_toAscii)
|
||||
{
|
||||
cnote << "Testing jsonrpc toAscii...";
|
||||
string testString = "1234567890987654";
|
||||
string ascii = jsonrpcClient->toAscii(testString);
|
||||
BOOST_CHECK_EQUAL(jsToBinary(testString), ascii);
|
||||
BOOST_CHECK_EQUAL(testString, jsFromBinary(ascii)); // failing!
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_toDecimal)
|
||||
{
|
||||
cnote << "Testing jsonrpc toDecimal...";
|
||||
string testString = "1234567890987654";
|
||||
string decimal = jsonrpcClient->toDecimal(testString);
|
||||
BOOST_CHECK_EQUAL(jsToDecimal(testString), decimal);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_toFixed)
|
||||
{
|
||||
cnote << "Testing jsonrpc toFixed...";
|
||||
double testValue = 123567;
|
||||
string fixed = jsonrpcClient->toFixed(testValue);
|
||||
BOOST_CHECK_EQUAL(jsToFixed(testValue), fixed);
|
||||
BOOST_CHECK_EQUAL(testValue, jsFromFixed(fixed));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_transact)
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_transaction)
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_uncle)
|
||||
{
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(jsonrpc_watch)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user