aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests/test_framework/util.py
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-04-14 16:38:07 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2016-04-14 17:40:31 +0200
commit6ef5e000a26be15919a4006f4b879fcaea8915c5 (patch)
tree4a280dbaa57968cb89fb57b3d8694d2621aa273d /qa/rpc-tests/test_framework/util.py
parent430fffefaab6832b8f6605f14a992e7e55b9547e (diff)
parentfaa41ee204124da19dcf1e5b8a3aef1e216bf5e6 (diff)
downloadbitcoin-6ef5e000a26be15919a4006f4b879fcaea8915c5.tar.xz
Merge #7853: [qa] py2: Unfiddle strings into bytes explicitly
faa41ee [qa] py2: Unfiddle strings into bytes explicitly (MarcoFalke)
Diffstat (limited to 'qa/rpc-tests/test_framework/util.py')
-rw-r--r--qa/rpc-tests/test_framework/util.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py
index acb7f8a6b4..8b720b54a1 100644
--- a/qa/rpc-tests/test_framework/util.py
+++ b/qa/rpc-tests/test_framework/util.py
@@ -1,6 +1,8 @@
# Copyright (c) 2014-2015 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
@@ -91,6 +95,15 @@ def check_json_precision():
def count_bytes(hex_string):
return len(bytearray.fromhex(hex_string))
+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
@@ -466,7 +479,7 @@ def assert_is_hash_string(string, length=64):
"String %r contains invalid characters for a hash." % string)
def satoshi_round(amount):
- return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)
+ return Decimal(amount).quantize(Decimal('0.00000001'), rounding=ROUND_DOWN)
# Helper to create at least "count" utxos
# Pass in a fee that is sufficient for relay and mining new transactions.