Skip to content

Commit a79598d

Browse files
committed
Qt/Test: Make sure filtering sensitive data works correctly in nested commands
1 parent 629cd42 commit a79598d

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/qt/test/rpcnestedtests.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ void RPCNestedTests::rpcNestedTests()
6161

6262
std::string result;
6363
std::string result2;
64-
RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo()[chain]"); //simple result filtering with path
64+
std::string filtered;
65+
RPCConsole::RPCExecuteCommandLine(result, "getblockchaininfo()[chain]", &filtered); //simple result filtering with path
6566
QVERIFY(result=="main");
67+
QVERIFY(filtered == "getblockchaininfo()[chain]");
6668

6769
RPCConsole::RPCExecuteCommandLine(result, "getblock(getbestblockhash())"); //simple 2 level nesting
6870
RPCConsole::RPCExecuteCommandLine(result, "getblock(getblock(getbestblockhash())[hash], true)");
@@ -87,8 +89,30 @@ void RPCNestedTests::rpcNestedTests()
8789
(RPCConsole::RPCExecuteCommandLine(result2, "createrawtransaction( [], {} , 0 )")); //whitespace between parametres is allowed
8890
QVERIFY(result == result2);
8991

90-
RPCConsole::RPCExecuteCommandLine(result, "getblock(getbestblockhash())[tx][0]");
92+
RPCConsole::RPCExecuteCommandLine(result, "getblock(getbestblockhash())[tx][0]", &filtered);
9193
QVERIFY(result == "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");
94+
QVERIFY(filtered == "getblock(getbestblockhash())[tx][0]");
95+
96+
RPCConsole::RPCParseCommandLine(result, "importprivkey", false, &filtered);
97+
QVERIFY(filtered == "importprivkey(…)");
98+
RPCConsole::RPCParseCommandLine(result, "signmessagewithprivkey abc", false, &filtered);
99+
QVERIFY(filtered == "signmessagewithprivkey(…)");
100+
RPCConsole::RPCParseCommandLine(result, "signmessagewithprivkey abc,def", false, &filtered);
101+
QVERIFY(filtered == "signmessagewithprivkey(…)");
102+
RPCConsole::RPCParseCommandLine(result, "signrawtransaction(abc)", false, &filtered);
103+
QVERIFY(filtered == "signrawtransaction(…)");
104+
RPCConsole::RPCParseCommandLine(result, "walletpassphrase(help())", false, &filtered);
105+
QVERIFY(filtered == "walletpassphrase(…)");
106+
RPCConsole::RPCParseCommandLine(result, "walletpassphrasechange(help(walletpassphrasechange(abc)))", false, &filtered);
107+
QVERIFY(filtered == "walletpassphrasechange(…)");
108+
RPCConsole::RPCParseCommandLine(result, "help(encryptwallet(abc, def))", false, &filtered);
109+
QVERIFY(filtered == "help(encryptwallet(…))");
110+
RPCConsole::RPCParseCommandLine(result, "help(importprivkey())", false, &filtered);
111+
QVERIFY(filtered == "help(importprivkey(…))");
112+
RPCConsole::RPCParseCommandLine(result, "help(importprivkey(help()))", false, &filtered);
113+
QVERIFY(filtered == "help(importprivkey(…))");
114+
RPCConsole::RPCParseCommandLine(result, "help(importprivkey(abc), walletpassphrase(def))", false, &filtered);
115+
QVERIFY(filtered == "help(importprivkey(…), walletpassphrase(…))");
92116

93117
RPCConsole::RPCExecuteCommandLine(result, "rpcNestedTest");
94118
QVERIFY(result == "[]");

0 commit comments

Comments
 (0)