Skip to content

Commit

Permalink
Fix getmasternodeblocks depth filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
dcorral committed Dec 3, 2021
1 parent ebae304 commit 6879367
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/masternodes/rpc_masternodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ UniValue remforcedrewardaddress(const JSONRPCRequest& request)
// Temporarily disabled for 2.2
throw JSONRPCError(RPC_INVALID_REQUEST,
"reward address change is disabled for Fort Canning");

auto pwallet = GetWallet(request);

RPCHelpMan{"remforcedrewardaddress",
Expand Down Expand Up @@ -814,10 +814,11 @@ UniValue getmasternodeblocks(const JSONRPCRequest& request) {
if (blockHeight <= creationHeight) {
return true;
}

if (auto tip = ::ChainActive()[blockHeight]) {
auto tip = ::ChainActive()[blockHeight];
if (tip && depth > 0) {
lastHeight = tip->height;
ret.pushKV(std::to_string(tip->height), tip->GetBlockHash().ToString());
depth--;
}

return true;
Expand Down
3 changes: 3 additions & 0 deletions test/functional/rpc_mn_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ def run_test(self):
# test getmasternodeblocks
self.nodes[0].generate(1)
node0_keys = self.nodes[0].get_genesis_keys()
blocks = self.nodes[0].getmasternodeblocks({'operatorAddress': node0_keys.operatorAuthAddress}, 2)
assert_equal(len(blocks), 2)

blocks = self.nodes[0].getmasternodeblocks({'operatorAddress': node0_keys.operatorAuthAddress})
assert_equal(list(blocks.keys())[0], '162')

Expand Down

0 comments on commit 6879367

Please sign in to comment.