mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Remove direct bitcoin calls from qt/rpcconsole.cpp
This commit is contained in:
parent
80286d777a
commit
a19c1f8b88
@ -15,6 +15,7 @@
|
||||
#include <netaddress.h>
|
||||
#include <netbase.h>
|
||||
#include <primitives/block.h>
|
||||
#include <rpc/server.h>
|
||||
#include <scheduler.h>
|
||||
#include <sync.h>
|
||||
#include <txmempool.h>
|
||||
@ -34,6 +35,7 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <univalue.h>
|
||||
|
||||
class CWallet;
|
||||
|
||||
@ -114,6 +116,29 @@ class NodeImpl : public Node
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool ban(const CNetAddr& net_addr, BanReason reason, int64_t ban_time_offset) override
|
||||
{
|
||||
if (g_connman) {
|
||||
g_connman->Ban(net_addr, reason, ban_time_offset);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool unban(const CSubNet& ip) override
|
||||
{
|
||||
if (g_connman) {
|
||||
g_connman->Unban(ip);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool disconnect(NodeId id) override
|
||||
{
|
||||
if (g_connman) {
|
||||
return g_connman->DisconnectNode(id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
int64_t getTotalBytesRecv() override { return g_connman ? g_connman->GetTotalBytesRecv() : 0; }
|
||||
int64_t getTotalBytesSent() override { return g_connman ? g_connman->GetTotalBytesSent() : 0; }
|
||||
size_t getMempoolSize() override { return ::mempool.size(); }
|
||||
@ -168,6 +193,17 @@ class NodeImpl : public Node
|
||||
}
|
||||
}
|
||||
bool getNetworkActive() override { return g_connman && g_connman->GetNetworkActive(); }
|
||||
UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) override
|
||||
{
|
||||
JSONRPCRequest req;
|
||||
req.params = params;
|
||||
req.strMethod = command;
|
||||
req.URI = uri;
|
||||
return ::tableRPC.execute(req);
|
||||
}
|
||||
std::vector<std::string> listRpcCommands() override { return ::tableRPC.listCommands(); }
|
||||
void rpcSetTimerInterfaceIfUnset(RPCTimerInterface* iface) override { RPCSetTimerInterfaceIfUnset(iface); }
|
||||
void rpcUnsetTimerInterface(RPCTimerInterface* iface) override { RPCUnsetTimerInterface(iface); }
|
||||
std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) override
|
||||
{
|
||||
return MakeHandler(::uiInterface.InitMessage.connect(fn));
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
class CDeterministicMNList;
|
||||
class CNodeStats;
|
||||
class RPCTimerInterface;
|
||||
class UniValue;
|
||||
class proxyType;
|
||||
struct CNodeStateStats;
|
||||
|
||||
@ -92,6 +94,15 @@ public:
|
||||
//! Get ban map entries.
|
||||
virtual bool getBanned(banmap_t& banmap) = 0;
|
||||
|
||||
//! Ban node.
|
||||
virtual bool ban(const CNetAddr& net_addr, BanReason reason, int64_t ban_time_offset) = 0;
|
||||
|
||||
//! Unban node.
|
||||
virtual bool unban(const CSubNet& ip) = 0;
|
||||
|
||||
//! Disconnect node.
|
||||
virtual bool disconnect(NodeId id) = 0;
|
||||
|
||||
//! Get total bytes recv.
|
||||
virtual int64_t getTotalBytesRecv() = 0;
|
||||
|
||||
@ -134,6 +145,18 @@ public:
|
||||
//! Get network active.
|
||||
virtual bool getNetworkActive() = 0;
|
||||
|
||||
//! Execute rpc command.
|
||||
virtual UniValue executeRpc(const std::string& command, const UniValue& params, const std::string& uri) = 0;
|
||||
|
||||
//! List rpc commands.
|
||||
virtual std::vector<std::string> listRpcCommands() = 0;
|
||||
|
||||
//! Set RPC timer interface if unset.
|
||||
virtual void rpcSetTimerInterfaceIfUnset(RPCTimerInterface* iface) = 0;
|
||||
|
||||
//! Unset RPC timer interface.
|
||||
virtual void rpcUnsetTimerInterface(RPCTimerInterface* iface) = 0;
|
||||
|
||||
//! Register handler for init messages.
|
||||
using InitMessageFn = std::function<void(const std::string& message)>;
|
||||
virtual std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn) = 0;
|
||||
|
@ -149,7 +149,7 @@ BitcoinGUI::BitcoinGUI(interface::Node& node, const NetworkStyle* networkStyle,
|
||||
setWindowIcon(networkStyle->getTrayAndWindowIcon());
|
||||
setWindowTitle(windowTitle);
|
||||
|
||||
rpcConsole = new RPCConsole(this);
|
||||
rpcConsole = new RPCConsole(node, this);
|
||||
helpMessageDialog = new HelpMessageDialog(node, this, HelpMessageDialog::cmdline);
|
||||
#ifdef ENABLE_WALLET
|
||||
if(enableWallet)
|
||||
|
@ -79,12 +79,17 @@ const QStringList historyFilter = QStringList()
|
||||
class RPCExecutor : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
RPCExecutor(interface::Node& node) : m_node(node) {}
|
||||
|
||||
public Q_SLOTS:
|
||||
void request(const QString &command, const QString &walletID);
|
||||
|
||||
Q_SIGNALS:
|
||||
void reply(int category, const QString &command);
|
||||
|
||||
private:
|
||||
interface::Node& m_node;
|
||||
};
|
||||
|
||||
/** Class for handling RPC timers
|
||||
@ -136,13 +141,14 @@ public:
|
||||
* - Within double quotes, only escape \c " and backslashes before a \c " or another backslash
|
||||
* - Within single quotes, no escaping is possible and no special interpretation takes place
|
||||
*
|
||||
* @param[in] node optional node to execute command on
|
||||
* @param[out] result stringified Result from the executed command(chain)
|
||||
* @param[in] strCommand Command line to split
|
||||
* @param[in] fExecute set true if you want the command to be executed
|
||||
* @param[out] pstrFilteredOut Command line, filtered to remove any sensitive data
|
||||
*/
|
||||
|
||||
bool RPCConsole::RPCParseCommandLine(std::string &strResult, const std::string &strCommand, const bool fExecute, std::string * const pstrFilteredOut, const std::string *walletID)
|
||||
bool RPCConsole::RPCParseCommandLine(interface::Node* node, std::string &strResult, const std::string &strCommand, const bool fExecute, std::string * const pstrFilteredOut, const std::string *walletID)
|
||||
{
|
||||
std::vector< std::vector<std::string> > stack;
|
||||
stack.push_back(std::vector<std::string>());
|
||||
@ -296,16 +302,17 @@ bool RPCConsole::RPCParseCommandLine(std::string &strResult, const std::string &
|
||||
if (fExecute) {
|
||||
// Convert argument list to JSON objects in method-dependent way,
|
||||
// and pass it along with the method name to the dispatcher.
|
||||
JSONRPCRequest req;
|
||||
req.params = RPCConvertValues(stack.back()[0], std::vector<std::string>(stack.back().begin() + 1, stack.back().end()));
|
||||
req.strMethod = stack.back()[0];
|
||||
UniValue params = RPCConvertValues(stack.back()[0], std::vector<std::string>(stack.back().begin() + 1, stack.back().end()));
|
||||
std::string method = stack.back()[0];
|
||||
std::string uri;
|
||||
#ifdef ENABLE_WALLET
|
||||
if (walletID && !walletID->empty()) {
|
||||
QByteArray encodedName = QUrl::toPercentEncoding(QString::fromStdString(*walletID));
|
||||
req.URI = "/wallet/"+std::string(encodedName.constData(), encodedName.length());
|
||||
uri = "/wallet/"+std::string(encodedName.constData(), encodedName.length());
|
||||
}
|
||||
#endif
|
||||
lastResult = tableRPC.execute(req);
|
||||
assert(node);
|
||||
lastResult = node->executeRpc(method, params, uri);
|
||||
}
|
||||
|
||||
state = STATE_COMMAND_EXECUTED;
|
||||
@ -412,7 +419,7 @@ void RPCExecutor::request(const QString &command, const QString &walletID)
|
||||
return;
|
||||
}
|
||||
std::string wallet_id = walletID.toStdString();
|
||||
if(!RPCConsole::RPCExecuteCommandLine(result, executableCommand, nullptr, &wallet_id))
|
||||
if(!RPCConsole::RPCExecuteCommandLine(m_node, result, executableCommand, nullptr, &wallet_id))
|
||||
{
|
||||
Q_EMIT reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \""));
|
||||
return;
|
||||
@ -439,8 +446,9 @@ void RPCExecutor::request(const QString &command, const QString &walletID)
|
||||
}
|
||||
}
|
||||
|
||||
RPCConsole::RPCConsole(QWidget* parent) :
|
||||
RPCConsole::RPCConsole(interface::Node& node, QWidget* parent) :
|
||||
QWidget(parent, Qt::Window),
|
||||
m_node(node),
|
||||
ui(new Ui::RPCConsole),
|
||||
clientModel(0),
|
||||
historyPtr(0),
|
||||
@ -510,7 +518,7 @@ RPCConsole::RPCConsole(QWidget* parent) :
|
||||
rpcTimerInterface = new QtRPCTimerInterface();
|
||||
// avoid accidentally overwriting an existing, non QTThread
|
||||
// based timer interface
|
||||
RPCSetTimerInterfaceIfUnset(rpcTimerInterface);
|
||||
m_node.rpcSetTimerInterfaceIfUnset(rpcTimerInterface);
|
||||
|
||||
setTrafficGraphRange(INITIAL_TRAFFIC_GRAPH_SETTING);
|
||||
|
||||
@ -532,7 +540,7 @@ RPCConsole::~RPCConsole()
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("RPCConsoleWindowGeometry", saveGeometry());
|
||||
RPCUnsetTimerInterface(rpcTimerInterface);
|
||||
m_node.rpcUnsetTimerInterface(rpcTimerInterface);
|
||||
delete rpcTimerInterface;
|
||||
delete ui;
|
||||
}
|
||||
@ -694,7 +702,7 @@ void RPCConsole::setClientModel(ClientModel *model)
|
||||
|
||||
//Setup autocomplete and attach it
|
||||
QStringList wordList;
|
||||
std::vector<std::string> commandList = tableRPC.listCommands();
|
||||
std::vector<std::string> commandList = m_node.listRpcCommands();
|
||||
for (size_t i = 0; i < commandList.size(); ++i)
|
||||
{
|
||||
wordList << commandList[i].c_str();
|
||||
@ -993,7 +1001,7 @@ void RPCConsole::on_lineEdit_returnPressed()
|
||||
std::string strFilteredCmd;
|
||||
try {
|
||||
std::string dummy;
|
||||
if (!RPCParseCommandLine(dummy, cmd.toStdString(), false, &strFilteredCmd)) {
|
||||
if (!RPCParseCommandLine(nullptr, dummy, cmd.toStdString(), false, &strFilteredCmd)) {
|
||||
// Failed to parse command, so we cannot even filter it for the history
|
||||
throw std::runtime_error("Invalid command line");
|
||||
}
|
||||
@ -1066,7 +1074,7 @@ void RPCConsole::browseHistory(int offset)
|
||||
|
||||
void RPCConsole::startExecutor()
|
||||
{
|
||||
RPCExecutor *executor = new RPCExecutor();
|
||||
RPCExecutor *executor = new RPCExecutor(m_node);
|
||||
executor->moveToThread(&thread);
|
||||
|
||||
// Replies from executor object must go to this object
|
||||
@ -1304,9 +1312,6 @@ void RPCConsole::showBanTableContextMenu(const QPoint& point)
|
||||
|
||||
void RPCConsole::disconnectSelectedNode()
|
||||
{
|
||||
if(!g_connman)
|
||||
return;
|
||||
|
||||
// Get selected peer addresses
|
||||
QList<QModelIndex> nodes = GUIUtil::getEntryData(ui->peerWidget, PeerTableModel::NetNodeId);
|
||||
for(int i = 0; i < nodes.count(); i++)
|
||||
@ -1314,14 +1319,14 @@ void RPCConsole::disconnectSelectedNode()
|
||||
// Get currently selected peer address
|
||||
NodeId id = nodes.at(i).data().toLongLong();
|
||||
// Find the node, disconnect it and clear the selected node
|
||||
if(g_connman->DisconnectNode(id))
|
||||
if(m_node.disconnect(id))
|
||||
clearSelectedNode();
|
||||
}
|
||||
}
|
||||
|
||||
void RPCConsole::banSelectedNode(int bantime)
|
||||
{
|
||||
if (!clientModel || !g_connman)
|
||||
if (!clientModel)
|
||||
return;
|
||||
|
||||
// Get selected peer addresses
|
||||
@ -1339,7 +1344,7 @@ void RPCConsole::banSelectedNode(int bantime)
|
||||
// Find possible nodes, ban it and clear the selected node
|
||||
const CNodeCombinedStats *stats = clientModel->getPeerTableModel()->getNodeStats(detailNodeRow);
|
||||
if(stats) {
|
||||
g_connman->Ban(stats->nodeStats.addr, BanReasonManuallyAdded, bantime);
|
||||
m_node.ban(stats->nodeStats.addr, BanReasonManuallyAdded, bantime);
|
||||
}
|
||||
}
|
||||
clearSelectedNode();
|
||||
@ -1360,9 +1365,8 @@ void RPCConsole::unbanSelectedNode()
|
||||
CSubNet possibleSubnet;
|
||||
|
||||
LookupSubNet(strNode.toStdString().c_str(), possibleSubnet);
|
||||
if (possibleSubnet.IsValid() && g_connman)
|
||||
if (possibleSubnet.IsValid() && m_node.unban(possibleSubnet))
|
||||
{
|
||||
g_connman->Unban(possibleSubnet);
|
||||
clientModel->getBanTableModel()->refresh();
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,10 @@ class ClientModel;
|
||||
class RPCTimerInterface;
|
||||
class WalletModel;
|
||||
|
||||
namespace interface {
|
||||
class Node;
|
||||
}
|
||||
|
||||
namespace Ui {
|
||||
class RPCConsole;
|
||||
}
|
||||
@ -35,12 +39,12 @@ class RPCConsole: public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RPCConsole(QWidget* parent);
|
||||
explicit RPCConsole(interface::Node& node, QWidget* parent);
|
||||
~RPCConsole();
|
||||
|
||||
static bool RPCParseCommandLine(std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = nullptr, const std::string *walletID = nullptr);
|
||||
static bool RPCExecuteCommandLine(std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = nullptr, const std::string *walletID = nullptr) {
|
||||
return RPCParseCommandLine(strResult, strCommand, true, pstrFilteredOut, walletID);
|
||||
static bool RPCParseCommandLine(interface::Node* node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = nullptr, const std::string *walletID = nullptr);
|
||||
static bool RPCExecuteCommandLine(interface::Node& node, std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = nullptr, const std::string *walletID = nullptr) {
|
||||
return RPCParseCommandLine(&node, strResult, strCommand, true, pstrFilteredOut, walletID);
|
||||
}
|
||||
|
||||
void setClientModel(ClientModel *model);
|
||||
@ -162,6 +166,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
interface::Node& m_node;
|
||||
Ui::RPCConsole *ui;
|
||||
QButtonGroup pageButtons;
|
||||
ClientModel *clientModel;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <chainparams.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <fs.h>
|
||||
#include <interface/node.h>
|
||||
#include <validation.h>
|
||||
#include <rpc/register.h>
|
||||
#include <rpc/server.h>
|
||||
@ -48,87 +49,88 @@ void RPCNestedTests::rpcNestedTests()
|
||||
std::string result;
|
||||
std::string result2;
|
||||
std::string filtered;
|
||||
RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo()[chain]", &filtered); //simple result filtering with path
|
||||
auto node = interface::MakeNode();
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo()[chain]", &filtered); //simple result filtering with path
|
||||
QVERIFY(result=="main");
|
||||
QVERIFY(filtered == "getblockchaininfo()[chain]");
|
||||
|
||||
RPCConsole::RPCExecuteCommandLine(result, "getblock(getbestblockhash())"); //simple 2 level nesting
|
||||
RPCConsole::RPCExecuteCommandLine(result, "getblock(getblock(getbestblockhash())[hash], true)");
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "getblock(getbestblockhash())"); //simple 2 level nesting
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "getblock(getblock(getbestblockhash())[hash], true)");
|
||||
|
||||
RPCConsole::RPCExecuteCommandLine(result, "getblock( getblock( getblock(getbestblockhash())[hash] )[hash], true)"); //4 level nesting with whitespace, filtering path and boolean parameter
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "getblock( getblock( getblock(getbestblockhash())[hash] )[hash], true)"); //4 level nesting with whitespace, filtering path and boolean parameter
|
||||
|
||||
RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo");
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo");
|
||||
QVERIFY(result.substr(0,1) == "{");
|
||||
|
||||
RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo()");
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo()");
|
||||
QVERIFY(result.substr(0,1) == "{");
|
||||
|
||||
RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo "); //whitespace at the end will be tolerated
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo "); //whitespace at the end will be tolerated
|
||||
QVERIFY(result.substr(0,1) == "{");
|
||||
|
||||
(RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo()[\"chain\"]")); //Quote path identifier are allowed, but look after a child containing the quotes in the key
|
||||
(RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo()[\"chain\"]")); //Quote path identifier are allowed, but look after a child containing the quotes in the key
|
||||
QVERIFY(result == "null");
|
||||
|
||||
(RPCConsole::RPCExecuteCommandLine(result, "createrawtransaction [] {} 0")); //parameter not in brackets are allowed
|
||||
(RPCConsole::RPCExecuteCommandLine(result2, "createrawtransaction([],{},0)")); //parameter in brackets are allowed
|
||||
(RPCConsole::RPCExecuteCommandLine(*node, result, "createrawtransaction [] {} 0")); //parameter not in brackets are allowed
|
||||
(RPCConsole::RPCExecuteCommandLine(*node, result2, "createrawtransaction([],{},0)")); //parameter in brackets are allowed
|
||||
QVERIFY(result == result2);
|
||||
(RPCConsole::RPCExecuteCommandLine(result2, "createrawtransaction( [], {} , 0 )")); //whitespace between parameters is allowed
|
||||
(RPCConsole::RPCExecuteCommandLine(*node, result2, "createrawtransaction( [], {} , 0 )")); //whitespace between parameters is allowed
|
||||
QVERIFY(result == result2);
|
||||
|
||||
RPCConsole::RPCExecuteCommandLine(result, "getblock(getbestblockhash())[tx][0]", &filtered);
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "getblock(getbestblockhash())[tx][0]", &filtered);
|
||||
QVERIFY(result == "e0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7");
|
||||
QVERIFY(filtered == "getblock(getbestblockhash())[tx][0]");
|
||||
|
||||
RPCConsole::RPCParseCommandLine(result, "importprivkey", false, &filtered);
|
||||
RPCConsole::RPCParseCommandLine(nullptr, result, "importprivkey", false, &filtered);
|
||||
QVERIFY(filtered == "importprivkey(…)");
|
||||
RPCConsole::RPCParseCommandLine(result, "signmessagewithprivkey abc", false, &filtered);
|
||||
RPCConsole::RPCParseCommandLine(nullptr, result, "signmessagewithprivkey abc", false, &filtered);
|
||||
QVERIFY(filtered == "signmessagewithprivkey(…)");
|
||||
RPCConsole::RPCParseCommandLine(result, "signmessagewithprivkey abc,def", false, &filtered);
|
||||
RPCConsole::RPCParseCommandLine(nullptr, result, "signmessagewithprivkey abc,def", false, &filtered);
|
||||
QVERIFY(filtered == "signmessagewithprivkey(…)");
|
||||
RPCConsole::RPCParseCommandLine(result, "signrawtransaction(abc)", false, &filtered);
|
||||
RPCConsole::RPCParseCommandLine(nullptr, result, "signrawtransaction(abc)", false, &filtered);
|
||||
QVERIFY(filtered == "signrawtransaction(…)");
|
||||
RPCConsole::RPCParseCommandLine(result, "walletpassphrase(help())", false, &filtered);
|
||||
RPCConsole::RPCParseCommandLine(nullptr, result, "walletpassphrase(help())", false, &filtered);
|
||||
QVERIFY(filtered == "walletpassphrase(…)");
|
||||
RPCConsole::RPCParseCommandLine(result, "walletpassphrasechange(help(walletpassphrasechange(abc)))", false, &filtered);
|
||||
RPCConsole::RPCParseCommandLine(nullptr, result, "walletpassphrasechange(help(walletpassphrasechange(abc)))", false, &filtered);
|
||||
QVERIFY(filtered == "walletpassphrasechange(…)");
|
||||
RPCConsole::RPCParseCommandLine(result, "help(encryptwallet(abc, def))", false, &filtered);
|
||||
RPCConsole::RPCParseCommandLine(nullptr, result, "help(encryptwallet(abc, def))", false, &filtered);
|
||||
QVERIFY(filtered == "help(encryptwallet(…))");
|
||||
RPCConsole::RPCParseCommandLine(result, "help(importprivkey())", false, &filtered);
|
||||
RPCConsole::RPCParseCommandLine(nullptr, result, "help(importprivkey())", false, &filtered);
|
||||
QVERIFY(filtered == "help(importprivkey(…))");
|
||||
RPCConsole::RPCParseCommandLine(result, "help(importprivkey(help()))", false, &filtered);
|
||||
RPCConsole::RPCParseCommandLine(nullptr, result, "help(importprivkey(help()))", false, &filtered);
|
||||
QVERIFY(filtered == "help(importprivkey(…))");
|
||||
RPCConsole::RPCParseCommandLine(result, "help(importprivkey(abc), walletpassphrase(def))", false, &filtered);
|
||||
RPCConsole::RPCParseCommandLine(nullptr, result, "help(importprivkey(abc), walletpassphrase(def))", false, &filtered);
|
||||
QVERIFY(filtered == "help(importprivkey(…), walletpassphrase(…))");
|
||||
|
||||
RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest");
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "rpcNestedTest");
|
||||
QVERIFY(result == "[]");
|
||||
RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest ''");
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "rpcNestedTest ''");
|
||||
QVERIFY(result == "[\"\"]");
|
||||
RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest \"\"");
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "rpcNestedTest \"\"");
|
||||
QVERIFY(result == "[\"\"]");
|
||||
RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest '' abc");
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "rpcNestedTest '' abc");
|
||||
QVERIFY(result == "[\"\",\"abc\"]");
|
||||
RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest abc '' abc");
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "rpcNestedTest abc '' abc");
|
||||
QVERIFY(result == "[\"abc\",\"\",\"abc\"]");
|
||||
RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest abc abc");
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "rpcNestedTest abc abc");
|
||||
QVERIFY(result == "[\"abc\",\"abc\"]");
|
||||
RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest abc\t\tabc");
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "rpcNestedTest abc\t\tabc");
|
||||
QVERIFY(result == "[\"abc\",\"abc\"]");
|
||||
RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc )");
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "rpcNestedTest(abc )");
|
||||
QVERIFY(result == "[\"abc\"]");
|
||||
RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest( abc )");
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "rpcNestedTest( abc )");
|
||||
QVERIFY(result == "[\"abc\"]");
|
||||
RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest( abc , cba )");
|
||||
RPCConsole::RPCExecuteCommandLine(*node, result, "rpcNestedTest( abc , cba )");
|
||||
QVERIFY(result == "[\"abc\",\"cba\"]");
|
||||
|
||||
// do the QVERIFY_EXCEPTION_THROWN checks only with Qt5.3 and higher (QVERIFY_EXCEPTION_THROWN was introduced in Qt5.3)
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo() .\n"), std::runtime_error); //invalid syntax
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo() getblockchaininfo()"), std::runtime_error); //invalid syntax
|
||||
(RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo(")); //tolerate non closing brackets if we have no arguments
|
||||
(RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo()()()")); //tolerate non command brackts
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo(True)"), UniValue); //invalid argument
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "a(getblockchaininfo(True))"), UniValue); //method not found
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest abc,,abc"), std::runtime_error); //don't tollerate empty arguments when using ,
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,abc)"), std::runtime_error); //don't tollerate empty arguments when using ,
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest(abc,,)"), std::runtime_error); //don't tollerate empty arguments when using ,
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo() .\n"), std::runtime_error); //invalid syntax
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo() getblockchaininfo()"), std::runtime_error); //invalid syntax
|
||||
(RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo(")); //tolerate non closing brackets if we have no arguments
|
||||
(RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo()()()")); //tolerate non command brackts
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo(True)"), UniValue); //invalid argument
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(*node, result, "a(getblockchaininfo(True))"), UniValue); //method not found
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(*node, result, "rpcNestedTest abc,,abc"), std::runtime_error); //don't tollerate empty arguments when using ,
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(*node, result, "rpcNestedTest(abc,,abc)"), std::runtime_error); //don't tollerate empty arguments when using ,
|
||||
QVERIFY_EXCEPTION_THROWN(RPCConsole::RPCExecuteCommandLine(*node, result, "rpcNestedTest(abc,,)"), std::runtime_error); //don't tollerate empty arguments when using ,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user