aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2020-04-30 01:05:55 -0400
committerAndrew Chow <achow101-github@achow101.com>2020-11-04 12:15:25 -0500
commit092fc434854f881330771a93a1280ac67b1d3549 (patch)
treed8db80b62bb60145680150da4b5b533dd140ca74 /test
parent0bd995aa19be65b0dd23df1df571c71428c2bc32 (diff)
downloadbitcoin-092fc434854f881330771a93a1280ac67b1d3549.tar.xz
tests: Add a sha256sum_file function to util
Diffstat (limited to 'test')
-rw-r--r--test/functional/test_framework/util.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/functional/test_framework/util.py b/test/functional/test_framework/util.py
index 7688febae7..0f4713d50e 100644
--- a/test/functional/test_framework/util.py
+++ b/test/functional/test_framework/util.py
@@ -8,6 +8,7 @@ from base64 import b64encode
from binascii import unhexlify
from decimal import Decimal, ROUND_DOWN
from subprocess import CalledProcessError
+import hashlib
import inspect
import json
import logging
@@ -260,6 +261,14 @@ def wait_until_helper(predicate, *, attempts=float('inf'), timeout=float('inf'),
raise AssertionError("Predicate {} not true after {} seconds".format(predicate_source, timeout))
raise RuntimeError('Unreachable')
+def sha256sum_file(filename):
+ h = hashlib.sha256()
+ with open(filename, 'rb') as f:
+ d = f.read(4096)
+ while len(d) > 0:
+ h.update(d)
+ d = f.read(4096)
+ return h.digest()
# RPC/P2P connection constants and functions
############################################