Appease black
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Luke Murphy 2020-05-16 18:37:43 +02:00
parent a04a3e32f0
commit 9776cea9f0
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
5 changed files with 21 additions and 21 deletions

View File

@ -10,6 +10,6 @@ except ImportError:
try:
__version__ = pkg_resources.get_distribution('merkle_tree_stream').version
__version__ = pkg_resources.get_distribution("merkle_tree_stream").version
except Exception:
__version__ = 'unknown'
__version__ = "unknown"

View File

@ -5,7 +5,7 @@ from typing import Any, Optional
import attr
from flat_tree import FlatTreeAccessor
__all__ = ['MerkleTreeNode']
__all__ = ["MerkleTreeNode"]
@attr.s(auto_attribs=True)

View File

@ -7,10 +7,10 @@ from flat_tree import FlatTreeAccessor
from merkle_tree_stream.node import MerkleTreeNode
EMPTY_DATA = b''
EMPTY_DATA = b""
EMPTY_HASH = None
__all__ = ['MerkleTreeGenerator']
__all__ = ["MerkleTreeGenerator"]
flat_tree = FlatTreeAccessor()

View File

@ -10,25 +10,25 @@ from merkle_tree_stream import MerkleTreeGenerator, MerkleTreeNode
def test_hashes(leaf, parent):
merkle = MerkleTreeGenerator(leaf=leaf, parent=parent)
merkle.write(b'a')
merkle.write(b'b')
merkle.write(b"a")
merkle.write(b"b")
expected_count = 2 + 1 # nodes plus parent
assert len(merkle) == expected_count
assert next(merkle) == MerkleTreeNode(
index=0, parent=1, hash=hashlib.sha256(b'a').digest(), size=1, data=b'a'
index=0, parent=1, hash=hashlib.sha256(b"a").digest(), size=1, data=b"a"
)
assert next(merkle) == MerkleTreeNode(
index=2, parent=1, hash=hashlib.sha256(b'b').digest(), size=1, data=b'b'
index=2, parent=1, hash=hashlib.sha256(b"b").digest(), size=1, data=b"b"
)
hashed = hashlib.sha256(b'a')
hashed.update(b'b')
hashed = hashlib.sha256(b"a")
hashed.update(b"b")
assert next(merkle) == MerkleTreeNode(
index=1, parent=3, hash=hashed.digest(), size=2, data=b''
index=1, parent=3, hash=hashed.digest(), size=2, data=b""
)
with pytest.raises(StopIteration):
@ -38,10 +38,10 @@ def test_hashes(leaf, parent):
def test_single_root(leaf, parent):
merkle = MerkleTreeGenerator(leaf=leaf, parent=parent)
merkle.write(b'a')
merkle.write(b'b')
merkle.write(b'c')
merkle.write(b'd')
merkle.write(b"a")
merkle.write(b"b")
merkle.write(b"c")
merkle.write(b"d")
assert len(merkle.roots) == 1
@ -49,8 +49,8 @@ def test_single_root(leaf, parent):
def multiple_roots(leaf, parent):
merkle = MerkleTreeGenerator(leaf=leaf, parent=parent)
merkle.write(b'a')
merkle.write(b'b')
merkle.write(b'c')
merkle.write(b"a")
merkle.write(b"b")
merkle.write(b"c")
assert len(merkle.roots) > 1

View File

@ -2,9 +2,9 @@
def test_version_fails_gracefully(mocker):
target = 'pkg_resources.get_distribution'
target = "pkg_resources.get_distribution"
mocker.patch(target, side_effect=Exception())
from merkle_tree_stream.__init__ import __version__
assert __version__ == 'unknown'
assert __version__ == "unknown"