This improves error reporting if `JSONRPCException` is not specifically caught
and ends up in Python's default backtrace handler.
Before:
```
Traceback (most recent call last):
File "/.../projects/bitcoin/bitcoin/qa/rpc-tests/test_framework/authproxy.py", line 153, in __call__
raise JSONRPCException(response['error'])
test_framework.authproxy.JSONRPCException
```
After:
```
Traceback (most recent call last):
File "/.../projects/bitcoin/bitcoin/qa/rpc-tests/test_framework/authproxy.py", line 152, in __call__
raise JSONRPCException(response['error'])
test_framework.authproxy.JSONRPCException: Unknown named parameter random (-8)
```
waitfornewblock waits until a new block is received, or the timeout expires, then
returns the current block height/hash.
waitforblock waits for a specific blockhash, or until the timeout expires, then
returns the current block height/hash. If the target blockhash is the current
tip, it will return immediately.
waitforblockheight waits until the tip has reached a certain height or higher,
then returns the current height and hash.
waitforblockheight is used to avoid polling in the rpc tests.
mininode now supports witness transactions/blocks, blocktools
has a helper for adding witness commitments to blocks, and script
has a function to calculate hashes for signature under sigversion
1, used by segwit.
Py3 conversion by Marco Falke
Test to make sure upgraded nodes don't ask for non-wit blocks by
Gregory Sanders.
Add a setting ensure_ascii to AuthServiceProxy. This setting,
defaulting to True (backwards compatible),
is passed through to json.dumps. If set to False, non-ASCII characters
>0x80 are not escaped. This is useful for testing server
input processing, as well as slightly more bandwidth friendly in case of
heavy unicode usage.
Previously these functions would infinitely loop if sync failed;
now they have a default timeout of 60 seconds, after which an
AssertionError is raised.
sync_blocks() has also been improved and now compares the tip
hash of each node, rather than just using block count.
We can't change "softforks", but it seems far more logical to use tags
in an object rather than using an "id" field in an array.
For example, to get the csv status before, you need to iterate the
array to find the entry with 'id' field equal to "csv":
jq '.bip9_softforks | map(select(.id == "csv"))[] | .status'
Now:
jq '.bip9_softforks.csv.status'
There is no issue with fork names being incompatible with JSON tags,
since we're selecting them ourselves.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Check the Content-Type header that is returned from the RPC server. Only
if it is `application/json` the data is supposed to be parsed as JSON.
This gives better reporting if the HTTP server happens to return an error that is
not JSON-formatted, which is the case if it happens at a lower level
before JSON-RPC kicks in.
Before: `Unexpected exception caught during testing: No JSON object could be decoded`
After: `JSONRPC error: non-JSON HTTP response with '403 Forbidden' from server`
Avoid an infinite loop in encoding, by ensuring EncodeDecimal
returns a string. round(Decimal) used to convert it to
float, but it no longer does in python 3.x. Strings are
supported since #6380, so just use that.
Replace the `bitcoin-cli -rpcwait` after spawning bitcoind
with our own loop that detects when bitcoind exits prematurely.
And if one node fails to start, stop the others.
This prevents a hang in such a case (see #7463).