Skip to content
Snippets Groups Projects
Commit 1edf8078 authored by Moul's avatar Moul
Browse files

Move verify in blockchain.verify (#330)

parent 01a71493
No related branches found
No related tags found
1 merge request!216#330: Restructure repository
File moved
......@@ -23,7 +23,7 @@ from silkaj.auth import generate_auth_file
from silkaj.blockchain.blocks import list_blocks
from silkaj.blockchain.difficulty import difficulties
from silkaj.blockchain.information import argos_info, currency_info
from silkaj.blocks import verify_blocks_signatures
from silkaj.blockchain.verify import verify_blocks_signatures
from silkaj.cert import send_certification
from silkaj.checksum import checksum_command
from silkaj.constants import (
......
# Copyright 2016-2022 Maël Azimi <m.a@moul.re>
#
# Silkaj is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Silkaj is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
......@@ -19,13 +19,7 @@ from duniterpy.api import bma
from duniterpy.documents import Block
from silkaj import cli
from silkaj.blocks import (
check_passed_blocks_range,
display_result,
get_chunk,
get_chunk_size,
verify_block_signature,
)
from silkaj.blockchain import verify
from silkaj.constants import (
BMA_MAX_BLOCKS_CHUNK_SIZE,
FAILURE_EXIT_STATUS,
......@@ -49,7 +43,7 @@ def test_check_passed_blocks_range(from_block, to_block, capsys, monkeypatch):
client = client_instance()
# https://medium.com/python-pandemonium/testing-sys-exit-with-pytest-10c6e5f7726f
with pytest.raises(SystemExit) as pytest_wrapped_e:
check_passed_blocks_range(client, from_block, to_block)
verify.check_passed_blocks_range(client, from_block, to_block)
assert pytest_wrapped_e.type == SystemExit
assert pytest_wrapped_e.value.code == FAILURE_EXIT_STATUS
captured = capsys.readouterr()
......@@ -94,7 +88,7 @@ def test_verify_blocks_signatures(from_block, to_block, monkeypatch):
],
)
def test_get_chunk_size(from_block, to_block, chunks_from, chunk_from):
chunk_size = get_chunk_size(from_block, to_block, chunks_from, chunk_from)
chunk_size = verify.get_chunk_size(from_block, to_block, chunks_from, chunk_from)
if chunk_from != chunks_from[-1]:
assert chunk_size == BMA_MAX_BLOCKS_CHUNK_SIZE
else:
......@@ -104,7 +98,7 @@ def test_get_chunk_size(from_block, to_block, chunks_from, chunk_from):
@pytest.mark.parametrize("chunk_size, chunk_from", [(2, 1), (5, 10)])
def test_get_chunks(chunk_size, chunk_from):
client = client_instance()
chunk = get_chunk(client, chunk_size, chunk_from)
chunk = verify.get_chunk(client, chunk_size, chunk_from)
assert chunk[0]["number"] + chunk_size - 1 == chunk[-1]["number"]
......@@ -141,7 +135,7 @@ def test_verify_block_signature(signature, block_raw):
# Check with valid and non-valid signatures block
invalid_signatures_blocks = []
block = Block.from_signed_raw(block_raw + signature + "\n")
verify_block_signature(invalid_signatures_blocks, block)
verify.verify_block_signature(invalid_signatures_blocks, block)
if block.number == G1_INVALID_BLOCK_SIG:
assert invalid_signatures_blocks == [block.number]
else:
......@@ -159,6 +153,6 @@ def test_display_result(from_block, to_block, invalid_blocks_signatures, capsys)
expected += " ".join(str(n) for n in invalid_blocks_signatures)
else:
expected += "no blocks with a wrong signature."
display_result(from_block, to_block, invalid_blocks_signatures)
verify.display_result(from_block, to_block, invalid_blocks_signatures)
captured = capsys.readouterr()
assert expected + "\n" == captured.out
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment