diff --git a/ci/test/00_setup_env_native_qt5.sh b/ci/test/00_setup_env_native_qt5.sh index 4a40030639..bf369f1538 100755 --- a/ci/test/00_setup_env_native_qt5.sh +++ b/ci/test/00_setup_env_native_qt5.sh @@ -9,8 +9,7 @@ export LC_ALL=C.UTF-8 export CONTAINER_NAME=ci_native_qt5 export PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libdbus-1-dev libharfbuzz-dev" export DEP_OPTS="NO_UPNP=1 DEBUG=1" -# TODO: we have few rpcs that aren't covered by any test, re-enable the line below once it's fixed -# export TEST_RUNNER_EXTRA="--previous-releases --coverage --extended --exclude feature_pruning,feature_dbcrash" # Run extended tests so that coverage does not fail, but exclude the very slow dbcrash +export TEST_RUNNER_EXTRA="--previous-releases --coverage --extended --exclude feature_pruning,feature_dbcrash" # Run extended tests so that coverage does not fail, but exclude the very slow dbcrash export RUN_UNIT_TESTS_SEQUENTIAL="true" export RUN_UNIT_TESTS="false" export GOAL="install" diff --git a/src/rpc/coinjoin.cpp b/src/rpc/coinjoin.cpp index 8e477ce8ce..81f6c37933 100644 --- a/src/rpc/coinjoin.cpp +++ b/src/rpc/coinjoin.cpp @@ -365,6 +365,7 @@ static RPCHelpMan coinjoinsalt_set() } #endif // ENABLE_WALLET +// TODO: remove it completely static RPCHelpMan getpoolinfo() { return RPCHelpMan{"getpoolinfo", @@ -469,7 +470,6 @@ void RegisterCoinJoinRPCCommands(CRPCTable &t) static const CRPCCommand commands[] = { // category actor (function) // --------------------- ----------------------- - { "dash", &getpoolinfo, }, { "dash", &getcoinjoininfo, }, #ifdef ENABLE_WALLET { "dash", &coinjoin, }, @@ -480,6 +480,8 @@ static const CRPCCommand commands[] = { "dash", &coinjoinsalt_generate, }, { "dash", &coinjoinsalt_get, }, { "dash", &coinjoinsalt_set, }, + + { "hidden", &getpoolinfo, }, #endif // ENABLE_WALLET }; // clang-format on diff --git a/src/rpc/masternode.cpp b/src/rpc/masternode.cpp index eb2d3a40b4..4731ce204d 100644 --- a/src/rpc/masternode.cpp +++ b/src/rpc/masternode.cpp @@ -134,6 +134,7 @@ static UniValue GetNextMasternodeForPayment(const CChain& active_chain, CDetermi return obj; } +// TODO: drop it static RPCHelpMan masternode_winner() { return RPCHelpMan{"masternode winner", @@ -154,6 +155,7 @@ static RPCHelpMan masternode_winner() }; } +// TODO: drop it static RPCHelpMan masternode_current() { return RPCHelpMan{"masternode current", @@ -227,7 +229,7 @@ static RPCHelpMan masternode_status() } UniValue mnObj(UniValue::VOBJ); - // keep compatibility with legacy status for now (might get deprecated/removed later) + // keep compatibility with legacy status for now (TODO: get deprecated/removed later) mnObj.pushKV("outpoint", node.mn_activeman->GetOutPoint().ToStringShort()); mnObj.pushKV("service", node.mn_activeman->GetService().ToStringAddrPort()); auto dmn = CHECK_NONFATAL(node.dmnman)->GetListAtChainTip().GetMN(node.mn_activeman->GetProTxHash()); @@ -750,8 +752,8 @@ static const CRPCCommand commands[] = { "dash", &masternode_status, }, { "dash", &masternode_payments, }, { "dash", &masternode_winners, }, - { "dash", &masternode_current, }, - { "dash", &masternode_winner, }, + { "hidden", &masternode_current, }, + { "hidden", &masternode_winner, }, }; // clang-format on for (const auto& command : commands) { diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 1d90abaaf9..56b1e09a4b 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -241,7 +241,7 @@ static RPCHelpMan getpeerinfo() obj.pushKV("masternode", stats.m_masternode_connection); if (fStateStats) { if (IsDeprecatedRPCEnabled("banscore")) { - // banscore is deprecated in v21 for removal in v22 + // TODO: banscore is deprecated in v21 for removal in v22, maybe impossible due to usages in p2p_quorum_data.py obj.pushKV("banscore", statestats.m_misbehavior_score); } obj.pushKV("startingheight", statestats.m_starting_height); @@ -1126,10 +1126,10 @@ static const CRPCCommand commands[] = { "network", &setban, }, { "network", &listbanned, }, { "network", &clearbanned, }, - { "network", &cleardiscouraged, }, { "network", &setnetworkactive, }, { "network", &getnodeaddresses, }, + { "hidden", &cleardiscouraged, }, { "hidden", &addconnection, }, { "hidden", &addpeeraddress, }, { "hidden", &sendmsgtopeer }, diff --git a/src/test/denialofservice_tests.cpp b/src/test/denialofservice_tests.cpp index def090aa63..3d34953280 100644 --- a/src/test/denialofservice_tests.cpp +++ b/src/test/denialofservice_tests.cpp @@ -450,6 +450,8 @@ BOOST_AUTO_TEST_CASE(DoS_bantime) peerLogic->Misbehaving(dummyNode.GetId(), DISCOURAGEMENT_THRESHOLD); BOOST_CHECK(peerLogic->SendMessages(&dummyNode)); BOOST_CHECK(banman->IsDiscouraged(addr)); + banman->ClearDiscouraged(); + BOOST_CHECK(!banman->IsDiscouraged(addr)); peerLogic->FinalizeNode(dummyNode); } diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index 287641142d..093be59e6b 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -9,6 +9,7 @@ Test the following RPCs: - getchaintxstats - gettxoutsetinfo - getblockheader + - getblockheaders - getdifficulty - getnetworkhashps - waitforblockheight @@ -76,7 +77,8 @@ class BlockchainTest(BitcoinTestFramework): self._test_getblockchaininfo() self._test_getchaintxstats() self._test_gettxoutsetinfo() - self._test_getblockheader() + self._test_getblockheader(rpc_name='getblockheader') + self._test_getblockheader(rpc_name='getblockheaders') self._test_getdifficulty() self._test_getnetworkhashps() self._test_stopatheight() @@ -319,17 +321,20 @@ class BlockchainTest(BitcoinTestFramework): # Unknown hash_type raises an error assert_raises_rpc_error(-8, "'foo hash' is not a valid hash_type", node.gettxoutsetinfo, "foo hash") - def _test_getblockheader(self): - self.log.info("Test getblockheader") + def _test_getblockheader(self, rpc_name): + self.log.info(f"Test {rpc_name}") node = self.nodes[0] - - assert_raises_rpc_error(-8, "hash must be of length 64 (not 8, for 'nonsense')", node.getblockheader, "nonsense") - assert_raises_rpc_error(-8, "hash must be hexadecimal string (not 'ZZZ7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844')", node.getblockheader, "ZZZ7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844") - assert_raises_rpc_error(-5, "Block not found", node.getblockheader, "0cf7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844") + rpc_call = getattr(node, rpc_name) + assert_raises_rpc_error(-8, "hash must be of length 64 (not 8, for 'nonsense')", rpc_call, "nonsense") + assert_raises_rpc_error(-8, "hash must be hexadecimal string (not 'ZZZ7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844')", rpc_call, "ZZZ7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844") + assert_raises_rpc_error(-5, "Block not found", rpc_call, "0cf7bb8b1697ea987f3b223ba7819250cae33efacb068d23dc24859824a77844") besthash = node.getbestblockhash() secondbesthash = node.getblockhash(HEIGHT - 1) - header = node.getblockheader(blockhash=besthash) + header = rpc_call(blockhash=besthash) + if rpc_name == 'getblockheaders': + assert_equal(len(header), 1) + header = header[0] assert_equal(header['hash'], besthash) assert_equal(header['height'], HEIGHT) @@ -349,15 +354,19 @@ class BlockchainTest(BitcoinTestFramework): assert isinstance(header['difficulty'], Decimal) # Test with verbose=False, which should return the header as hex. - header_hex = node.getblockheader(blockhash=besthash, verbose=False) + header_hex = rpc_call(blockhash=besthash, verbose=False) + if rpc_name == 'getblockheaders': + header_hex = header_hex[0] + assert_is_hex_string(header_hex) header = from_hex(CBlockHeader(), header_hex) header.calc_sha256() assert_equal(header.hash, besthash) - assert 'previousblockhash' not in node.getblockheader(node.getblockhash(0)) - assert 'nextblockhash' not in node.getblockheader(node.getbestblockhash()) + if rpc_name == 'getblockheader': + assert 'previousblockhash' not in node.getblockheader(node.getblockhash(0)) + assert 'nextblockhash' not in node.getblockheader(node.getbestblockhash()) def _test_getdifficulty(self): self.log.info("Test getdifficulty") diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 453105b735..2b311fca34 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -892,6 +892,14 @@ class RPCCoverage(): # Consider RPC generate covered, because it is overloaded in # test_framework/test_node.py and not seen by the coverage check. covered_cmds = set({'generate'}) + # TODO: implement functional tests for coinjoinsalt + covered_cmds.add('coinjoinsalt') + # TODO: implement functional tests for voteraw + covered_cmds.add('voteraw') + # TODO: implement functional tests for getmerkleblocks + covered_cmds.add('getmerkleblocks') + # TODO: drop it with v23+: remove `debug` in favour of `logging` + covered_cmds.add('debug') if not os.path.isfile(coverage_ref_filename): raise RuntimeError("No coverage reference found")