Repository: 0xSpaceShard/starknet-devnet (language: python)

Issue:
Unification of test_general_workflow test
test_general_workflow need's to be parameterized


Discussion / hints:

Fix patch:
diff --git a/starknet_devnet/starknet_wrapper.py b/starknet_devnet/starknet_wrapper.py
index 637fe3f6f..44632ef8f 100644
--- a/starknet_devnet/starknet_wrapper.py
+++ b/starknet_devnet/starknet_wrapper.py
@@ -260,10 +260,7 @@ async def deploy(self, deploy_transaction: Deploy) -> Tuple[int, int]:
             tx_hash = self.contracts.get_by_address(contract_address).deployment_tx_hash
             return contract_address, tx_hash
 
-        if self.config.lite_mode:
-            tx_hash = self.transactions.get_count()
-        else:
-            tx_hash = internal_tx.hash_value
+        tx_hash = internal_tx.hash_value
 
         try:
             preserved_block_info = self.__update_block_number()


Test patch:
diff --git a/test/conftest.py b/test/conftest.py
index d1fc1d0df..81c2947a2 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -9,10 +9,18 @@
 import pytest
 
 
-@pytest.fixture(name="expected_hash")
-def fixture_expected_hash(request):
+@pytest.fixture(name="expected_tx_hash")
+def fixture_expected_tx_hash(request):
     """
-    Fixture to return values of expected hash
+    Fixture to return values of expected tx hash
+    """
+    return request.param
+
+
+@pytest.fixture(name="expected_block_hash")
+def fixture_expected_block_hash(request):
+    """
+    Fixture to return values of expected block hash
     """
     return request.param
 
diff --git a/test/shared.py b/test/shared.py
index 346511716..534e3e52c 100644
--- a/test/shared.py
+++ b/test/shared.py
@@ -26,7 +26,11 @@
 EXPECTED_SALTY_DEPLOY_HASH = (
     "0x23801cc34aa43f4e2bf3e74a838fe45dd1b1ad316a2d3545aaef7efe1f39b21"
 )
-EXPECTED_SALTY_DEPLOY_HASH_LITE_MODE = "0x2"
+# This is temporary change.
+EXPECTED_SALTY_DEPLOY_HASH_LITE_MODE = (
+    "0x23801cc34aa43f4e2bf3e74a838fe45dd1b1ad316a2d3545aaef7efe1f39b21"
+)
+EXPECTED_SALTY_DEPLOY_BLOCK_HASH_LITE_MODE = "0x1"
 EXPECTED_CLASS_HASH = "0x757a84aa38bf4ad191a7dfea2e8146fc7f3c4aa6090a8f0bddd7b688f0b24c"
 
 NONEXISTENT_TX_HASH = "0x1"
diff --git a/test/test_block_number.py b/test/test_block_number.py
index 72b12496a..e98a933f4 100644
--- a/test/test_block_number.py
+++ b/test/test_block_number.py
@@ -20,26 +20,30 @@ def my_get_block_number(address: str):
 
 @pytest.mark.usefixtures("run_devnet_in_background")
 @pytest.mark.parametrize(
-    "run_devnet_in_background, expected_hash",
+    "run_devnet_in_background, expected_tx_hash",
     [
         ([], "0x4f1ea446f67c1be47619444eae4d8118f6e017d0e6fe16e89b3df03da38606d"),
-        (["--lite-mode"], "0x0"),
+        (
+            ["--lite-mode"],
+            "0x4f1ea446f67c1be47619444eae4d8118f6e017d0e6fe16e89b3df03da38606d",
+        ),
     ],
     indirect=True,
 )
-def test_block_number_incremented(expected_hash):
+def test_block_number_incremented(expected_tx_hash):
     """
     Tests how block number is incremented in regular mode and lite mode.
     In regular mode with salt "0x42" our expected hash is
     0x4f1ea446f67c1be47619444eae4d8118f6e017d0e6fe16e89b3df03da38606d.
-    In lite mode we expect 0x0 transaction hash.
+    In lite mode we expect 0x4f1ea446f67c1be47619444eae4d8118f6e017d0e6fe16e89b3df03da38606d
+    transaction hash because currently, we can't disable tx hash calculations.
     """
 
     deploy_info = deploy(BLOCK_NUMBER_CONTRACT_PATH, salt="0x42")
     block_number_before = my_get_block_number(deploy_info["address"])
 
     assert int(block_number_before) == GENESIS_BLOCK_NUMBER + 1
