From 672e56c7b5dc68363e61ab1ffc51ed34925ae52d Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 16 Oct 2014 03:46:47 +0200 Subject: [PATCH] common changes to unify apis --- libethrpc/EthStubServer.cpp | 44 ++++++++++++++++++----------- libethrpc/EthStubServer.h | 7 +++-- libethrpc/abstractethstubserver.h | 30 ++++++++++---------- libethrpc/eth.js | 43 +++++++++++++++++++--------- libethrpc/spec.json | 10 +++---- libqethereum/QEthereum.cpp | 47 ++++++++++++++++++++----------- libqethereum/QEthereum.h | 20 +++++++------ test/ethstubclient.h | 20 ++++++------- test/jsonrpc.cpp | 31 +++++++------------- 9 files changed, 144 insertions(+), 108 deletions(-) diff --git a/libethrpc/EthStubServer.cpp b/libethrpc/EthStubServer.cpp index f9f76144c..f57c834fd 100644 --- a/libethrpc/EthStubServer.cpp +++ b/libethrpc/EthStubServer.cpp @@ -110,12 +110,23 @@ std::string EthStubServer::balanceAt(const string &address, const int& block) return toJS(client()->balanceAt(jsToAddress(address), block)); } -//TODO BlockDetails? -Json::Value EthStubServer::block(const string &numberOrHash) +dev::FixedHash<32> EthStubServer::numberOrHash(Json::Value const &json) const { - auto n = jsToU256(numberOrHash); - auto h = n < client()->number() ? client()->hashFromNumber((unsigned)n) : ::jsToFixed<32>(numberOrHash); - return toJson(client()->blockInfo(h)); + dev::FixedHash<32> hash; + if (!json["hash"].empty()) + hash = jsToFixed<32>(json["hash"].asString()); + else if (!json["number"].empty()) + hash = client()->hashFromNumber((unsigned)json["number"].asInt()); + return hash; +} + +Json::Value EthStubServer::block(const Json::Value ¶ms) +{ + if (!client()) + return ""; + + auto hash = numberOrHash(params); + return toJson(client()->blockInfo(hash)); } static TransactionJS toTransaction(const Json::Value &json) @@ -394,21 +405,22 @@ std::string EthStubServer::transact(const Json::Value &json) return ret; } -Json::Value EthStubServer::transaction(const int &i, const string &numberOrHash) +Json::Value EthStubServer::transaction(const int &i, const Json::Value ¶ms) { - if (!client()){ - return Json::Value(); - } - auto n = jsToU256(numberOrHash); - auto h = n < client()->number() ? client()->hashFromNumber((unsigned)n) : jsToFixed<32>(numberOrHash); - return toJson(client()->transaction(h, i)); + if (!client()) + return ""; + + auto hash = numberOrHash(params); + return toJson(client()->transaction(hash, i)); } -Json::Value EthStubServer::uncle(const int &i, const string &numberOrHash) +Json::Value EthStubServer::uncle(const int &i, const Json::Value ¶ms) { - auto n = jsToU256(numberOrHash); - auto h = n < client()->number() ? client()->hashFromNumber((unsigned)n) : jsToFixed<32>(numberOrHash); - return client() ? toJson(client()->uncle(h, i)) : Json::Value(); + if (!client()) + return ""; + + auto hash = numberOrHash(params); + return toJson(client()->uncle(hash, i)); } //TODO watch! diff --git a/libethrpc/EthStubServer.h b/libethrpc/EthStubServer.h index aec1757ac..8fe93f078 100644 --- a/libethrpc/EthStubServer.h +++ b/libethrpc/EthStubServer.h @@ -37,7 +37,7 @@ public: EthStubServer(jsonrpc::AbstractServerConnector* _conn, dev::WebThreeDirect& _web3); virtual std::string balanceAt(const std::string& address, const int& block); - virtual Json::Value block(const std::string& numberOrHash); + virtual Json::Value block(const Json::Value& params); virtual std::string call(const Json::Value& json); virtual std::string codeAt(const std::string& address, const int& block); virtual std::string coinbase(); @@ -64,8 +64,8 @@ public: virtual std::string toDecimal(const std::string& s); virtual std::string toFixed(const double& s); virtual std::string transact(const Json::Value& json); - virtual Json::Value transaction(const int& i, const std::string& numberOrHash); - virtual Json::Value uncle(const int& i, const std::string& numberOrHash); + virtual Json::Value transaction(const int& i, const Json::Value& params); + virtual Json::Value uncle(const int& i, const Json::Value ¶ms); virtual std::string watch(const std::string& json); void setKeys(std::vector _keys) { m_keys = _keys; } @@ -74,4 +74,5 @@ private: dev::WebThreeDirect& m_web3; std::vector m_keys; Json::Value jsontypeToValue(int); + dev::FixedHash<32> numberOrHash(Json::Value const &_json) const; }; diff --git a/libethrpc/abstractethstubserver.h b/libethrpc/abstractethstubserver.h index db0c57c98..24c594b8c 100644 --- a/libethrpc/abstractethstubserver.h +++ b/libethrpc/abstractethstubserver.h @@ -14,7 +14,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServer(conn) { this->bindAndAddMethod(new jsonrpc::Procedure("balanceAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "address",jsonrpc::JSON_STRING,"block",jsonrpc::JSON_INTEGER, NULL), &AbstractEthStubServer::balanceAtI); - this->bindAndAddMethod(new jsonrpc::Procedure("block", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "numberOrHash",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::blockI); + this->bindAndAddMethod(new jsonrpc::Procedure("block", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "params",jsonrpc::JSON_OBJECT, NULL), &AbstractEthStubServer::blockI); this->bindAndAddMethod(new jsonrpc::Procedure("call", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "json",jsonrpc::JSON_OBJECT, NULL), &AbstractEthStubServer::callI); this->bindAndAddMethod(new jsonrpc::Procedure("codeAt", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "address",jsonrpc::JSON_STRING,"block",jsonrpc::JSON_INTEGER, NULL), &AbstractEthStubServer::codeAtI); this->bindAndAddMethod(new jsonrpc::Procedure("coinbase", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::coinbaseI); @@ -27,7 +27,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServerbindAndAddMethod(new jsonrpc::Procedure("keys", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_ARRAY, NULL), &AbstractEthStubServer::keysI); this->bindAndAddMethod(new jsonrpc::Procedure("listening", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_BOOLEAN, NULL), &AbstractEthStubServer::listeningI); this->bindAndAddMethod(new jsonrpc::Procedure("lll", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "s",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::lllI); - this->bindAndAddMethod(new jsonrpc::Procedure("messages", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_ARRAY, "json",jsonrpc::JSON_OBJECT, NULL), &AbstractEthStubServer::messagesI); + this->bindAndAddMethod(new jsonrpc::Procedure("messages", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_ARRAY, "params",jsonrpc::JSON_OBJECT, NULL), &AbstractEthStubServer::messagesI); this->bindAndAddMethod(new jsonrpc::Procedure("mining", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_BOOLEAN, NULL), &AbstractEthStubServer::miningI); this->bindAndAddMethod(new jsonrpc::Procedure("number", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_INTEGER, NULL), &AbstractEthStubServer::numberI); this->bindAndAddMethod(new jsonrpc::Procedure("peerCount", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_INTEGER, NULL), &AbstractEthStubServer::peerCountI); @@ -41,9 +41,9 @@ class AbstractEthStubServer : public jsonrpc::AbstractServerbindAndAddMethod(new jsonrpc::Procedure("toDecimal", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "s",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::toDecimalI); this->bindAndAddMethod(new jsonrpc::Procedure("toFixed", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "s",jsonrpc::JSON_REAL, NULL), &AbstractEthStubServer::toFixedI); this->bindAndAddMethod(new jsonrpc::Procedure("transact", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "json",jsonrpc::JSON_OBJECT, NULL), &AbstractEthStubServer::transactI); - this->bindAndAddMethod(new jsonrpc::Procedure("transaction", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "i",jsonrpc::JSON_INTEGER,"numberOrHash",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::transactionI); - this->bindAndAddMethod(new jsonrpc::Procedure("uncle", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "i",jsonrpc::JSON_INTEGER,"numberOrHash",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::uncleI); - this->bindAndAddMethod(new jsonrpc::Procedure("watch", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "json",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::watchI); + this->bindAndAddMethod(new jsonrpc::Procedure("transaction", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "i",jsonrpc::JSON_INTEGER,"params",jsonrpc::JSON_OBJECT, NULL), &AbstractEthStubServer::transactionI); + this->bindAndAddMethod(new jsonrpc::Procedure("uncle", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_OBJECT, "i",jsonrpc::JSON_INTEGER,"params",jsonrpc::JSON_OBJECT, NULL), &AbstractEthStubServer::uncleI); + this->bindAndAddMethod(new jsonrpc::Procedure("watch", jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, "params",jsonrpc::JSON_STRING, NULL), &AbstractEthStubServer::watchI); } @@ -54,7 +54,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServerblock(request["numberOrHash"].asString()); + response = this->block(request["params"]); } inline virtual void callI(const Json::Value& request, Json::Value& response) @@ -119,7 +119,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServermessages(request["json"]); + response = this->messages(request["params"]); } inline virtual void miningI(const Json::Value& request, Json::Value& response) @@ -189,22 +189,22 @@ class AbstractEthStubServer : public jsonrpc::AbstractServertransaction(request["i"].asInt(), request["numberOrHash"].asString()); + response = this->transaction(request["i"].asInt(), request["params"]); } inline virtual void uncleI(const Json::Value& request, Json::Value& response) { - response = this->uncle(request["i"].asInt(), request["numberOrHash"].asString()); + response = this->uncle(request["i"].asInt(), request["params"]); } inline virtual void watchI(const Json::Value& request, Json::Value& response) { - response = this->watch(request["json"].asString()); + response = this->watch(request["params"].asString()); } virtual std::string balanceAt(const std::string& address, const int& block) = 0; - virtual Json::Value block(const std::string& numberOrHash) = 0; + virtual Json::Value block(const Json::Value& params) = 0; virtual std::string call(const Json::Value& json) = 0; virtual std::string codeAt(const std::string& address, const int& block) = 0; virtual std::string coinbase() = 0; @@ -217,7 +217,7 @@ class AbstractEthStubServer : public jsonrpc::AbstractServeraddress()) : ""; } -QString QEthereum::number() const +unsigned QEthereum::number() const { - return m_client ? QString::number(client()->number() + 1) : ""; + return client() ? client()->number() + 1 : 0; } QString QEthereum::account() const @@ -367,7 +367,6 @@ static QString toJson(dev::eth::BlockInfo const& _bi) { QJsonObject v; v["hash"] = toQJS(_bi.hash); - v["parentHash"] = toQJS(_bi.parentHash); v["sha3Uncles"] = toQJS(_bi.sha3Uncles); v["miner"] = toQJS(_bi.coinbaseAddress); @@ -389,7 +388,6 @@ static QString toJson(dev::eth::Transaction const& _bi) { QJsonObject v; v["hash"] = toQJS(_bi.sha3()); - v["input"] = ::fromBinary(_bi.data); v["to"] = toQJS(_bi.receiveAddress); v["from"] = toQJS(_bi.sender()); @@ -401,25 +399,42 @@ static QString toJson(dev::eth::Transaction const& _bi) return QString::fromUtf8(QJsonDocument(v).toJson()); } -QString QEthereum::getUncle(QString _numberOrHash, int _i) const +dev::FixedHash<32> QEthereum::numberOrHash(QString const &_json) const +{ + QJsonObject f = QJsonDocument::fromJson(_json.toUtf8()).object(); + dev::FixedHash<32> hash; + if (f.contains("hash")) + hash = ::toFixed<32>(f["hash"].toString()); + else if (f.contains("number")) + hash = client()->hashFromNumber((unsigned)f["number"].toInt()); + return hash; +} + +QString QEthereum::_private_getBlock(QString _json) const { - auto n = toU256(_numberOrHash); - auto h = n < m_client->number() ? m_client->hashFromNumber((unsigned)n) : ::toFixed<32>(_numberOrHash); - return m_client ? toJson(m_client->uncle(h, _i)) : ""; + if (!client()) + return ""; + + auto hash = numberOrHash(_json); + return toJson(client()->blockInfo(hash), client()->blockDetails(hash)); } -QString QEthereum::getTransaction(QString _numberOrHash, int _i) const +QString QEthereum::_private_getTransaction(QString _json, int _i) const { - auto n = toU256(_numberOrHash); - auto h = n < m_client->number() ? m_client->hashFromNumber((unsigned)n) : ::toFixed<32>(_numberOrHash); - return m_client ? toJson(m_client->transaction(h, _i)) : ""; + if (!client()) + return ""; + + auto hash = numberOrHash(_json); + return toJson(client()->transaction(hash, _i)); } -QString QEthereum::getBlock(QString _numberOrHash) const +QString QEthereum::_private_getUncle(QString _json, int _i) const { - auto n = toU256(_numberOrHash); - auto h = n < m_client->number() ? m_client->hashFromNumber((unsigned)n) : ::toFixed<32>(_numberOrHash); - return m_client ? toJson(m_client->blockInfo(h), m_client->blockDetails(h)) : ""; + if (!client()) + return ""; + + auto hash = numberOrHash(_json); + return toJson(client()->uncle(hash, _i)); } QString QEthereum::_private_getMessages(QString _json) const diff --git a/libqethereum/QEthereum.h b/libqethereum/QEthereum.h index fa5ed2d07..9cac3bd3c 100644 --- a/libqethereum/QEthereum.h +++ b/libqethereum/QEthereum.h @@ -148,9 +148,9 @@ public: Q_INVOKABLE QString/*dev::u256*/ stateAt(QString/*dev::Address*/ _a, QString/*dev::u256*/ _p) const; Q_INVOKABLE QString/*dev::u256*/ codeAt(QString/*dev::Address*/ _a) const; - Q_INVOKABLE QString/*json*/ getBlock(QString _numberOrHash/*unsigned if < number(), hash otherwise*/) const; - Q_INVOKABLE QString/*json*/ getTransaction(QString _numberOrHash/*unsigned if < number(), hash otherwise*/, int _index) const; - Q_INVOKABLE QString/*json*/ getUncle(QString _numberOrHash/*unsigned if < number(), hash otherwise*/, int _index) const; + Q_INVOKABLE QString/*json*/ _private_getBlock(QString _json) const; + Q_INVOKABLE QString/*json*/ _private_getTransaction(QString _json, int _index) const; + Q_INVOKABLE QString/*json*/ _private_getUncle(QString _json, int _index) const; Q_INVOKABLE QString/*json*/ _private_getMessages(QString _attribs/*json*/) const; @@ -169,7 +169,7 @@ public: QString/*dev::Address*/ coinbase() const; QString/*dev::u256*/ gasPrice() const { return toQJS(10 * dev::eth::szabo); } - QString/*dev::u256*/ number() const; + unsigned/*dev::u256*/ number() const; int getDefault() const; QString/*dev::KeyPair*/ key() const; @@ -205,11 +205,12 @@ private: Q_PROPERTY(QStringList keys READ keys NOTIFY keysChanged) Q_PROPERTY(unsigned peerCount READ peerCount NOTIFY miningChanged) Q_PROPERTY(int defaultBlock READ getDefault WRITE setDefault) - Q_PROPERTY(QString number READ number NOTIFY watchChanged) + Q_PROPERTY(unsigned number READ number NOTIFY watchChanged) dev::eth::Interface* m_client; std::vector m_watches; QList m_accounts; + dev::FixedHash<32> numberOrHash(QString const &_json) const; }; class QWhisper: public QObject @@ -279,11 +280,14 @@ private: frame->evaluateJavaScript("eth.makeTransact = function() { var args = Array.prototype.slice.call(arguments, 0, -1); f = arguments[arguments.length - 1]; window.setTimeout(function () { if (f) { f(eth.transact.apply(null, args)); }},0);}"); \ frame->evaluateJavaScript("eth.call = function(a) { var ret = eth.doCallJson(JSON.stringify(a)); return ret; }"); \ frame->evaluateJavaScript("eth.makeCall = function() { var args = Array.prototype.slice.call(arguments, 0, -1); f = arguments[arguments.length - 1]; window.setTimeout(function () { if (f) { f(eth.call.apply(null, args)); }},0);}"); \ + frame->evaluateJavaScript("eth.block = function(a) { return JSON.parse(eth._private_getBlock(JSON.stringify(a))); }"); \ + frame->evaluateJavaScript("eth.getBlock = function() { var args = Array.prototype.slice.call(arguments, 0, -1); f = arguments[arguments.length - 1]; window.setTimeout(function () { if (f) { f(eth.block.apply(null, args)); }},0);}"); \ + frame->evaluateJavaScript("eth.transaction = function(a, i) { return JSON.parse(eth._private_getTransaction(JSON.stringify(a), i)); }"); \ + frame->evaluateJavaScript("eth.getTransaction = function() { var args = Array.prototype.slice.call(arguments, 0, -1); f = arguments[arguments.length - 1]; window.setTimeout(function () { if (f) { f(eth.transaction.apply(null, args)); }},0);}"); \ + frame->evaluateJavaScript("eth.uncle = function(a, i) { return JSON.parse(eth._private_getUncle(JSON.stringify(a), i)); }"); \ + frame->evaluateJavaScript("eth.getUncle = function() { var args = Array.prototype.slice.call(arguments, 0, -1); f = arguments[arguments.length - 1]; window.setTimeout(function () { if (f) { f(eth.uncle.apply(null, args)); }},0);}"); \ frame->evaluateJavaScript("eth.makeWatch = function(a) { var ww = eth.newWatch(a); var ret = { w: ww }; ret.uninstall = function() { eth.killWatch(w); }; ret.changed = function(f) { eth.watchChanged.connect(function(nw) { if (nw == ww) f() }); }; ret.messages = function() { return JSON.parse(eth.watchMessages(this.w)) }; return ret; }"); \ frame->evaluateJavaScript("eth.watch = function(a) { return eth.makeWatch(JSON.stringify(a)) }"); \ - frame->evaluateJavaScript("eth.block = function(a) { return JSON.parse(eth.getBlock(a)); }"); \ - frame->evaluateJavaScript("eth.transaction = function(a) { return JSON.parse(eth.getTransaction(a)); }"); \ - frame->evaluateJavaScript("eth.uncle = function(a) { return JSON.parse(eth.getUncle(a)); }"); \ frame->evaluateJavaScript("shh.makeWatch = function(a) { var ww = shh.newWatch(a); var ret = { w: ww }; ret.uninstall = function() { shh.killWatch(w); }; ret.changed = function(f) { shh.watchChanged.connect(function(nw) { if (nw == ww) f() }); }; ret.messages = function() { return JSON.parse(shh.watchMessages(this.w)) }; return ret; }"); \ frame->evaluateJavaScript("shh.watch = function(a) { return shh.makeWatch(JSON.stringify(a)) }"); \ } diff --git a/test/ethstubclient.h b/test/ethstubclient.h index e2f1fb906..a9c46a0bc 100644 --- a/test/ethstubclient.h +++ b/test/ethstubclient.h @@ -33,10 +33,10 @@ p["block"] = block; } - Json::Value block(const std::string& numberOrHash) throw (jsonrpc::JsonRpcException) + Json::Value block(const Json::Value& params) throw (jsonrpc::JsonRpcException) { Json::Value p; - p["numberOrHash"] = numberOrHash; + p["params"] = params; Json::Value result = this->client->CallMethod("block",p); if (result.isObject()) @@ -199,10 +199,10 @@ p["s"] = s; } - Json::Value messages(const Json::Value& json) throw (jsonrpc::JsonRpcException) + Json::Value messages(const Json::Value& params) throw (jsonrpc::JsonRpcException) { Json::Value p; - p["json"] = json; + p["params"] = params; Json::Value result = this->client->CallMethod("messages",p); if (result.isArray()) @@ -380,11 +380,11 @@ p["storage"] = storage; } - Json::Value transaction(const int& i, const std::string& numberOrHash) throw (jsonrpc::JsonRpcException) + Json::Value transaction(const int& i, const Json::Value& params) throw (jsonrpc::JsonRpcException) { Json::Value p; p["i"] = i; -p["numberOrHash"] = numberOrHash; +p["params"] = params; Json::Value result = this->client->CallMethod("transaction",p); if (result.isObject()) @@ -394,11 +394,11 @@ p["numberOrHash"] = numberOrHash; } - Json::Value uncle(const int& i, const std::string& numberOrHash) throw (jsonrpc::JsonRpcException) + Json::Value uncle(const int& i, const Json::Value& params) throw (jsonrpc::JsonRpcException) { Json::Value p; p["i"] = i; -p["numberOrHash"] = numberOrHash; +p["params"] = params; Json::Value result = this->client->CallMethod("uncle",p); if (result.isObject()) @@ -408,10 +408,10 @@ p["numberOrHash"] = numberOrHash; } - std::string watch(const std::string& json) throw (jsonrpc::JsonRpcException) + std::string watch(const std::string& params) throw (jsonrpc::JsonRpcException) { Json::Value p; - p["json"] = json; + p["params"] = params; Json::Value result = this->client->CallMethod("watch",p); if (result.isString()) diff --git a/test/jsonrpc.cpp b/test/jsonrpc.cpp index 930b5686f..081f1ccf3 100644 --- a/test/jsonrpc.cpp +++ b/test/jsonrpc.cpp @@ -58,11 +58,7 @@ BOOST_AUTO_TEST_CASE(jsonrpc_balanceAt) dev::KeyPair key = KeyPair::create(); auto address = key.address(); string balance = jsonrpcClient->balanceAt(toJS(address), 0); - BOOST_CHECK_EQUAL(jsToDecimal(toJS(web3.ethereum()->balanceAt(address))), balance); -} - -BOOST_AUTO_TEST_CASE(jsonrpc_block) -{ + BOOST_CHECK_EQUAL(toJS(web3.ethereum()->balanceAt(address)), balance); } BOOST_AUTO_TEST_CASE(jsonrpc_call) @@ -162,17 +158,23 @@ BOOST_AUTO_TEST_CASE(jsonrpc_keys) BOOST_AUTO_TEST_CASE(jsonrpc_lll) { + } BOOST_AUTO_TEST_CASE(jsonrpc_messages) { + cnote << "Testing jsonrpc messages..."; + Json::Value msgs = jsonrpcClient->messages(Json::Value()); + auto messages = web3.ethereum()->messages(dev::eth::MessageFilter()); + BOOST_CHECK_EQUAL(msgs.isArray(), true); + BOOST_CHECK_EQUAL(msgs.size(), messages.size()); } BOOST_AUTO_TEST_CASE(jsonrpc_number) { - cnote << "Testing jsonrpc number..."; - int number = jsonrpcClient->number(); - BOOST_CHECK_EQUAL(number, web3.ethereum()->number() + 1); + cnote << "Testing jsonrpc number..."; + int number = jsonrpcClient->number(); + BOOST_CHECK_EQUAL(number, web3.ethereum()->number() + 1); } BOOST_AUTO_TEST_CASE(jsonrpc_number2) @@ -293,19 +295,6 @@ BOOST_AUTO_TEST_CASE(jsonrpc_transact) BOOST_CHECK_EQUAL(txAmount, jsToU256(messages[0u]["value"].asString())); } -BOOST_AUTO_TEST_CASE(jsonrpc_transaction) -{ - // TODO! not working? -// auto messages = jsonrpcClient->messages(Json::Value()); -// auto transactionNumber = messages[0u]["path"][0u].asInt(); -// auto transactionBlock = messages[0u]["block"].asString(); -// Json::Value p = jsonrpcClient->transaction(transactionNumber, transactionBlock); -} - -BOOST_AUTO_TEST_CASE(jsonrpc_uncle) -{ -} - BOOST_AUTO_TEST_CASE(jsonrpc_watch) {