diff --git a/requirements.txt b/requirements.txt index 1621ad8..bb64b26 100644 --- a/requirements.txt +++ b/requirements.txt @@ -37,7 +37,7 @@ setuptools==70.0.0 tenacity==8.2.3 typeguard==4.1.5 typing-inspect==0.9.0 -typing_extensions==4.9.0 +typing_extensions>=4.10 urllib3==2.2.2 virtualenv==20.25.0 Jinja2~=3.1.5 diff --git a/tests/data_confidentiality/test_data_confidentiality.py b/tests/data_confidentiality/test_data_confidentiality.py index 500ef71..316b1ab 100644 --- a/tests/data_confidentiality/test_data_confidentiality.py +++ b/tests/data_confidentiality/test_data_confidentiality.py @@ -3,6 +3,7 @@ import json import tarfile import pytest +from ruamel.yaml import YAML from src.client.nomos_cli import NomosCli from src.env_vars import CONSENSUS_SLOT_TIME, NOMOS_CUSTOM @@ -15,6 +16,32 @@ from src.test_data import DATA_TO_DISPERSE logger = get_custom_logger(__name__) +def modify_key_value(file_path, yaml_key_path): + yaml = YAML() + yaml.preserve_quotes = True + + with open(file_path, "r") as f: + data = yaml.load(f) + + keys = yaml_key_path.split(".") + ref = data + for key in keys[:-1]: + if key not in ref: + raise KeyError(f"Key '{key}' not found in path '{'.'.join(keys)}'") + ref = ref[key] + + final_key = keys[-1] + if final_key not in ref: + raise KeyError(f"Key '{final_key}' not found in path '{'.'.join(keys)}'") + + old_value = ref[final_key] + # Swap last two characters + ref[final_key] = old_value[:-2] + old_value[-1] + old_value[-2] + + with open(file_path, "w") as f: + yaml.dump(data, f) + + class TestDataConfidentiality(StepsDataAvailability): main_nodes = [] @@ -45,6 +72,11 @@ class TestDataConfidentiality(StepsDataAvailability): self.node2.stop() + # Change the private key of the nomos_node_0 -> change its PeerId + modify_key_value("./cluster_config/config.yaml", "network.backend.node_key") + modify_key_value("./cluster_config/config.yaml", "blend.backend.node_key") + modify_key_value("./cluster_config/config.yaml", "da_network.backend.node_key") + # Start new node with the same hostname and configuration as first node self.nodeX = NomosNode(NOMOS_CUSTOM, "nomos_node_0") self.nodeX.start()