2025-02-06 16:09:30 +08:00
|
|
|
import json
|
2025-02-11 16:11:14 +08:00
|
|
|
import random
|
2025-02-06 16:09:30 +08:00
|
|
|
|
2025-01-17 14:23:52 +08:00
|
|
|
import pytest
|
|
|
|
|
|
2025-03-10 05:57:22 +00:00
|
|
|
from src.client.nomos_cli import NomosCli
|
2025-02-13 11:07:41 +08:00
|
|
|
from src.libs.common import delay, to_app_id, to_index
|
2025-02-06 16:09:30 +08:00
|
|
|
from src.libs.custom_logger import get_custom_logger
|
2025-01-17 14:23:52 +08:00
|
|
|
from src.steps.da import StepsDataAvailability
|
|
|
|
|
from src.test_data import DATA_TO_DISPERSE
|
|
|
|
|
|
2025-02-06 16:09:30 +08:00
|
|
|
logger = get_custom_logger(__name__)
|
|
|
|
|
|
2025-01-17 14:23:52 +08:00
|
|
|
|
|
|
|
|
class TestDataIntegrity(StepsDataAvailability):
|
2024-12-13 15:58:25 +08:00
|
|
|
main_nodes = []
|
|
|
|
|
|
2025-02-11 16:11:14 +08:00
|
|
|
@pytest.mark.usefixtures("setup_4_node_cluster")
|
2025-01-16 19:08:22 +08:00
|
|
|
def test_da_identify_retrieve_missing_columns(self):
|
2025-02-13 19:51:14 +08:00
|
|
|
self.disperse_data(DATA_TO_DISPERSE[1], to_app_id(1), to_index(0))
|
2025-02-12 13:39:43 +08:00
|
|
|
delay(5)
|
2025-02-28 02:53:34 +00:00
|
|
|
test_results = []
|
|
|
|
|
# Iterate through standard nodes to get blob data for 1/2 columns
|
|
|
|
|
for node in self.main_nodes[1:4]:
|
|
|
|
|
rcv_data = self.get_data_range(node, to_app_id(1), to_index(0), to_index(5))
|
|
|
|
|
rcv_data_json = json.dumps(rcv_data)
|
|
|
|
|
|
|
|
|
|
reconstructed_data = NomosCli(command="reconstruct").run(input_values=[rcv_data_json])
|
|
|
|
|
|
|
|
|
|
if DATA_TO_DISPERSE[1] == reconstructed_data:
|
|
|
|
|
test_results.append(node.name())
|
2025-02-11 16:11:14 +08:00
|
|
|
|
2025-02-28 02:53:34 +00:00
|
|
|
assert len(test_results) > 0, "Dispersed data were not received by any node"
|
2025-01-22 14:47:33 +08:00
|
|
|
|
2025-02-28 02:53:34 +00:00
|
|
|
logger.info(f"Dispersed data received by : {test_results}")
|
2025-01-16 19:08:22 +08:00
|
|
|
|
2025-01-21 14:55:26 +08:00
|
|
|
@pytest.mark.usefixtures("setup_2_node_cluster")
|
2025-01-16 19:08:22 +08:00
|
|
|
def test_da_sampling_determines_data_presence(self):
|
2025-02-13 19:51:14 +08:00
|
|
|
self.disperse_data(DATA_TO_DISPERSE[1], to_app_id(1), to_index(0))
|
2025-02-10 20:49:24 +08:00
|
|
|
delay(5)
|
2025-02-13 11:07:41 +08:00
|
|
|
rcv_data = self.get_data_range(self.node2, to_app_id(1), to_index(0), to_index(5))
|
2025-02-11 16:11:14 +08:00
|
|
|
rcv_data_json = json.dumps(rcv_data)
|
|
|
|
|
|
2025-02-13 10:29:18 +08:00
|
|
|
decoded_data = NomosCli(command="reconstruct").run(input_values=[rcv_data_json], decode_only=True)
|
2025-02-06 16:09:30 +08:00
|
|
|
|
2025-02-13 19:51:14 +08:00
|
|
|
assert DATA_TO_DISPERSE[1] == decoded_data, "Retrieved data are not same with original data"
|