From d8d80ad31ba92b30ee5439a69cb7361374815443 Mon Sep 17 00:00:00 2001
From: matograine <tom.ngr@zaclys.net>
Date: Thu, 11 Mar 2021 11:20:37 +0100
Subject: [PATCH] [mod] add PUBKEY_MIN_LENGTH and PUBKEY_MAX_LENGTH constants

---
 silkaj/constants.py |  4 +++-
 tests/test_tx.py    | 13 +++++++++++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/silkaj/constants.py b/silkaj/constants.py
index da154546..6eeba4fc 100644
--- a/silkaj/constants.py
+++ b/silkaj/constants.py
@@ -26,7 +26,9 @@ SOURCES_PER_TX = 40
 SUCCESS_EXIT_STATUS = 0
 FAILURE_EXIT_STATUS = 1
 BMA_MAX_BLOCKS_CHUNK_SIZE = 5000
-PUBKEY_PATTERN = "[1-9A-HJ-NP-Za-km-z]{43,44}"
+PUBKEY_MIN_LENGTH = 43
+PUBKEY_MAX_LENGTH = 44
+PUBKEY_PATTERN = f"[1-9A-HJ-NP-Za-km-z]{{{PUBKEY_MIN_LENGTH},{PUBKEY_MAX_LENGTH}}}"
 MINIMAL_ABSOLUTE_TX_AMOUNT = 0.01
 MINIMAL_RELATIVE_TX_AMOUNT = 1e-6
 CENT_MULT_TO_UNIT = 100
diff --git a/tests/test_tx.py b/tests/test_tx.py
index d6caf2de..8d6c03c3 100644
--- a/tests/test_tx.py
+++ b/tests/test_tx.py
@@ -28,6 +28,7 @@ from silkaj.constants import (
     MINIMAL_RELATIVE_TX_AMOUNT,
     FAILURE_EXIT_STATUS,
     CENT_MULT_TO_UNIT,
+    PUBKEY_MIN_LENGTH,
 )
 
 from patched.money import patched_ud_value, patched_get_sources
@@ -217,8 +218,16 @@ def test_tx_passed_amount_cli():
 @pytest.mark.parametrize(
     "arguments, auth_method, is_account_filled",
     [
-        (["tx", "--allSources", "-r", "A" * 43], patched_auth_method_truc, False),
-        (["tx", "--allSources", "-r", "A" * 43], patched_auth_method_riri, True),
+        (
+            ["tx", "--allSources", "-r", "A" * PUBKEY_MIN_LENGTH],
+            patched_auth_method_truc,
+            False,
+        ),
+        (
+            ["tx", "--allSources", "-r", "A" * PUBKEY_MIN_LENGTH],
+            patched_auth_method_riri,
+            True,
+        ),
     ],
 )
 def test_tx_passed_all_sources_empty(
-- 
GitLab