55 lines
2.0 KiB
Python
Raw Permalink Normal View History

2025-04-22 14:00:13 +08:00
import pytest
from src.env_vars import CONSENSUS_SLOT_TIME
2025-04-24 14:50:10 +08:00
from src.libs.common import to_app_id, to_index, delay, to_blob_id
2025-04-22 14:00:13 +08:00
from src.libs.custom_logger import get_custom_logger
from src.steps.consensus import StepsConsensus
from src.steps.da import StepsDataAvailability
2025-04-24 14:50:10 +08:00
from src.steps.mempool import StepsMempool
2025-04-22 14:00:13 +08:00
from src.steps.storage import StepsStorage
from src.test_data import DATA_TO_DISPERSE
logger = get_custom_logger(__name__)
def extract_da_shares(index_shares):
return [share for _, shares in index_shares for share in shares if shares]
2025-04-24 14:50:10 +08:00
class TestInteractionDataFlow(StepsDataAvailability, StepsMempool):
2025-04-22 14:00:13 +08:00
main_nodes = []
@pytest.mark.usefixtures("setup_2_node_cluster")
def test_da_dispersal_integration(self):
self.disperse_data(DATA_TO_DISPERSE[3], to_app_id(1), to_index(0))
delay(CONSENSUS_SLOT_TIME)
2025-04-22 14:00:13 +08:00
index_shares = self.get_data_range(self.node2, to_app_id(1), to_index(0), to_index(5))
da_shares = extract_da_shares(index_shares)
assert len(da_shares) == 2, "Two da_shares are expected"
modified_da_share = da_shares[0]
modified_da_share["share_idx"] = 7
2025-04-22 15:53:33 +08:00
self.add_publish_share(self.node2, modified_da_share)
delay(CONSENSUS_SLOT_TIME)
index_shares = self.get_data_range(self.node2, to_app_id(1), to_index(0), to_index(8))
da_shares = extract_da_shares(index_shares)
assert len(da_shares) < 3, "Modified da_share should not get published"
2025-04-24 14:50:10 +08:00
@pytest.mark.usefixtures("setup_2_node_cluster")
def test_da_mempool_interaction(self):
self.disperse_data(DATA_TO_DISPERSE[4], to_app_id(1), to_index(0))
2025-04-24 14:50:10 +08:00
self.add_dispersed_blob_info(self.node2, to_blob_id(10), to_app_id(1), to_index(0))
delay(CONSENSUS_SLOT_TIME)
2025-04-24 14:50:10 +08:00
index_shares = self.get_data_range(self.node2, to_app_id(1), to_index(0), to_index(5))
da_shares = extract_da_shares(index_shares)
2025-04-24 15:08:06 +08:00
assert len(da_shares) == 2, "Dispersal should not be affected by additional blob info added to mempool"