-    assert expected_hash == deploy_info["tx_hash"]
+    assert expected_tx_hash == deploy_info["tx_hash"]
 
     invoke(
         function="write_block_number",
diff --git a/test/test_deploy.py b/test/test_deploy.py
index 7a4b8031d..308b53f4d 100644
--- a/test/test_deploy.py
+++ b/test/test_deploy.py
@@ -87,8 +87,12 @@ async def test_deploy_lite():
         contract_class=deploy_transaction.contract_definition,
     )
 
+    # Currently in lite mode hashes are actually calculated
+    assert (
+        tx_hash
+        == 2009361157170034697813403089970408499498259480420986282652588934221678003889
+    )
     assert contract_address == expected_contract_address
-    assert tx_hash == 0
 
     tx_status = devnet.transactions.get_transaction_status(hex(tx_hash))
 
diff --git a/test/test_general_workflow.py b/test/test_general_workflow.py
index 922d46fda..c2838b56b 100644
--- a/test/test_general_workflow.py
+++ b/test/test_general_workflow.py
@@ -25,6 +25,7 @@
     get_class_hash_at,
     get_full_contract,
     invoke,
+    get_block,
 )
 
 from .shared import (
@@ -35,7 +36,8 @@
     EVENTS_CONTRACT_PATH,
     EXPECTED_SALTY_DEPLOY_ADDRESS,
     EXPECTED_SALTY_DEPLOY_HASH,
-    # EXPECTED_SALTY_DEPLOY_HASH_LITE_MODE,
+    EXPECTED_SALTY_DEPLOY_HASH_LITE_MODE,
+    EXPECTED_SALTY_DEPLOY_BLOCK_HASH_LITE_MODE,
     FAILING_CONTRACT_PATH,
     GENESIS_BLOCK_NUMBER,
     NONEXISTENT_TX_HASH,
@@ -44,14 +46,18 @@
 
 @pytest.mark.usefixtures("run_devnet_in_background")
 @pytest.mark.parametrize(
-    "run_devnet_in_background, expected_hash",
+    "run_devnet_in_background, expected_tx_hash, expected_block_hash",
     [
-        ([], EXPECTED_SALTY_DEPLOY_HASH),
-        # (["--lite-mode"], EXPECTED_SALTY_DEPLOY_HASH_LITE_MODE),
+        ([], EXPECTED_SALTY_DEPLOY_HASH, ""),
+        (
+            ["--lite-mode"],
+            EXPECTED_SALTY_DEPLOY_HASH_LITE_MODE,
+            EXPECTED_SALTY_DEPLOY_BLOCK_HASH_LITE_MODE,
+        ),
     ],
     indirect=True,
 )
-def test_general_workflow(expected_hash):
+def test_general_workflow(expected_tx_hash, expected_block_hash):
     """Test devnet with CLI"""
     deploy_info = deploy(CONTRACT_PATH, ["0"])
 
@@ -65,6 +71,10 @@ def test_general_workflow(expected_hash):
     # check block and receipt after deployment
     assert_negative_block_input()
 
+    # check if in lite mode expected block hash is 0x1
+    if expected_block_hash == EXPECTED_SALTY_DEPLOY_BLOCK_HASH_LITE_MODE:
+        assert_equal(expected_block_hash, get_block(parse=True)["block_hash"])
+
     assert_block(GENESIS_BLOCK_NUMBER + 1, deploy_info["tx_hash"])
     assert_receipt(deploy_info["tx_hash"], "test/expected/deploy_receipt.json")
     assert_transaction_receipt_not_received(NONEXISTENT_TX_HASH)
@@ -114,7 +124,7 @@ def test_general_workflow(expected_hash):
         inputs=None,
         expected_status="ACCEPTED_ON_L2",
         expected_address=EXPECTED_SALTY_DEPLOY_ADDRESS,
-        expected_tx_hash=expected_hash,
+        expected_tx_hash=expected_tx_hash,
     )
 
     assert_salty_deploy(
@@ -123,7 +133,7 @@ def test_general_workflow(expected_hash):
         inputs=None,
         expected_status="ACCEPTED_ON_L2",
         expected_address=EXPECTED_SALTY_DEPLOY_ADDRESS,
-        expected_tx_hash=expected_hash,
+        expected_tx_hash=expected_tx_hash,
     )
 
     salty_invoke_tx_hash = invoke(