Skip to content

Commit

Permalink
tests: Add a sha256sum_file function to util
Browse files Browse the repository at this point in the history
  • Loading branch information
achow101 committed Nov 4, 2020
1 parent 0bd995a commit 092fc43
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/functional/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from binascii import unhexlify
from decimal import Decimal, ROUND_DOWN
from subprocess import CalledProcessError
import hashlib
import inspect
import json
import logging
Expand Down Expand Up @@ -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
############################################
Expand Down

0 comments on commit 092fc43

Please sign in to comment.