diff --git a/silkaj/auth.py b/silkaj/auth.py index 74b16f83063d47d436a975d6983b7387583f251b..3b698978c18d090bfe4e54a5d22e39cba6afa0f9 100644 --- a/silkaj/auth.py +++ b/silkaj/auth.py @@ -16,17 +16,16 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import re -from click import command, option, pass_context, confirm from getpass import getpass from pathlib import Path +from click import command, confirm, option, pass_context from duniterpy.key import SigningKey from duniterpy.key.scrypt_params import ScryptParams -from silkaj.tui import display_pubkey_and_checksum -from silkaj.tools import message_exit from silkaj.constants import PUBKEY_PATTERN - +from silkaj.tools import message_exit +from silkaj.tui import display_pubkey_and_checksum SEED_HEX_PATTERN = "^[0-9a-fA-F]{64}$" PUBSEC_PUBKEY_PATTERN = "pub: ({0})".format(PUBKEY_PATTERN) diff --git a/silkaj/blockchain_tools.py b/silkaj/blockchain_tools.py index df6cc8b9101a2ad877db6c80d669e1785491326c..57d640c8e110b4f0d43d44d3523edb5fe8e65ab2 100644 --- a/silkaj/blockchain_tools.py +++ b/silkaj/blockchain_tools.py @@ -15,9 +15,10 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -from silkaj.network_tools import ClientInstance from duniterpy.api.bma import blockchain +from silkaj.network_tools import ClientInstance + class BlockchainParams(object): __instance = None diff --git a/silkaj/blocks.py b/silkaj/blocks.py index 5d978391ab9aabba36538591128a6371f6e7f9f7..b21bc2e3fc61348d2252748e1e63e3afc33856a9 100644 --- a/silkaj/blocks.py +++ b/silkaj/blocks.py @@ -17,18 +17,18 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. import logging from asyncio import sleep -from click import command, argument, INT, progressbar -from aiohttp.client_exceptions import ServerDisconnectedError +from aiohttp.client_exceptions import ServerDisconnectedError +from click import INT, argument, command, progressbar from duniterpy.api import bma from duniterpy.api.client import Client from duniterpy.api.errors import DuniterError from duniterpy.documents import Block from duniterpy.key.verifying_key import VerifyingKey -from silkaj.tools import message_exit, coroutine -from silkaj.network_tools import EndPoint from silkaj.constants import BMA_MAX_BLOCKS_CHUNK_SIZE +from silkaj.network_tools import EndPoint +from silkaj.tools import coroutine, message_exit @command( diff --git a/silkaj/cert.py b/silkaj/cert.py index a3f501a05340c19d87d2f188960757fefe03776f..483f089c15b00c60abbea6a77bfa1bc264447aa7 100644 --- a/silkaj/cert.py +++ b/silkaj/cert.py @@ -16,22 +16,22 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import sys + import click +from duniterpy.api import bma +from duniterpy.documents import BlockUID, Certification, Identity, block_uid from pendulum import from_timestamp, now - from tabulate import tabulate -from duniterpy.api import bma -from duniterpy.documents import BlockUID, block_uid, Identity, Certification +from silkaj import tui, wot +from silkaj import wot_tools as wt from silkaj.auth import auth_method -from silkaj.tools import message_exit, coroutine -from silkaj.network_tools import ClientInstance from silkaj.blockchain_tools import BlockchainParams, HeadBlock -from silkaj.license import license_approval -from silkaj import wot, tui -from silkaj.constants import SUCCESS_EXIT_STATUS, DATE, ALL +from silkaj.constants import ALL, DATE, SUCCESS_EXIT_STATUS from silkaj.crypto_tools import is_pubkey_and_check -from silkaj import wot_tools as wt +from silkaj.license import license_approval +from silkaj.network_tools import ClientInstance +from silkaj.tools import coroutine, message_exit @click.command("cert", help="Send certification") diff --git a/silkaj/checksum.py b/silkaj/checksum.py index 19c86dbfb8119133c87221629596fb3dbe2f3b88..4885e8c2b38d8c1fb14eed1ed47112e9fba3a366 100644 --- a/silkaj/checksum.py +++ b/silkaj/checksum.py @@ -16,18 +16,18 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import re + import click from silkaj.auth import auth_method, has_auth_method from silkaj.crypto_tools import ( - gen_checksum, - PUBKEY_DELIMITED_PATTERN, PUBKEY_CHECKSUM_PATTERN, + PUBKEY_DELIMITED_PATTERN, + gen_checksum, ) from silkaj.tools import message_exit from silkaj.tui import display_pubkey_and_checksum - MESSAGE = "You should specify a pubkey or an authentication method" diff --git a/silkaj/cli.py b/silkaj/cli.py index fb4c0c86058eebee1937e6b07033c9dfcae83699..94f5c02776eaec9baf432d2b073a3bcc95c29d9a 100644 --- a/silkaj/cli.py +++ b/silkaj/cli.py @@ -16,30 +16,25 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import sys -from click import group, help_option, version_option, option, pass_context -from silkaj.tx import send_transaction -from silkaj.tx_history import transaction_history -from silkaj.money import cmd_amount -from silkaj.cert import send_certification -from silkaj.checksum import checksum_command -from silkaj.commands import ( - currency_info, - difficulties, - argos_info, - list_blocks, -) +from click import group, help_option, option, pass_context, version_option -from silkaj.wot import received_sent_certifications, id_pubkey_correspondence from silkaj.auth import generate_auth_file -from silkaj.license import license_command -from silkaj.membership import send_membership from silkaj.blocks import verify_blocks_signatures +from silkaj.cert import send_certification +from silkaj.checksum import checksum_command +from silkaj.commands import argos_info, currency_info, difficulties, list_blocks from silkaj.constants import ( - SILKAJ_VERSION, G1_DEFAULT_ENDPOINT, G1_TEST_DEFAULT_ENDPOINT, + SILKAJ_VERSION, ) +from silkaj.license import license_command +from silkaj.membership import send_membership +from silkaj.money import cmd_amount +from silkaj.tx import send_transaction +from silkaj.tx_history import transaction_history +from silkaj.wot import id_pubkey_correspondence, received_sent_certifications @group() diff --git a/silkaj/commands.py b/silkaj/commands.py index 1508f3c492b37c754532eb3065945497d5905c45..5ddfda6875827129bb50e3ade2c2016be38b8c98 100644 --- a/silkaj/commands.py +++ b/silkaj/commands.py @@ -15,29 +15,24 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -import aiohttp -import jsonschema -from pendulum import from_timestamp -from click import command, option, argument, IntRange -from os import system +from asyncio import sleep from collections import OrderedDict -from tabulate import tabulate from operator import itemgetter -from asyncio import sleep -from _socket import gaierror +from os import system +import aiohttp +import jsonschema +from _socket import gaierror +from click import IntRange, argument, command, option from duniterpy.api import bma +from pendulum import from_timestamp +from tabulate import tabulate -from silkaj.tools import coroutine -from silkaj.wot_tools import identity_of -from silkaj.network_tools import ( - best_endpoint_address, - EndPoint, - ClientInstance, -) from silkaj.blockchain_tools import HeadBlock -from silkaj.tools import CurrencySymbol -from silkaj.constants import ASYNC_SLEEP, ALL, HOUR +from silkaj.constants import ALL, ASYNC_SLEEP, HOUR +from silkaj.network_tools import ClientInstance, EndPoint, best_endpoint_address +from silkaj.tools import CurrencySymbol, coroutine +from silkaj.wot_tools import identity_of @command("info", help="Display information about currency") diff --git a/silkaj/crypto_tools.py b/silkaj/crypto_tools.py index 0a03375daa29872625b2627bd8238613fc947409..b7e846420ce2b1c64013944a2c2a2f2930404371 100644 --- a/silkaj/crypto_tools.py +++ b/silkaj/crypto_tools.py @@ -15,8 +15,8 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -import re import hashlib +import re import base58 diff --git a/silkaj/license.py b/silkaj/license.py index bdd6f89190335a819c559c5df8a21f20134f78ed..939a485fbebed1b3aa89da3d4957e4439b6af525 100644 --- a/silkaj/license.py +++ b/silkaj/license.py @@ -16,7 +16,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import webbrowser -from click import command, echo_via_pager, confirm + +from click import command, confirm, echo_via_pager def license_approval(currency): diff --git a/silkaj/membership.py b/silkaj/membership.py index da81a4fae614f8bdf7d27cbf90186da01fdb45e7..9a5a3ca27f1939edb1d617c3defed70b629998df 100644 --- a/silkaj/membership.py +++ b/silkaj/membership.py @@ -15,22 +15,21 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -import sys import logging +import sys -import pendulum import click -from tabulate import tabulate - +import pendulum from duniterpy.api import bma -from duniterpy.documents import BlockUID, block_uid, Membership +from duniterpy.documents import BlockUID, Membership, block_uid +from tabulate import tabulate -from silkaj import auth, wot, tui -from silkaj.tools import coroutine -from silkaj.network_tools import ClientInstance +from silkaj import auth, tui, wot from silkaj.blockchain_tools import BlockchainParams, HeadBlock +from silkaj.constants import DATE, SUCCESS_EXIT_STATUS from silkaj.license import license_approval -from silkaj.constants import SUCCESS_EXIT_STATUS, DATE +from silkaj.network_tools import ClientInstance +from silkaj.tools import coroutine @click.command( diff --git a/silkaj/money.py b/silkaj/money.py index a4596771dba4bff0104c42c63f7bba5720dfc9cf..33aed211008e946b54cee02b0b4ccccd5e7bc6e8 100644 --- a/silkaj/money.py +++ b/silkaj/money.py @@ -15,24 +15,23 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -from click import command, argument, pass_context, echo +from click import argument, command, echo, pass_context +from duniterpy.api.bma import blockchain, tx +from duniterpy.documents.transaction import InputSource from tabulate import tabulate from silkaj import wot_tools as wt -from silkaj.network_tools import ClientInstance -from silkaj.blockchain_tools import HeadBlock -from silkaj.tools import CurrencySymbol, message_exit, coroutine from silkaj.auth import auth_method, has_auth_method +from silkaj.blockchain_tools import HeadBlock from silkaj.crypto_tools import ( - is_pubkey_and_check, check_pubkey_format, + is_pubkey_and_check, validate_checksum, ) +from silkaj.network_tools import ClientInstance +from silkaj.tools import CurrencySymbol, coroutine, message_exit from silkaj.tui import display_amount, display_pubkey_and_checksum -from duniterpy.api.bma import tx, blockchain -from duniterpy.documents.transaction import InputSource - @command("balance", help="Get wallet balance") @argument("pubkeys", nargs=-1) diff --git a/silkaj/network_tools.py b/silkaj/network_tools.py index e3687547337c8b452fe10118726d7c13bbe33712..3e67b8f7d682b7e03ba6a9b5e4fda6efc46e1152 100644 --- a/silkaj/network_tools.py +++ b/silkaj/network_tools.py @@ -15,18 +15,19 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ +import logging import re import socket -import logging from sys import exit, stderr + from duniterpy.api.client import Client from duniterpy.constants import IPV4_REGEX, IPV6_REGEX from silkaj.constants import ( - G1_DEFAULT_ENDPOINT, - G1_TEST_DEFAULT_ENDPOINT, CONNECTION_TIMEOUT, FAILURE_EXIT_STATUS, + G1_DEFAULT_ENDPOINT, + G1_TEST_DEFAULT_ENDPOINT, ) diff --git a/silkaj/tools.py b/silkaj/tools.py index 53d14be9bac4a06aab7c8ff79fd99b2885ed74b6..b4a10af9dd153bfda37805a381196507a68dc2bc 100644 --- a/silkaj/tools.py +++ b/silkaj/tools.py @@ -15,12 +15,12 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -from sys import exit from asyncio import get_event_loop from functools import update_wrapper +from sys import exit -from silkaj.constants import G1_SYMBOL, GTEST_SYMBOL, FAILURE_EXIT_STATUS from silkaj.blockchain_tools import BlockchainParams +from silkaj.constants import FAILURE_EXIT_STATUS, G1_SYMBOL, GTEST_SYMBOL class CurrencySymbol(object): diff --git a/silkaj/tui.py b/silkaj/tui.py index 87463bd2c0fc51888de8dc3ef2d64a41e9b759cd..b61e390f59aebe6c191d1a08e2ee1f9e50921ce4 100644 --- a/silkaj/tui.py +++ b/silkaj/tui.py @@ -16,11 +16,13 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import sys -import click from datetime import datetime -from silkaj import network_tools, constants, wot_tools +import click + +from silkaj import constants from silkaj import crypto_tools as ct +from silkaj import network_tools, wot_tools def display_amount(tx, message, amount, ud_value, currency_symbol): diff --git a/silkaj/tx.py b/silkaj/tx.py index 1dae94a27098b3d61c1066e1eaf64fcd0cb50e7a..2e6fea41a298bbe14b6ace1bfaa186d2996c6f7f 100644 --- a/silkaj/tx.py +++ b/silkaj/tx.py @@ -15,31 +15,30 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -from re import compile, search import math from asyncio import sleep -from tabulate import tabulate +from re import compile, search + import click +from duniterpy.api.bma.tx import process +from duniterpy.documents import BlockUID, Transaction +from duniterpy.documents.transaction import OutputSource, SIGParameter, Unlock +from tabulate import tabulate +from silkaj import auth +from silkaj import blockchain_tools as bt from silkaj import cli_tools -from silkaj import network_tools as nt from silkaj import crypto_tools as ct -from silkaj import blockchain_tools as bt -from silkaj import tools -from silkaj import auth from silkaj import money -from silkaj import tui +from silkaj import network_tools as nt +from silkaj import tools, tui from silkaj.constants import ( + ASYNC_SLEEP, + CENT_MULT_TO_UNIT, MINIMAL_ABSOLUTE_TX_AMOUNT, MINIMAL_RELATIVE_TX_AMOUNT, - CENT_MULT_TO_UNIT, - ASYNC_SLEEP, ) -from duniterpy.api.bma.tx import process -from duniterpy.documents import BlockUID, Transaction -from duniterpy.documents.transaction import OutputSource, Unlock, SIGParameter - MAX_COMMENT_LENGTH = 255 diff --git a/silkaj/tx_history.py b/silkaj/tx_history.py index 1b4a90edd13a8acfd3155257b60e19dd20c95e10..c7de2ce44a1d96a931e9548c45692980d1199568 100644 --- a/silkaj/tx_history.py +++ b/silkaj/tx_history.py @@ -15,23 +15,22 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -from pendulum import from_timestamp, now -from click import command, argument, option, echo_via_pager, get_terminal_size -from texttable import Texttable -from operator import itemgetter, neg, eq, ne +from operator import eq, itemgetter, ne, neg +from click import argument, command, echo_via_pager, get_terminal_size, option from duniterpy.api.bma.tx import history from duniterpy.documents.transaction import Transaction +from pendulum import from_timestamp, now +from texttable import Texttable +from silkaj import wot from silkaj import wot_tools as wt +from silkaj.constants import ALL, ALL_DIGITAL +from silkaj.crypto_tools import check_pubkey_format, validate_checksum +from silkaj.money import UDValue, amount_in_current_base, get_amount_from_pubkey from silkaj.network_tools import ClientInstance -from silkaj.tools import coroutine +from silkaj.tools import CurrencySymbol, coroutine from silkaj.tui import display_pubkey_and_checksum -from silkaj.crypto_tools import validate_checksum, check_pubkey_format -from silkaj import wot -from silkaj.money import get_amount_from_pubkey, amount_in_current_base, UDValue -from silkaj.tools import CurrencySymbol -from silkaj.constants import ALL, ALL_DIGITAL @command("history", help="Display transaction history") diff --git a/silkaj/wot.py b/silkaj/wot.py index fd7610d9e9c5aa73d6ce89b036fec8d17282f382..9d8cf096fa6cfbea0ae6ea523e0c37096ea2b724 100644 --- a/silkaj/wot.py +++ b/silkaj/wot.py @@ -15,20 +15,21 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ +from collections import OrderedDict + import click +from duniterpy.api.bma import blockchain, wot +from duniterpy.api.errors import DuniterError from pendulum import from_timestamp, now from tabulate import tabulate -from collections import OrderedDict -from duniterpy.api.bma import wot, blockchain -from duniterpy.api.errors import DuniterError from silkaj import wot_tools as wt -from silkaj.network_tools import ClientInstance +from silkaj.blockchain_tools import BlockchainParams +from silkaj.constants import DATE from silkaj.crypto_tools import is_pubkey_and_check +from silkaj.network_tools import ClientInstance from silkaj.tools import coroutine from silkaj.tui import display_pubkey_and_checksum -from silkaj.blockchain_tools import BlockchainParams -from silkaj.constants import DATE def get_sent_certifications(signed, time_first_block, params): diff --git a/silkaj/wot_tools.py b/silkaj/wot_tools.py index 829b105fb3cfc7ca548a00eb6ceeeb3c39ee00c9..061765755c230fe1746e9480aa2654b1e36d4693 100644 --- a/silkaj/wot_tools.py +++ b/silkaj/wot_tools.py @@ -16,12 +16,13 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ from asyncio import sleep + from duniterpy.api.bma import wot from duniterpy.api.errors import DuniterError +from silkaj.constants import ASYNC_SLEEP from silkaj.network_tools import ClientInstance from silkaj.tools import message_exit -from silkaj.constants import ASYNC_SLEEP async def identity_of(pubkey_uid): diff --git a/tests/patched/money.py b/tests/patched/money.py index ff82f0ec2345efd8ba3c1bcd1158dd12fb183848..5bdc1f132306a92d6b0a11b52e5b072113119ca9 100644 --- a/tests/patched/money.py +++ b/tests/patched/money.py @@ -17,11 +17,12 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. # This file contains patched functions for testing purposes. +from duniterpy.documents.transaction import InputSource + +from patched.test_constants import mock_ud_value from silkaj.constants import G1_SYMBOL from silkaj.money import amount_in_current_base from silkaj.tx import MAX_INPUTS_PER_TX -from duniterpy.documents.transaction import InputSource -from patched.test_constants import mock_ud_value async def patched_ud_value(self): diff --git a/tests/patched/tools.py b/tests/patched/tools.py index 4128f88a3634c76e9ba5faafdc7f46e5a98cf0db..2b6bf706752b2f4ff7fd601e2972d2e6db2972ed 100644 --- a/tests/patched/tools.py +++ b/tests/patched/tools.py @@ -17,6 +17,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. from silkaj.constants import G1_SYMBOL + # mock CurrencySymbol().symbol async def patched_currency_symbol(self): return G1_SYMBOL diff --git a/tests/patched/tx.py b/tests/patched/tx.py index 631c2ff848984a026f8c674400c5f7a74fda425e..949aed89a9edc1a71e13ebdda6c4995073290053 100644 --- a/tests/patched/tx.py +++ b/tests/patched/tx.py @@ -16,6 +16,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ from duniterpy.key import SigningKey + from silkaj.tools import message_exit diff --git a/tests/patched/tx_history.py b/tests/patched/tx_history.py index bc325de1a6d5273959c654678b81c1c981b270ea..ee475904e986cad2781fc7f83ae7dcee5353c5a0 100644 --- a/tests/patched/tx_history.py +++ b/tests/patched/tx_history.py @@ -17,8 +17,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. from duniterpy.documents.transaction import Transaction -from patched.wot import pubkey_list from patched.blockchain_tools import currency +from patched.wot import pubkey_list fake_received_tx_hist = [ { diff --git a/tests/test_auth.py b/tests/test_auth.py index a238ee6d8a1deb32a7c8211f3604fae47312da7e..39b52412d2b1dbdfaa19d629a5eb346898ca907d 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -1,14 +1,14 @@ -import pytest import click - -from silkaj import auth +import pytest from patched.auth import ( - patched_auth_by_seed, - patched_auth_by_wif, patched_auth_by_auth_file, patched_auth_by_scrypt, + patched_auth_by_seed, + patched_auth_by_wif, ) +from silkaj import auth + # test auth_method @pytest.mark.parametrize( diff --git a/tests/test_checksum.py b/tests/test_checksum.py index 2a38cfd97944fee708b89dd5bde0904c2eb24c98..decb83590ae92ed6105af715b1d3f83a6129e570 100644 --- a/tests/test_checksum.py +++ b/tests/test_checksum.py @@ -18,9 +18,8 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. import pytest from click.testing import CliRunner -from silkaj.cli import cli from silkaj.checksum import MESSAGE - +from silkaj.cli import cli pubkey = "3rp7ahDGeXqffBQTnENiXEFXYS7BRjYmS33NbgfCuDc8" checksum = "DFQ" diff --git a/tests/test_crypto_tools.py b/tests/test_crypto_tools.py index 10c247210011d78c929799da30d69170fd91474d..e9eaa13a069546bb0b4065699af3e21b2052f83e 100644 --- a/tests/test_crypto_tools.py +++ b/tests/test_crypto_tools.py @@ -19,6 +19,7 @@ import pytest from silkaj import crypto_tools + # test gen_checksum @pytest.mark.parametrize( "pubkey, checksum", diff --git a/tests/test_membership.py b/tests/test_membership.py index c763ffb78965ae622dc32d3db245788cb3e65fca..08250e71747e0302cccc8873a3088d1740c139bb 100644 --- a/tests/test_membership.py +++ b/tests/test_membership.py @@ -17,38 +17,31 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. import sys from unittest.mock import Mock -import pytest -from click.testing import CliRunner -from tabulate import tabulate import pendulum - -from duniterpy.documents import Membership, block_uid +import pytest +from click.testing import CliRunner from duniterpy.api import bma +from duniterpy.documents import Membership, block_uid from duniterpy.key import SigningKey +from tabulate import tabulate from patched.blockchain_tools import ( currency, - patched_params, + fake_block_uid, patched_block, patched_head_block, - fake_block_uid, + patched_params, ) from patched.wot import ( - patched_wot_requirements_one_pending, patched_wot_requirements_no_pending, + patched_wot_requirements_one_pending, ) - -from silkaj import auth, wot +from silkaj import auth, membership, wot +from silkaj.blockchain_tools import BlockchainParams, HeadBlock from silkaj.cli import cli +from silkaj.constants import DATE, FAILURE_EXIT_STATUS, SUCCESS_EXIT_STATUS from silkaj.network_tools import ClientInstance -from silkaj import membership -from silkaj.blockchain_tools import BlockchainParams, HeadBlock -from silkaj.constants import ( - SUCCESS_EXIT_STATUS, - FAILURE_EXIT_STATUS, - DATE, -) from silkaj.tui import display_pubkey_and_checksum # AsyncMock available from Python 3.8. asynctest is used for Py < 3.8 diff --git a/tests/test_money.py b/tests/test_money.py index eaaa746789681fce1612e09ea5c89d81783ac6ff..a179e749a632b44cddffc682ae8ce480f07b0b06 100644 --- a/tests/test_money.py +++ b/tests/test_money.py @@ -15,17 +15,17 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ +import duniterpy.api.bma.tx as bma_tx import pytest from click.testing import CliRunner -import duniterpy.api.bma.tx as bma_tx - -# had to import from wot to prevent loop dependencies -from silkaj.wot import display_pubkey_and_checksum from silkaj.cli import cli from silkaj.constants import FAILURE_EXIT_STATUS from silkaj.money import get_sources +# had to import from wot to prevent loop dependencies +from silkaj.wot import display_pubkey_and_checksum + @pytest.mark.asyncio async def test_get_sources(monkeypatch): diff --git a/tests/test_network_tools.py b/tests/test_network_tools.py index 2f3b9744f950e7f7190d2fa6d9bd0d098b0aa2ff..127a97d89a949ad9de29c35a95f7d1c3efd4b447 100644 --- a/tests/test_network_tools.py +++ b/tests/test_network_tools.py @@ -16,6 +16,7 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import pytest + from silkaj import network_tools diff --git a/tests/test_tui.py b/tests/test_tui.py index 3fd413d132c2cad988246eeb61a170fad52103d7..6de018c6c5adde20390e28d0fd731b36c3cddc62 100644 --- a/tests/test_tui.py +++ b/tests/test_tui.py @@ -16,12 +16,13 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import pytest -from silkaj.tui import display_pubkey, display_amount, display_pubkey_and_checksum -from silkaj.constants import G1_SYMBOL, SHORT_PUBKEY_SIZE -from silkaj import wot_tools -from patched.wot import patched_is_member from patched.test_constants import mock_ud_value +from patched.wot import patched_is_member +from silkaj import wot_tools +from silkaj.constants import G1_SYMBOL, SHORT_PUBKEY_SIZE +from silkaj.tui import display_amount, display_pubkey, display_pubkey_and_checksum + # display_amount() @pytest.mark.parametrize( diff --git a/tests/test_tx.py b/tests/test_tx.py index c6b1909b0c4dd4d1520cc39d89b52aa899de1b0a..92ab426f5c60583d93873678465f182f08525d00 100644 --- a/tests/test_tx.py +++ b/tests/test_tx.py @@ -16,25 +16,25 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import sys + import pytest -from click.testing import CliRunner from click import pass_context +from click.testing import CliRunner -from silkaj import tx, auth, money +from patched.auth import patched_auth_method +from patched.money import patched_get_sources, patched_ud_value +from patched.test_constants import mock_ud_value +from patched.tx import patched_gen_confirmation_table +from silkaj import auth, money, tx from silkaj.cli import cli from silkaj.constants import ( + CENT_MULT_TO_UNIT, + FAILURE_EXIT_STATUS, MINIMAL_ABSOLUTE_TX_AMOUNT, MINIMAL_RELATIVE_TX_AMOUNT, - FAILURE_EXIT_STATUS, - CENT_MULT_TO_UNIT, PUBKEY_MIN_LENGTH, ) -from patched.money import patched_ud_value, patched_get_sources -from patched.test_constants import mock_ud_value -from patched.auth import patched_auth_method -from patched.tx import patched_gen_confirmation_table - # AsyncMock available from Python 3.8. asynctest is used for Py < 3.8 if sys.version_info[1] > 7: from unittest.mock import AsyncMock diff --git a/tests/test_tx_history.py b/tests/test_tx_history.py index ace734042b788421cbb0f7a1dd243f8dac66dd91..38f4e7c829dd1a18f05d79809b3745ec8c13bd2a 100644 --- a/tests/test_tx_history.py +++ b/tests/test_tx_history.py @@ -16,19 +16,18 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import pytest +from patched.blockchain_tools import currency +from patched.tx_history import patched_get_transactions_history +from patched.wot import patched_identities_from_pubkeys from silkaj import tx_history, wot, wot_tools from silkaj.constants import ( G1_DEFAULT_ENDPOINT, - SHORT_PUBKEY_SIZE, - PUBKEY_MIN_LENGTH, PUBKEY_MAX_LENGTH, + PUBKEY_MIN_LENGTH, + SHORT_PUBKEY_SIZE, ) from silkaj.crypto_tools import CHECKSUM_SIZE -from patched.tx_history import patched_get_transactions_history -from patched.wot import patched_identities_from_pubkeys -from patched.blockchain_tools import currency - SHORT_PUBKEY_LENGTH_WITH_CHECKSUM = ( SHORT_PUBKEY_SIZE + CHECKSUM_SIZE + 2 ) # 2 chars "…:" ==> 8 + 3 + 2 = 13 diff --git a/tests/test_unit_cert.py b/tests/test_unit_cert.py index fa09d3683a7023a4baeb1f162bfe18c23b45449a..7b96e03bf4631ef156bfb2334b3976b110614707 100644 --- a/tests/test_unit_cert.py +++ b/tests/test_unit_cert.py @@ -19,7 +19,6 @@ from unittest.mock import patch from silkaj.cert import certification_confirmation - # @patch('builtins.input') # def test_certification_confirmation(mock_input): # id_to_certify = {"pubkey": "pubkeyid to certify"} diff --git a/tests/test_unit_tx.py b/tests/test_unit_tx.py index 62fc092c722e053c2e2b974be884759d036a73fe..a1ac49237a3de4a95662f43b583ededa4656f38a 100644 --- a/tests/test_unit_tx.py +++ b/tests/test_unit_tx.py @@ -16,47 +16,41 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ import sys -import pytest -from silkaj import ( - tx, - wot, - wot_tools, - money, - tools, - blockchain_tools, - auth, - network_tools, -) -from silkaj.tui import display_pubkey, display_amount -from silkaj.constants import ( - G1_SYMBOL, - CENT_MULT_TO_UNIT, - MINIMAL_ABSOLUTE_TX_AMOUNT, -) -from silkaj.cli import cli - -from click.testing import CliRunner +import pytest from click import pass_context - +from click.testing import CliRunner from duniterpy.documents.transaction import ( InputSource, - Transaction, OutputSource, - Unlock, SIGParameter, + Transaction, + Unlock, ) -from patched.wot import patched_is_member +from patched.auth import patched_auth_method +from patched.blockchain_tools import fake_block_uid, patched_head_block from patched.money import patched_get_sources, patched_ud_value from patched.test_constants import mock_ud_value from patched.tools import patched_currency_symbol -from patched.blockchain_tools import patched_head_block, fake_block_uid -from patched.auth import patched_auth_method from patched.tx import ( patched_gen_confirmation_table, patched_handle_intermediaries_transactions, ) +from patched.wot import patched_is_member +from silkaj import ( + auth, + blockchain_tools, + money, + network_tools, + tools, + tx, + wot, + wot_tools, +) +from silkaj.cli import cli +from silkaj.constants import CENT_MULT_TO_UNIT, G1_SYMBOL, MINIMAL_ABSOLUTE_TX_AMOUNT +from silkaj.tui import display_amount, display_pubkey # AsyncMock available from Python 3.8. asynctest is used for Py < 3.8 if sys.version_info[1] > 7: diff --git a/tests/test_verify_blocks.py b/tests/test_verify_blocks.py index 5a80474906836afe89aebdba610f8c0e5e32bdf6..9145cbbeec76242b7647670a79f6f534cd0d6a7c 100644 --- a/tests/test_verify_blocks.py +++ b/tests/test_verify_blocks.py @@ -17,26 +17,24 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>. import pytest from click.testing import CliRunner - -from duniterpy.documents import Block -from duniterpy.api.client import Client from duniterpy.api import bma +from duniterpy.api.client import Client +from duniterpy.documents import Block -from silkaj.network_tools import EndPoint from silkaj import cli from silkaj.blocks import ( check_passed_blocks_range, - get_chunk_size, + display_result, get_chunk, + get_chunk_size, verify_block_signature, - display_result, ) from silkaj.constants import ( - SUCCESS_EXIT_STATUS, - FAILURE_EXIT_STATUS, BMA_MAX_BLOCKS_CHUNK_SIZE, + FAILURE_EXIT_STATUS, + SUCCESS_EXIT_STATUS, ) - +from silkaj.network_tools import EndPoint G1_INVALID_BLOCK_SIG = 15144 HEAD_BLOCK = 48000 diff --git a/tests/test_wot.py b/tests/test_wot.py index 3b4299ed1b3d1893b53afa9f07bc9c9b7d9cd75d..70fca3f3dcbf7867780bc0e1795a0dd008df464a 100644 --- a/tests/test_wot.py +++ b/tests/test_wot.py @@ -15,11 +15,10 @@ You should have received a copy of the GNU Affero General Public License along with Silkaj. If not, see <https://www.gnu.org/licenses/>. """ -import pytest import click +import pytest -from silkaj import wot -from silkaj import wot_tools +from silkaj import wot, wot_tools pubkey_titi_tata = "B4RoF48cTxzmsQDB3UjodKdZ2cVymKSKzgiPVRoMeA88" pubkey_toto_tutu = "totoF48cTxzmsQDB3UjodKdZ2cVymKSKzgiPVRoMeA88"