aboutsummaryrefslogtreecommitdiff
path: root/qa/rpc-tests/test_framework/util.py
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2016-04-10 16:54:28 +0200
committerMarcoFalke <falke.marco@gmail.com>2016-04-10 20:35:57 +0200
commitfaa41ee204124da19dcf1e5b8a3aef1e216bf5e6 (patch)
tree4b33bcb6db57bcde90e12d1b0e9140c4d8cb32ba /qa/rpc-tests/test_framework/util.py
parent0afac87e8173dd71616e211aa08dcd59cb5cf90e (diff)
downloadbitcoin-faa41ee204124da19dcf1e5b8a3aef1e216bf5e6.tar.xz
[qa] py2: Unfiddle strings into bytes explicitly
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 d9fe0f75f2..42541b4162 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.