Repository: Naruno/Naruno (language: python)

Issue:
transactions: Adding logging to PendingtoValidating function



Discussion / hints:

Fix patch:
diff --git a/decentra_network/transactions/pending_to_validating.py b/decentra_network/transactions/pending_to_validating.py
index 186db466..b3204058 100644
--- a/decentra_network/transactions/pending_to_validating.py
+++ b/decentra_network/transactions/pending_to_validating.py
@@ -4,21 +4,35 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at https://mozilla.org/MPL/2.0/.
+from decentra_network.lib.log import get_logger
 from decentra_network.transactions.pending.delete_pending import DeletePending
 from decentra_network.transactions.pending.get_pending import GetPending
 
+logger = get_logger("TRANSACTIONS")
+
 
 def PendingtoValidating(block):
     """
     Adds transactions to the verification list
     if there are suitable conditions.
     """
-
+    logger.info("Pending to validating transfer process is started")
+    first_validating_list_len = len(block.validating_list)
+    first_max_tx_number = block.max_tx_number
+    logger.debug(f"Currently tx amount: {first_validating_list_len}")
+    logger.debug(f"Validating list capacity: {first_max_tx_number}")
     if len(block.validating_list) < block.max_tx_number:
         for tx in OrderbyFee(GetPending()):
             if len(block.validating_list) < block.max_tx_number:
+                logger.info(f"tx {tx.signature} is moved to validating list")
+
                 block.validating_list.append(tx)
                 DeletePending(tx)
+            else:
+                logger.info(
+                    f"TX {tx.signature} is can not moved to validating list")
+    else:
+        logger.info("List is full")
 
 
 def OrderbyFee(transactions: list):


Test patch:
diff --git a/tests/unit_tests/test_transactions.py b/tests/unit_tests/test_transactions.py
index ff5c3700..0116d42f 100644
--- a/tests/unit_tests/test_transactions.py
+++ b/tests/unit_tests/test_transactions.py
@@ -380,6 +380,39 @@ def test_pending_to_validating(self):
         self.assertEqual(transaction_1_true, False)
         self.assertEqual(transaction_2_true, False)
 
+    def test_pending_to_validating_full_list(self):
+
+        block = Block("")
+        block.validating_list = [
+            Transaction(1, "717", "", "", "", 1, 1, 1),
+            Transaction(1, "7b7", "", "", "", 1, 1, 1),
+        ]
+        block.max_tx_number = 2
+
+        temp_transaction = Transaction(1, "77", "", "", "", 1, 1, 1)
+        temp_transaction_2 = Transaction(1, "88", "", "", "", 1, 1, 1)
+
+        SavePending(temp_transaction)
+        SavePending(temp_transaction_2)
+
+        PendingtoValidating(block)
+
+        pending_transactions = GetPending()
+
+        transaction_1_true = any(
+            element.signature == temp_transaction.signature
+            for element in pending_transactions)
+        transaction_2_true = any(
+            element.signature == temp_transaction_2.signature
+            for element in pending_transactions)
+
+        DeletePending(temp_transaction)
+        DeletePending(temp_transaction_2)
+
+        self.assertEqual(len(block.validating_list), 2)
+        self.assertEqual(transaction_1_true, True)
+        self.assertEqual(transaction_2_true, True)
+
     def test_change_transaction_fee_increasing(self):
 
         block = Block("")