MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / rpcNestedTests

Method rpcNestedTests

src/qt/test/rpcnestedtests.cpp:35–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33};
34
35void RPCNestedTests::rpcNestedTests()
36{
37 // do some test setup
38 // could be moved to a more generic place when we add more tests on QT level
39 tableRPC.appendCommand("rpcNestedTest", &vRPCCommands[0]);
40 //mempool.setSanityCheck(1.0);
41
42 TestingSetup test;
43
44 SetRPCWarmupFinished();
45
46 std::string result;
47 std::string result2;
48 std::string filtered;
49 auto node = interfaces::MakeNode();
50 RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo()[chain]", &filtered); //simple result filtering with path
51 QVERIFY(result=="main");
52 QVERIFY(filtered == "getblockchaininfo()[chain]");
53
54 RPCConsole::RPCExecuteCommandLine(*node, result, "getblock(getbestblockhash())"); //simple 2 level nesting
55 RPCConsole::RPCExecuteCommandLine(*node, result, "getblock(getblock(getbestblockhash())[hash], true)");
56
57 RPCConsole::RPCExecuteCommandLine(*node, result, "getblock( getblock( getblock(getbestblockhash())[hash] )[hash], true)"); //4 level nesting with whitespace, filtering path and boolean parameter
58
59 RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo");
60 QVERIFY(result.substr(0,1) == "{");
61
62 RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo()");
63 QVERIFY(result.substr(0,1) == "{");
64
65 RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo "); //whitespace at the end will be tolerated
66 QVERIFY(result.substr(0,1) == "{");
67
68 (RPCConsole::RPCExecuteCommandLine(*node, result, "getblockchaininfo()[\"chain\"]")); //Quote path identifier are allowed, but look after a child containing the quotes in the key
69 QVERIFY(result == "null");
70
71 (RPCConsole::RPCExecuteCommandLine(*node, result, "createrawtransaction [] {} 0")); //parameter not in brackets are allowed
72 (RPCConsole::RPCExecuteCommandLine(*node, result2, "createrawtransaction([],{},0)")); //parameter in brackets are allowed
73 QVERIFY(result == result2);
74 (RPCConsole::RPCExecuteCommandLine(*node, result2, "createrawtransaction( [], {} , 0 )")); //whitespace between parameters is allowed
75 QVERIFY(result == result2);
76
77 RPCConsole::RPCExecuteCommandLine(*node, result, "getblock(getbestblockhash())[tx][0]", &filtered);
78 QVERIFY(result == "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");
79 QVERIFY(filtered == "getblock(getbestblockhash())[tx][0]");
80
81 RPCConsole::RPCParseCommandLine(nullptr, result, "importprivkey", false, &filtered);
82 QVERIFY(filtered == "importprivkey(…)");
83 RPCConsole::RPCParseCommandLine(nullptr, result, "signmessagewithprivkey abc", false, &filtered);
84 QVERIFY(filtered == "signmessagewithprivkey(…)");
85 RPCConsole::RPCParseCommandLine(nullptr, result, "signmessagewithprivkey abc,def", false, &filtered);
86 QVERIFY(filtered == "signmessagewithprivkey(…)");
87 RPCConsole::RPCParseCommandLine(nullptr, result, "signrawtransactionwithkey(abc)", false, &filtered);
88 QVERIFY(filtered == "signrawtransactionwithkey(…)");
89 RPCConsole::RPCParseCommandLine(nullptr, result, "walletpassphrase(help())", false, &filtered);
90 QVERIFY(filtered == "walletpassphrase(…)");
91 RPCConsole::RPCParseCommandLine(nullptr, result, "walletpassphrasechange(help(walletpassphrasechange(abc)))", false, &filtered);
92 QVERIFY(filtered == "walletpassphrasechange(…)");

Callers

nothing calls this directly

Calls 4

SetRPCWarmupFinishedFunction · 0.85
MakeNodeFunction · 0.85
RPCExecuteCommandLineFunction · 0.85
appendCommandMethod · 0.80

Tested by

no test coverage detected