Repository: Naruno/Naruno (language: python)

Issue:
tests: Adding unit test for true_time function



Discussion / hints:

Fix patch:
diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml
index ca6af7d9..3a9e2d08 100644
--- a/.github/workflows/builds.yml
+++ b/.github/workflows/builds.yml
@@ -27,7 +27,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml
index 8ffa5fcc..acdc56e2 100644
--- a/.github/workflows/codecov.yml
+++ b/.github/workflows/codecov.yml
@@ -22,7 +22,7 @@ on:
       - 'tests/**'
       - 'auto_builders/**'      
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
   run:
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 4e5b4a75..5a534fa9 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -32,7 +32,7 @@ on:
     - cron: '22 14 * * 5'
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
   analyze:
diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml
index 176b1aea..e7c705de 100644
--- a/.github/workflows/dependency-review.yml
+++ b/.github/workflows/dependency-review.yml
@@ -17,7 +17,7 @@ permissions:
   contents: read
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
   dependency-review:
diff --git a/.github/workflows/deploys.yml b/.github/workflows/deploys.yml
index d3e93ff2..a4750c23 100644
--- a/.github/workflows/deploys.yml
+++ b/.github/workflows/deploys.yml
@@ -5,7 +5,7 @@ on:
     types: [published]
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
   deploy-pypi:
diff --git a/.github/workflows/devskim.yml b/.github/workflows/devskim.yml
index b797e30e..e180a3ec 100644
--- a/.github/workflows/devskim.yml
+++ b/.github/workflows/devskim.yml
@@ -26,7 +26,7 @@ on:
     - cron: '43 6 * * 1'
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
   lint:
diff --git a/.github/workflows/gource.yml b/.github/workflows/gource.yml
index 5a5ddaa8..b53e3447 100644
--- a/.github/workflows/gource.yml
+++ b/.github/workflows/gource.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
   gource:
diff --git a/.github/workflows/labeler_pull_requests.yml b/.github/workflows/labeler_pull_requests.yml
index bf76bf8e..c6afad63 100644
--- a/.github/workflows/labeler_pull_requests.yml
+++ b/.github/workflows/labeler_pull_requests.yml
@@ -4,7 +4,7 @@ on:
     types: [opened, edited]
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/ossar.yml b/.github/workflows/ossar.yml
index 004e1906..b6f00b10 100644
--- a/.github/workflows/ossar.yml
+++ b/.github/workflows/ossar.yml
@@ -32,7 +32,7 @@ permissions:
   contents: read
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
   OSSAR-Scan:
diff --git a/decentra_network/consensus/finished/finished_main.py b/decentra_network/consensus/finished/finished_main.py
index b94e9492..000f9339 100644
--- a/decentra_network/consensus/finished/finished_main.py
+++ b/decentra_network/consensus/finished/finished_main.py
@@ -13,7 +13,7 @@
     SaveBlockstoBlockchainDB
 from decentra_network.consensus.finished.transactions.transactions_main import \
     transactions_main
-from decentra_network.consensus.time.true_time.true_time import true_time
+from decentra_network.consensus.time.true_time.true_time_main import true_time
 from decentra_network.lib.log import get_logger
 from decentra_network.transactions.pending_to_validating import \
     PendingtoValidating
diff --git a/decentra_network/consensus/time/true_time/true_time.py b/decentra_network/consensus/time/true_time/true_time_main.py
similarity index 100%
rename from decentra_network/consensus/time/true_time/true_time.py
rename to decentra_network/consensus/time/true_time/true_time_main.py


