mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-13 11:35:20 +01:00
tests: Add a sha256sum_file function to util
This commit is contained in:
parent
0bd995aa19
commit
092fc43485
1 changed files with 9 additions and 0 deletions
|
@ -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
|
||||
############################################
|
||||
|
|
Loading…
Add table
Reference in a new issue