Continuing to chip away at the untested RPC interface. This PR:
- adds tests for
getblockheader(previously uncovered) - adds missing documentation to the
getblockheaderRPC help - adds two assertion utilities to the RPC testing framework
Continuing to chip away at the untested RPC interface. This PR:
getblockheader (previously uncovered)getblockheader RPC helpNice. utACK. tiny nit: don't label rpcblockchain.cpp changes (help output) as [test]. Maybe better open a 2nd PR.
406 | @@ -407,5 +407,22 @@ def assert_raises(exc, fun, *args, **kwds): 407 | else: 408 | raise AssertionError("No exception raised") 409 | 410 | +def assert_is_hex_string(string): 411 | + try: 412 | + int(string, 16) 413 | + except Exception as e: 414 | + raise AssertionError( 415 | + "Couldn't interpret %r as hexidecimal; raised: %s" % (string, e))
hexadecimal
fixed
@jonasschnelli good point, thanks. I've changed the PR title to reflect this.
utACK modulo question
322 | @@ -323,7 +323,8 @@ UniValue getblockheader(const UniValue& params, bool fHelp) 323 | " \"bits\" : \"1d00ffff\", (string) The bits\n" 324 | " \"difficulty\" : x.xxx, (numeric) The difficulty\n" 325 | " \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n" 326 | - " \"nextblockhash\" : \"hash\" (string) The hash of the next block\n" 327 | + " \"nextblockhash\" : \"hash\", (string) The hash of the next block\n" 328 | + " \"chainwork\" : \"0000...1f3\" (string) Number of hashes expected to produce the current chain (in hex)\n"
What about "Expected number of hashes required to produce the current chain"?
Current wording could be read as "do that work, will get the current chain", which is a bit unlikely. :)
sure thing. fixed
utACK modulo wording
418 | + if not isinstance(string, basestring): 419 | + raise AssertionError("Expected a string, got type %r" % type(string)) 420 | + elif length and len(string) != length: 421 | + raise AssertionError( 422 | + "String of length %d expected; got %d" % (length, len(string))) 423 | + elif not re.match('[abcdef0-9]+', string):
I think you want:
elif not re.match('[abcdef0-9]+$', string):
Very true :). willfix
fixed
322 | @@ -323,7 +323,8 @@ UniValue getblockheader(const UniValue& params, bool fHelp) 323 | " \"bits\" : \"1d00ffff\", (string) The bits\n" 324 | " \"difficulty\" : x.xxx, (numeric) The difficulty\n" 325 | " \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n" 326 | - " \"nextblockhash\" : \"hash\" (string) The hash of the next block\n" 327 | + " \"nextblockhash\" : \"hash\", (string) The hash of the next block\n" 328 | + " \"chainwork\" : \"0000...1f3\" (string) Expected number of hashes required to produce the current chain (in hex)\n"
It's the expected number of hashes up to this point in the chain, not the entire chain. AFAIK
I added a similar line for getblock at #7232
This message is based on @sipa's description of chainwork and was vetted previously by [@petertodd](/bitcoin-bitcoin/contributor/petertodd/). You may want to close the PR you reference above; it was opened after this one and doesn't include tests.
Ok, I disagree that it's clear, but if everyone else is fine with it I can conform as well.
Regardless, my pull is not covered here, so not sure why would I close it?
edit: My title wasn't clear, so I added the specific rpc.
@instagibbs thanks!
Perhaps my newer suggestion is equitable?
https://github.com/bitcoin/bitcoin/pull/7232/files#r48769375
ping on this
I'll start reviewing again after new year.
utACK