Test patch:
diff --git a/.github/workflows/docker_stability_test_10_3.yml b/.github/workflows/docker_stability_test_10_3.yml
index 428dad46..8e351d85 100644
--- a/.github/workflows/docker_stability_test_10_3.yml
+++ b/.github/workflows/docker_stability_test_10_3.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/docker_stability_test_3_1.yml b/.github/workflows/docker_stability_test_3_1.yml
index 77e838a7..2fd50a09 100644
--- a/.github/workflows/docker_stability_test_3_1.yml
+++ b/.github/workflows/docker_stability_test_3_1.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/docker_stability_test_4_1.yml b/.github/workflows/docker_stability_test_4_1.yml
index 3e31e377..c97d2815 100644
--- a/.github/workflows/docker_stability_test_4_1.yml
+++ b/.github/workflows/docker_stability_test_4_1.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/docker_stability_test_5_1.yml b/.github/workflows/docker_stability_test_5_1.yml
index 2845513f..436c3534 100644
--- a/.github/workflows/docker_stability_test_5_1.yml
+++ b/.github/workflows/docker_stability_test_5_1.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/docker_stability_test_5_2.yml b/.github/workflows/docker_stability_test_5_2.yml
index 6eb6bc92..d1466d53 100644
--- a/.github/workflows/docker_stability_test_5_2.yml
+++ b/.github/workflows/docker_stability_test_5_2.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/docker_stability_test_6_1.yml b/.github/workflows/docker_stability_test_6_1.yml
index 2162c3b6..5a75d69e 100644
--- a/.github/workflows/docker_stability_test_6_1.yml
+++ b/.github/workflows/docker_stability_test_6_1.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/docker_stability_test_6_2.yml b/.github/workflows/docker_stability_test_6_2.yml
index a57fb13c..496d7ef3 100644
--- a/.github/workflows/docker_stability_test_6_2.yml
+++ b/.github/workflows/docker_stability_test_6_2.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/docker_stability_test_7_1.yml b/.github/workflows/docker_stability_test_7_1.yml
index af12bd0d..d44f0dc2 100644
--- a/.github/workflows/docker_stability_test_7_1.yml
+++ b/.github/workflows/docker_stability_test_7_1.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/docker_stability_test_7_2.yml b/.github/workflows/docker_stability_test_7_2.yml
index cad764e2..b27b86b5 100644
--- a/.github/workflows/docker_stability_test_7_2.yml
+++ b/.github/workflows/docker_stability_test_7_2.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/local_stability_test_10_3.yml b/.github/workflows/local_stability_test_10_3.yml
index f84095d2..16de25e0 100644
--- a/.github/workflows/local_stability_test_10_3.yml
+++ b/.github/workflows/local_stability_test_10_3.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/local_stability_test_3_1.yml b/.github/workflows/local_stability_test_3_1.yml
index 18ddbaf2..724de70c 100644
--- a/.github/workflows/local_stability_test_3_1.yml
+++ b/.github/workflows/local_stability_test_3_1.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/local_stability_test_4_1.yml b/.github/workflows/local_stability_test_4_1.yml
index 7fd42a99..075d58f4 100644
--- a/.github/workflows/local_stability_test_4_1.yml
+++ b/.github/workflows/local_stability_test_4_1.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/local_stability_test_5_1.yml b/.github/workflows/local_stability_test_5_1.yml
index 31f73006..39fb21c0 100644
--- a/.github/workflows/local_stability_test_5_1.yml
+++ b/.github/workflows/local_stability_test_5_1.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/local_stability_test_5_2.yml b/.github/workflows/local_stability_test_5_2.yml
index 06dada7e..4da62cc7 100644
--- a/.github/workflows/local_stability_test_5_2.yml
+++ b/.github/workflows/local_stability_test_5_2.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/local_stability_test_6_1.yml b/.github/workflows/local_stability_test_6_1.yml
index 3662600b..0cb6df18 100644
--- a/.github/workflows/local_stability_test_6_1.yml
+++ b/.github/workflows/local_stability_test_6_1.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/local_stability_test_6_2.yml b/.github/workflows/local_stability_test_6_2.yml
index 8d389bc0..bba0a2dc 100644
--- a/.github/workflows/local_stability_test_6_2.yml
+++ b/.github/workflows/local_stability_test_6_2.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/local_stability_test_7_1.yml b/.github/workflows/local_stability_test_7_1.yml
index 9362b70f..d00cac04 100644
--- a/.github/workflows/local_stability_test_7_1.yml
+++ b/.github/workflows/local_stability_test_7_1.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/local_stability_test_7_2.yml b/.github/workflows/local_stability_test_7_2.yml
index 97b3bcd7..277a65f2 100644
--- a/.github/workflows/local_stability_test_7_2.yml
+++ b/.github/workflows/local_stability_test_7_2.yml
@@ -6,7 +6,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
 
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 3cb9fe88..a821c213 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -24,7 +24,7 @@ on:
   workflow_dispatch:
 
 concurrency: 
-  group: ${{ github.ref }}
+  group: ${{ github.workflow }}-${{ github.ref }}
   cancel-in-progress: true
 jobs:
   lint_with_flake8:
diff --git a/tests/unit_tests/test_consensus.py b/tests/unit_tests/test_consensus.py
new file mode 100644
index 00000000..d2ae33cd
--- /dev/null
+++ b/tests/unit_tests/test_consensus.py
@@ -0,0 +1,49 @@
+#!/usr/bin/python3
+# -*- coding: utf-8 -*-
+#
+# 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/.
+import os
+import sys
+
+sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
+import time
+import unittest
+
+from decentra_network.blockchain.block.block_main import Block
+from decentra_network.consensus.time.true_time.true_time_main import true_time
+from decentra_network.lib.clean_up import CleanUp_tests
+
+
+class Test_Consensus(unittest.TestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        CleanUp_tests()
+
+    @classmethod
+    def tearDownClass(cls):
+        CleanUp_tests()
+
+    def test_true_time_false(self):
+        block = Block("Onur")
+
+        block.genesis_time = int(time.time())
+        block.block_time = 1
+        block.sequance_number = 0
+        block.empty_block_number = 100
+        self.assertFalse(true_time(block=block))
+
+    def test_true_time(self):
+        block = Block("Onur")
+
+        block.genesis_time = int(time.time())
+        block.block_time = 1
+        block.sequance_number = 0
+        block.empty_block_number = 0
+        time.sleep(1)
+        self.assertTrue(true_time(block=block))
+
+
+unittest.main(exit=False)