mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
(Partial) Merge #21053: rpc, test: document {previous,next}blockhash as optional
ba7e17e073f833eccd4c7c111ae9058c3f123371 rpc, test: document {previous,next}blockhash as optional (Sebastian Falbesoner) Pull request description: This PR updates the result help of the following RPCs w.r.t. the `previousblockhash` and `nextblockhash` fields: - getblockheader - getblock Also adds trivial tests on genesis block (should not contain "previousblockhash") and best block (should not contain "nextblockhash"). Top commit has no ACKs. Tree-SHA512: ef42c5c773fc436e1b4a67be14e2532e800e1e30e45e54a57431c6abb714d2c069c70d40ea4012d549293b823a1973b3f569484b3273679683b28ed40abf46bb
This commit is contained in:
parent
52d7dbe329
commit
9daa8a2fd0
@ -897,8 +897,8 @@ static UniValue getblockheader(const JSONRPCRequest& request)
|
||||
{RPCResult::Type::NUM, "difficulty", "The difficulty"},
|
||||
{RPCResult::Type::STR_HEX, "chainwork", "Expected number of hashes required to produce the current chain"},
|
||||
{RPCResult::Type::NUM, "nTx", "The number of transactions in the block"},
|
||||
{RPCResult::Type::STR_HEX, "previousblockhash", "The hash of the previous block"},
|
||||
{RPCResult::Type::STR_HEX, "nextblockhash", "The hash of the next block"},
|
||||
{RPCResult::Type::STR_HEX, "previousblockhash", /* optional */ true, "The hash of the previous block (if available)"},
|
||||
{RPCResult::Type::STR_HEX, "nextblockhash", /* optional */ true, "The hash of the next block (if available)"},
|
||||
}},
|
||||
RPCResult{"for verbose=false",
|
||||
RPCResult::Type::STR_HEX, "", "A string that is serialized, hex-encoded data for block 'hash'"},
|
||||
@ -970,8 +970,8 @@ static UniValue getblockheaders(const JSONRPCRequest& request)
|
||||
{RPCResult::Type::NUM, "difficulty", "The difficulty"},
|
||||
{RPCResult::Type::STR_HEX, "chainwork", "Expected number of hashes required to produce the current chain"},
|
||||
{RPCResult::Type::NUM, "nTx", "The number of transactions in the block"},
|
||||
{RPCResult::Type::STR_HEX, "previousblockhash", "The hash of the previous block"},
|
||||
{RPCResult::Type::STR_HEX, "nextblockhash", "The hash of the next block"},
|
||||
{RPCResult::Type::STR_HEX, "previousblockhash", /* optional */ true, "The hash of the previous block (if available)"},
|
||||
{RPCResult::Type::STR_HEX, "nextblockhash", /* optional */ true, "The hash of the next block (if available)"},
|
||||
}},
|
||||
}},
|
||||
RPCResult{"for verbose=false",
|
||||
|
@ -326,6 +326,9 @@ class BlockchainTest(BitcoinTestFramework):
|
||||
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())
|
||||
|
||||
def _test_getdifficulty(self):
|
||||
difficulty = self.nodes[0].getdifficulty()
|
||||
# 1 hash in 2 should be valid, so difficulty should be 1/2**31
|
||||
|
Loading…
Reference in New Issue
Block a user