diff options
Diffstat (limited to 'qa/rpc-tests/test_framework')
-rwxr-xr-x | qa/rpc-tests/test_framework/mininode.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/qa/rpc-tests/test_framework/mininode.py b/qa/rpc-tests/test_framework/mininode.py index 9d0fb713a1..259dba71c3 100755 --- a/qa/rpc-tests/test_framework/mininode.py +++ b/qa/rpc-tests/test_framework/mininode.py @@ -230,6 +230,14 @@ def ser_int_vector(l): r += struct.pack("<i", i) return r +# Deserialize from a hex string representation (eg from RPC) +def FromHex(obj, hex_string): + obj.deserialize(cStringIO.StringIO(binascii.unhexlify(hex_string))) + return obj + +# Convert a binary-serializable object to hex (eg for submission via RPC) +def ToHex(obj): + return binascii.hexlify(obj.serialize()).decode('utf-8') # Objects that map to bitcoind objects, which can be serialized/deserialized |