Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
352a7d3697 | |||
4b47706883 | |||
15cac7d390 | |||
c470b70722 | |||
9a651a9d3d | |||
a293d4bada | |||
71526e64aa | |||
173c911f28 | |||
896afc7675 | |||
af31c92fa6 | |||
3a0da1e2d6 | |||
de42d4f509 | |||
dd1c0776b2 | |||
1c4fe9533f |
@ -3,9 +3,9 @@ language: python
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- python: 3.6
|
- python: 3.6
|
||||||
env: TOXENV=py36-test
|
env: TOXENV=py36
|
||||||
- python: 3.7
|
- python: 3.7
|
||||||
env: TOXENV=py37-test
|
env: TOXENV=py37
|
||||||
- python: 3.7
|
- python: 3.7
|
||||||
env: TOXENV=lint
|
env: TOXENV=lint
|
||||||
- python: 3.7
|
- python: 3.7
|
||||||
|
@ -1,3 +1,30 @@
|
|||||||
|
Merkle_Tree_Stream 0.0.1a4 (2019-11-03)
|
||||||
|
=======================================
|
||||||
|
|
||||||
|
Improved Documentation
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
- New Sphinx theme. Improved clarity with documentation.
|
||||||
|
|
||||||
|
|
||||||
|
Merkle_Tree_Stream 0.0.1a3 (2019-10-08)
|
||||||
|
=======================================
|
||||||
|
|
||||||
|
Bug Fixes
|
||||||
|
---------
|
||||||
|
|
||||||
|
- MerkleTreeIterator -> MerkleTreeGenerator
|
||||||
|
|
||||||
|
|
||||||
|
Merkle_Tree_Stream 0.0.1a2 (2019-10-06)
|
||||||
|
=======================================
|
||||||
|
|
||||||
|
Bug Fixes
|
||||||
|
---------
|
||||||
|
|
||||||
|
- MerkleTreeIterator leaf and parent functions now return bytes.
|
||||||
|
|
||||||
|
|
||||||
Merkle_Tree_Stream 0.0.1a1 (2019-08-07)
|
Merkle_Tree_Stream 0.0.1a1 (2019-08-07)
|
||||||
=======================================
|
=======================================
|
||||||
|
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
Introduction
|
Introduction
|
||||||
------------
|
------------
|
||||||
|
|
||||||
The DatPy community is committed to providing an inclusive,
|
The DatPy community is committed to providing an inclusive, safe, and
|
||||||
safe, and collaborative environment for all participants, regardless of their
|
collaborative environment for all participants, regardless of their gender,
|
||||||
gender, gender expression, race, ethnicity, religion, sexual orientation,
|
gender expression, race, ethnicity, religion, sexual orientation, sexual
|
||||||
sexual characteristics, physical appearance, disability, or age. We encourage
|
characteristics, physical appearance, disability, or age. We encourage every
|
||||||
every participant to be themselves, and must respect the rights of others. The
|
participant to be themselves, and must respect the rights of others. The code
|
||||||
code of conduct is a set of guidelines that establishes shared values and
|
of conduct is a set of guidelines that establishes shared values and ensures
|
||||||
ensures that behaviors that may harm participants are avoided.
|
that behaviors that may harm participants are avoided.
|
||||||
|
|
||||||
The values of the DatPy community are focused on developing
|
The values of the DatPy community are focused on developing both our individual
|
||||||
both our individual and collective potential, supporting and empowering the
|
and collective potential, supporting and empowering the most marginalized,
|
||||||
most marginalized, mutual respect, and an anti-violence approach that favors
|
mutual respect, and an anti-violence approach that favors support and
|
||||||
support and collaboration among participants and the resolution of conflicts. A
|
collaboration among participants and the resolution of conflicts. A code of
|
||||||
code of conduct helps us co-exist in a more positive way and provides
|
conduct helps us co-exist in a more positive way and provides individuals who
|
||||||
individuals who are victims of negative behaviors with confidence that they
|
are victims of negative behaviors with confidence that they will be supported
|
||||||
will be supported by the organization and the DatPy
|
by the organization and the DatPy community, who respects and stands behind the
|
||||||
community, who respects and stands behind the code of conduct.
|
code of conduct.
|
||||||
|
|
||||||
The DatPy community works towards providing a welcoming
|
The DatPy community works towards providing a welcoming environment where
|
||||||
environment where participants are treated with dignity and respect and are
|
participants are treated with dignity and respect and are free to be
|
||||||
free to be themselves. We encourage all participants to approach the
|
themselves. We encourage all participants to approach the Librehosters network
|
||||||
Librehosters network with an open and positive attitude, engaging
|
with an open and positive attitude, engaging constructively with others at all
|
||||||
constructively with others at all times.
|
times.
|
||||||
|
|
||||||
Respect for Diversity & Inclusion
|
Respect for Diversity & Inclusion
|
||||||
---------------------------------
|
---------------------------------
|
||||||
@ -92,9 +92,9 @@ Enforcement
|
|||||||
Overseeing the code of conduct
|
Overseeing the code of conduct
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
The DatPy community, composed of volunteers, oversees the
|
The DatPy community, composed of volunteers, oversees the code of conduct,
|
||||||
code of conduct, including addressing all incident reports. Breaking the code
|
including addressing all incident reports. Breaking the code of conduct may
|
||||||
of conduct may result in immediate expulsion from the Librehosters network.
|
result in immediate expulsion from the Librehosters network.
|
||||||
|
|
||||||
How to Report an Incident
|
How to Report an Incident
|
||||||
=========================
|
=========================
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
Get started
|
Get started
|
||||||
-----------
|
-----------
|
||||||
|
|
||||||
Install `Tox`_ with:
|
Install `Tox`_.
|
||||||
|
|
||||||
.. _tox: http://tox.readthedocs.io/
|
.. _tox: http://tox.readthedocs.io/
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
$ pip install --user tox
|
|
||||||
|
|
||||||
Run tests
|
Run tests
|
||||||
---------
|
---------
|
||||||
|
|
||||||
@ -37,25 +33,37 @@ Type check source
|
|||||||
|
|
||||||
tox -e type
|
tox -e type
|
||||||
|
|
||||||
Release Process
|
Build the documentation
|
||||||
---------------
|
-----------------------
|
||||||
|
|
||||||
Add a change entry and re-generate the changelog:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
$ towncrier
|
$ tox -e docs
|
||||||
|
$ tox -e docs-livereload
|
||||||
|
|
||||||
Make a new release tag:
|
Make a new release
|
||||||
|
------------------
|
||||||
|
|
||||||
.. code-block:: bash
|
Ensure metadata for packaging is correct.
|
||||||
|
|
||||||
$ git tag x.x.x
|
|
||||||
$ git push --tags
|
|
||||||
|
|
||||||
Then run the release process:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
$ tox -e metadata-release
|
$ tox -e metadata-release
|
||||||
|
|
||||||
|
Generate the changelog with the next target version.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ export VERSION=1.0.1 tox -e changelog
|
||||||
|
|
||||||
|
Make a new Git tag.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ git tag -a 1.0.1
|
||||||
|
|
||||||
|
And finally, make a new release.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
$ tox -e release
|
$ tox -e release
|
||||||
|
23
README.rst
23
README.rst
@ -48,28 +48,27 @@ See the following for more:
|
|||||||
.. _Merkle Tree: https://datprotocol.github.io/book/ch01-02-merkle-tree.html
|
.. _Merkle Tree: https://datprotocol.github.io/book/ch01-02-merkle-tree.html
|
||||||
.. _Merkle Tree Stream: https://datprotocol.github.io/book/ch02-02-merkle-tree-stream.html
|
.. _Merkle Tree Stream: https://datprotocol.github.io/book/ch02-02-merkle-tree-stream.html
|
||||||
|
|
||||||
|
Part of the `Datpy`_ project.
|
||||||
|
|
||||||
|
.. _Datpy: https://datpy.decentral1.se/
|
||||||
|
|
||||||
A note on naming
|
A note on naming
|
||||||
================
|
================
|
||||||
|
|
||||||
For the purposes of uniformity and easy of discovery alongside the reference
|
For the purposes of uniformity and easy of discovery alongside the reference
|
||||||
implementation, we use the same module name as `merkle-tree-stream`_. This may
|
implementation, we use the same module name as `merkle-tree-stream`_. However,
|
||||||
cause confusion since it is not clear what exactly is referred to when using
|
there is currently no stream implemented, only a generator is available. This
|
||||||
the term "stream" in the context of Python. To be clear, this module provides a
|
is because the reference implementation of Hypercore 7 makes use of the
|
||||||
`Python iterator`_ which appears to match the implementation and meaning of the
|
generator only. A `stream`_ implementation may follow.
|
||||||
reference implementation.
|
|
||||||
|
|
||||||
.. _merkle-tree-stream: https://github.com/mafintosh/merkle-tree-stream
|
.. _merkle-tree-stream: https://github.com/mafintosh/merkle-tree-stream
|
||||||
.. _Python iterator: https://docs.python.org/3/c-api/iter.html
|
.. _stream: https://docs.python.org/3/library/asyncio-stream.html
|
||||||
|
|
||||||
.. _documentation:
|
.. _documentation:
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
*************
|
*************
|
||||||
|
|
||||||
* https://merkle-tree-stream.readthedocs.io/
|
* `merkle-tree-stream.readthedocs.io`_
|
||||||
|
|
||||||
Mirroring
|
.. _merkle-tree-stream.readthedocs.io: https://merkle-tree-stream.readthedocs.io/
|
||||||
*********
|
|
||||||
|
|
||||||
* https://hack.decentral1.se/datpy/merkle-tree-stream (primary)
|
|
||||||
* https://github.com/datpy/merkle-tree-stream
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
author = 'decentral1se'
|
author = 'decentral1se'
|
||||||
copyright = '2019, decentral1se'
|
copyright = '2019, decentral1se'
|
||||||
html_static_path = ['_static']
|
html_static_path = ['_static']
|
||||||
html_theme = 'alabaster'
|
html_theme = 'sphinx_rtd_theme'
|
||||||
master_doc = 'index'
|
master_doc = 'index'
|
||||||
project = 'merkle-tree-stream'
|
project = 'merkle-tree-stream'
|
||||||
templates_path = ['_templates']
|
templates_path = ['_templates']
|
||||||
|
24
documentation/source/example.rst
Normal file
24
documentation/source/example.rst
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
.. _example:
|
||||||
|
|
||||||
|
*******
|
||||||
|
Example
|
||||||
|
*******
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from hashlib import sha256
|
||||||
|
from merkle_tree_stream import MerkleTreeGenerator
|
||||||
|
|
||||||
|
def leaf(node, roots=None):
|
||||||
|
return sha256(node.data).digest()
|
||||||
|
|
||||||
|
def parent(first, second):
|
||||||
|
sha256 = hashlib.sha256()
|
||||||
|
sha256.update(first.data)
|
||||||
|
sha256.update(second.data)
|
||||||
|
return sha256.digest()
|
||||||
|
|
||||||
|
merkle = MerkleTreeGenerator(leaf=leaf, parent=parent)
|
||||||
|
merkle.write('hello')
|
||||||
|
merkle.write('hashed')
|
||||||
|
merkle.write('world')
|
@ -1,12 +1,13 @@
|
|||||||
.. include:: ../../README.rst
|
.. include:: ../../README.rst
|
||||||
:end-before: _documentation
|
:end-before: _documentation
|
||||||
|
|
||||||
Table of Contents
|
|
||||||
*****************
|
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
:hidden:
|
||||||
|
|
||||||
install
|
install
|
||||||
|
upgrade
|
||||||
|
example
|
||||||
modules-api
|
modules-api
|
||||||
other-impls
|
other-impls
|
||||||
contribute
|
contribute
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
Other Implementations
|
Other Implementations
|
||||||
*********************
|
*********************
|
||||||
|
|
||||||
* https://github.com/mafintosh/merkle-tree-stream
|
* `mafintosh/merkle-tree-stream`_
|
||||||
* https://github.com/datrs/merkle-tree-stream
|
* `datrs/merkle-tree-stream`_
|
||||||
* https://github.com/datcxx/merkle-tree-stream
|
* `datcxx/merkle-tree-stream`_
|
||||||
|
|
||||||
|
.. _mafintosh/merkle-tree-stream: https://github.com/mafintosh/merkle-tree-stream
|
||||||
|
.. _datrs/merkle-tree-stream: https://github.com/datrs/merkle-tree-stream
|
||||||
|
.. _datcxx/merkle-tree-stream: https://github.com/datcxx/merkle-tree-stream
|
||||||
|
7
documentation/source/upgrade.rst
Normal file
7
documentation/source/upgrade.rst
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
*******
|
||||||
|
Upgrade
|
||||||
|
*******
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ pip install --upgrade merkle-tree-stream
|
@ -1,7 +1,7 @@
|
|||||||
"""merkle-tree-stream module."""
|
"""merkle-tree-stream module."""
|
||||||
|
|
||||||
from merkle_tree_stream.node import MerkleTreeNode # noqa
|
from merkle_tree_stream.node import MerkleTreeNode # noqa
|
||||||
from merkle_tree_stream.tree import MerkleTreeIterator # noqa
|
from merkle_tree_stream.tree import MerkleTreeGenerator # noqa
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
@ -23,7 +23,7 @@ class MerkleTreeNode:
|
|||||||
parent: int
|
parent: int
|
||||||
size: int
|
size: int
|
||||||
data: bytes
|
data: bytes
|
||||||
hash: Optional[str] = attr.Factory(str)
|
hash: Optional[bytes] = attr.Factory(bytes)
|
||||||
|
|
||||||
def __attrs_post_init__(self) -> Any:
|
def __attrs_post_init__(self) -> Any:
|
||||||
"""Initialise the parent index."""
|
"""Initialise the parent index."""
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
"""A merkle tree iterator."""
|
"""A merkle tree generator."""
|
||||||
|
|
||||||
from typing import Any, Callable, Iterator, List
|
from typing import Any, Callable, Iterator, List
|
||||||
|
|
||||||
@ -7,27 +7,25 @@ from flat_tree import FlatTreeAccessor
|
|||||||
|
|
||||||
from merkle_tree_stream.node import MerkleTreeNode
|
from merkle_tree_stream.node import MerkleTreeNode
|
||||||
|
|
||||||
Hash = str
|
|
||||||
|
|
||||||
EMPTY_DATA = b''
|
EMPTY_DATA = b''
|
||||||
EMPTY_HASH = None
|
EMPTY_HASH = None
|
||||||
|
|
||||||
__all__ = ['MerkleTreeIterator']
|
__all__ = ['MerkleTreeGenerator']
|
||||||
|
|
||||||
flat_tree = FlatTreeAccessor()
|
flat_tree = FlatTreeAccessor()
|
||||||
|
|
||||||
|
|
||||||
@attr.s(auto_attribs=True)
|
@attr.s(auto_attribs=True)
|
||||||
class MerkleTreeIterator:
|
class MerkleTreeGenerator:
|
||||||
"""A merkle tree iterator.
|
"""A merkle tree generator.
|
||||||
|
|
||||||
:param leaf: The leaf hash generation function
|
:param leaf: The leaf hash generation function
|
||||||
:param parent: The parent hash generation function
|
:param parent: The parent hash generation function
|
||||||
:param roots: The tree roots
|
:param roots: The tree roots
|
||||||
"""
|
"""
|
||||||
|
|
||||||
leaf: Callable[[MerkleTreeNode], Hash]
|
leaf: Callable[[MerkleTreeNode], bytes]
|
||||||
parent: Callable[[MerkleTreeNode, MerkleTreeNode], Hash]
|
parent: Callable[[MerkleTreeNode, MerkleTreeNode], bytes]
|
||||||
roots: List[MerkleTreeNode] = attr.Factory(list)
|
roots: List[MerkleTreeNode] = attr.Factory(list)
|
||||||
|
|
||||||
_position: int = 0
|
_position: int = 0
|
||||||
|
@ -15,7 +15,7 @@ include = '\.pyi?$'
|
|||||||
[tool.towncrier]
|
[tool.towncrier]
|
||||||
directory = "changelog/"
|
directory = "changelog/"
|
||||||
filename = "CHANGELOG.rst"
|
filename = "CHANGELOG.rst"
|
||||||
package = "merkle-tree-stream"
|
package = "merkle_tree_stream"
|
||||||
package_dir = "merkle_tree_stream"
|
package_dir = "merkle_tree_stream"
|
||||||
|
|
||||||
[[tool.towncrier.type]]
|
[[tool.towncrier.type]]
|
||||||
|
@ -37,7 +37,7 @@ install_requires =
|
|||||||
|
|
||||||
[options]
|
[options]
|
||||||
use_scm_version = True
|
use_scm_version = True
|
||||||
python_requires = !=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*
|
python_requires = >=3.6
|
||||||
setup_requires =
|
setup_requires =
|
||||||
setuptools_scm
|
setuptools_scm
|
||||||
setuptools_scm_git_archive
|
setuptools_scm_git_archive
|
||||||
@ -47,7 +47,7 @@ packages = find:
|
|||||||
zip_safe = False
|
zip_safe = False
|
||||||
install_requires =
|
install_requires =
|
||||||
attrs >= 19.1.0, < 20.0
|
attrs >= 19.1.0, < 20.0
|
||||||
flat-tree == 0.0.1a3 # TODO(decentral1se): use bounds when 0.0.1 lands
|
flat-tree >= 0.0.1a3, < 1.0
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
where = .
|
where = .
|
||||||
@ -61,6 +61,7 @@ warning-is-error = True
|
|||||||
[options.extras_require]
|
[options.extras_require]
|
||||||
docs =
|
docs =
|
||||||
sphinx
|
sphinx
|
||||||
|
sphinx_rtd_theme
|
||||||
sphinx-autodoc-typehints >= 1.6.0, < 2.0
|
sphinx-autodoc-typehints >= 1.6.0, < 2.0
|
||||||
changelog =
|
changelog =
|
||||||
towncrier <= 19.2.0, < 20.0
|
towncrier <= 19.2.0, < 20.0
|
||||||
|
@ -6,7 +6,7 @@ import pytest
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def leaf():
|
def leaf():
|
||||||
def _leaf(node, roots=None):
|
def _leaf(node, roots=None):
|
||||||
return hashlib.sha256(node.data).hexdigest()
|
return hashlib.sha256(node.data).digest()
|
||||||
|
|
||||||
return _leaf
|
return _leaf
|
||||||
|
|
||||||
@ -17,6 +17,6 @@ def parent():
|
|||||||
sha256 = hashlib.sha256()
|
sha256 = hashlib.sha256()
|
||||||
sha256.update(first.data)
|
sha256.update(first.data)
|
||||||
sha256.update(second.data)
|
sha256.update(second.data)
|
||||||
return sha256.hexdigest()
|
return sha256.digest()
|
||||||
|
|
||||||
return _parent
|
return _parent
|
||||||
|
@ -4,61 +4,53 @@ import hashlib
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from merkle_tree_stream import MerkleTreeIterator, MerkleTreeNode
|
from merkle_tree_stream import MerkleTreeGenerator, MerkleTreeNode
|
||||||
|
|
||||||
|
|
||||||
def test_hashes(leaf, parent):
|
def test_hashes(leaf, parent):
|
||||||
merkle_iter = MerkleTreeIterator(leaf=leaf, parent=parent)
|
merkle = MerkleTreeGenerator(leaf=leaf, parent=parent)
|
||||||
|
|
||||||
merkle_iter.write(b'a')
|
merkle.write(b'a')
|
||||||
merkle_iter.write(b'b')
|
merkle.write(b'b')
|
||||||
|
|
||||||
expected_count = 2 + 1 # nodes plus parent
|
expected_count = 2 + 1 # nodes plus parent
|
||||||
assert len(merkle_iter) == expected_count
|
assert len(merkle) == expected_count
|
||||||
|
|
||||||
assert next(merkle_iter) == MerkleTreeNode(
|
assert next(merkle) == MerkleTreeNode(
|
||||||
index=0,
|
index=0, parent=1, hash=hashlib.sha256(b'a').digest(), size=1, data=b'a'
|
||||||
parent=1,
|
|
||||||
hash=hashlib.sha256(b'a').hexdigest(),
|
|
||||||
size=1,
|
|
||||||
data=b'a',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
assert next(merkle_iter) == MerkleTreeNode(
|
assert next(merkle) == MerkleTreeNode(
|
||||||
index=2,
|
index=2, parent=1, hash=hashlib.sha256(b'b').digest(), size=1, data=b'b'
|
||||||
parent=1,
|
|
||||||
hash=hashlib.sha256(b'b').hexdigest(),
|
|
||||||
size=1,
|
|
||||||
data=b'b',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
hashed = hashlib.sha256(b'a')
|
hashed = hashlib.sha256(b'a')
|
||||||
hashed.update(b'b')
|
hashed.update(b'b')
|
||||||
|
|
||||||
assert next(merkle_iter) == MerkleTreeNode(
|
assert next(merkle) == MerkleTreeNode(
|
||||||
index=1, parent=3, hash=hashed.hexdigest(), size=2, data=b''
|
index=1, parent=3, hash=hashed.digest(), size=2, data=b''
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(StopIteration):
|
with pytest.raises(StopIteration):
|
||||||
next(merkle_iter)
|
next(merkle)
|
||||||
|
|
||||||
|
|
||||||
def test_single_root(leaf, parent):
|
def test_single_root(leaf, parent):
|
||||||
merkle_iter = MerkleTreeIterator(leaf=leaf, parent=parent)
|
merkle = MerkleTreeGenerator(leaf=leaf, parent=parent)
|
||||||
|
|
||||||
merkle_iter.write(b'a')
|
merkle.write(b'a')
|
||||||
merkle_iter.write(b'b')
|
merkle.write(b'b')
|
||||||
merkle_iter.write(b'c')
|
merkle.write(b'c')
|
||||||
merkle_iter.write(b'd')
|
merkle.write(b'd')
|
||||||
|
|
||||||
assert len(merkle_iter.roots) == 1
|
assert len(merkle.roots) == 1
|
||||||
|
|
||||||
|
|
||||||
def multiple_roots(leaf, parent):
|
def multiple_roots(leaf, parent):
|
||||||
merkle_iter = MerkleTreeIterator(leaf=leaf, parent=parent)
|
merkle = MerkleTreeGenerator(leaf=leaf, parent=parent)
|
||||||
|
|
||||||
merkle_iter.write(b'a')
|
merkle.write(b'a')
|
||||||
merkle_iter.write(b'b')
|
merkle.write(b'b')
|
||||||
merkle_iter.write(b'c')
|
merkle.write(b'c')
|
||||||
|
|
||||||
assert len(merkle_iter.roots) > 1
|
assert len(merkle.roots) > 1
|
||||||
|
65
tox.ini
65
tox.ini
@ -1,6 +1,6 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist =
|
envlist =
|
||||||
{py36,py37}-test
|
{py36,py37}
|
||||||
lint
|
lint
|
||||||
sort
|
sort
|
||||||
format
|
format
|
||||||
@ -17,70 +17,63 @@ deps =
|
|||||||
pytest
|
pytest
|
||||||
pytest-cov
|
pytest-cov
|
||||||
pytest-mock
|
pytest-mock
|
||||||
commands =
|
commands = pytest test/ --cov={toxinidir}/merkle_tree_stream/ --no-cov-on-fail {posargs}
|
||||||
pytest test/ --cov={toxinidir}/merkle_tree_stream/ --no-cov-on-fail {posargs}
|
|
||||||
|
|
||||||
[testenv:lint]
|
[testenv:lint]
|
||||||
description = lint the source
|
description = lint the source
|
||||||
skipdist = True
|
skipdist = True
|
||||||
deps =
|
deps = flake8
|
||||||
flake8
|
commands = flake8 {posargs} merkle_tree_stream/ test/
|
||||||
commands =
|
|
||||||
flake8 {posargs} merkle_tree_stream/ test/
|
|
||||||
|
|
||||||
[testenv:sort]
|
[testenv:sort]
|
||||||
description = sort the source
|
description = sort the source
|
||||||
skipdist = True
|
skipdist = True
|
||||||
deps =
|
deps = isort
|
||||||
isort
|
commands = isort {posargs:-rc -c} -sp setup.cfg merkle_tree_stream/ test/
|
||||||
commands =
|
|
||||||
isort {posargs:-rc -c} -sp setup.cfg merkle_tree_stream/ test/
|
|
||||||
|
|
||||||
[testenv:format]
|
[testenv:format]
|
||||||
description = format the source
|
description = format the source
|
||||||
skipdist = True
|
skipdist = True
|
||||||
basepython = python3.6
|
deps = black
|
||||||
deps =
|
commands = black {posargs:--check} merkle_tree_stream/ test/
|
||||||
black
|
|
||||||
commands =
|
|
||||||
black {posargs:--check} merkle_tree_stream/ test/
|
|
||||||
|
|
||||||
[testenv:type]
|
[testenv:type]
|
||||||
description = type check the source
|
description = type check the source
|
||||||
basepython = python3.7
|
|
||||||
skipdist = True
|
skipdist = True
|
||||||
deps =
|
deps = mypy
|
||||||
mypy
|
commands = mypy merkle_tree_stream/ test/
|
||||||
commands =
|
|
||||||
mypy merkle_tree_stream/ test/
|
|
||||||
|
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
description = build the documentation
|
description = build the documentation
|
||||||
skipdist = True
|
skipdist = True
|
||||||
extras =
|
extras = docs
|
||||||
docs
|
commands = python -m setup build_sphinx
|
||||||
commands =
|
|
||||||
python -m setup build_sphinx
|
|
||||||
|
|
||||||
[testenv:changelog]
|
[testenv:changelog]
|
||||||
description = draft the changelog
|
description = draw up the new changelog
|
||||||
skipdist = True
|
skipdist = True
|
||||||
extras =
|
passenv = VERSION
|
||||||
changelog
|
deps = towncrier
|
||||||
commands =
|
commands = towncrier --version={env:VERSION} {posargs}
|
||||||
towncrier --draft
|
|
||||||
|
|
||||||
[testenv:metadata-release]
|
[testenv:metadata-release]
|
||||||
description = validate the package metadata
|
description = validate the package metadata
|
||||||
deps =
|
deps = twine
|
||||||
twine
|
|
||||||
commands =
|
commands =
|
||||||
twine check .tox/dist/*
|
rm -rf {toxworkdir}/dist
|
||||||
|
python -m setup sdist --dist-dir {toxworkdir}/dist bdist_wheel
|
||||||
|
python -m setup sdist --dist-dir {toxworkdir}/dist bdist_egg
|
||||||
|
twine check {toxworkdir}/dist/*
|
||||||
|
whitelist_externals =
|
||||||
|
rm
|
||||||
|
|
||||||
[testenv:release]
|
[testenv:release]
|
||||||
description = make a release
|
description = make a release
|
||||||
deps =
|
deps = {[testenv:metadata-release]deps}
|
||||||
{[testenv:metadata-release]deps}
|
|
||||||
commands =
|
commands =
|
||||||
python -m setup sdist bdist_wheel
|
rm -rf {toxworkdir}/dist
|
||||||
|
python -m setup sdist --dist-dir {toxworkdir}/dist bdist_wheel
|
||||||
|
python -m setup sdist --dist-dir {toxworkdir}/dist bdist_egg
|
||||||
twine upload {toxworkdir}/dist/*
|
twine upload {toxworkdir}/dist/*
|
||||||
|
whitelist_externals =
|
||||||
|
rm
|
||||||
|
Reference in New Issue
Block a user