[qa] py2: Unfiddle strings into bytes explicitly in ZMQ RPC test

Extracted from bitcoin/bitcoin#7853
commit faa41ee204124da19dcf1e5b8a3aef1e216bf5e6
This commit is contained in:
Jack Grigg
2017-01-31 14:12:19 +01:00
parent a9445db62f
commit c7cb3c13ea
2 changed files with 24 additions and 11 deletions

View File

@@ -1,6 +1,8 @@
# Copyright (c) 2014 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Helpful routines for regression testing
#
@@ -9,6 +11,8 @@
import os
import sys
from binascii import hexlify, unhexlify
from base64 import b64encode
from decimal import Decimal, ROUND_DOWN
import json
import random
@@ -32,6 +36,15 @@ def check_json_precision():
if satoshis != 2000000000000003:
raise RuntimeError("JSON encode/decode loses precision")
def bytes_to_hex_str(byte_str):
return hexlify(byte_str).decode('ascii')
def hex_str_to_bytes(hex_str):
return unhexlify(hex_str.encode('ascii'))
def str_to_b64str(string):
return b64encode(string.encode('utf-8')).decode('ascii')
def sync_blocks(rpc_connections, wait=1):
"""
Wait until everybody has the same block count