mirror of
https://github.com/logos-blockchain/logos-blockchain-e2e-tests.git
synced 2026-01-07 15:43:05 +00:00
fix: optimize test_da_consensus_compatibility
This commit is contained in:
parent
8337506961
commit
17371cf3c5
@ -1,7 +1,5 @@
|
|||||||
import json
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from src.client.nomos_cli import NomosCli
|
|
||||||
from src.libs.common import to_app_id, to_index, delay
|
from src.libs.common import to_app_id, to_index, delay
|
||||||
from src.libs.custom_logger import get_custom_logger
|
from src.libs.custom_logger import get_custom_logger
|
||||||
from src.steps.consensus import StepsConsensus
|
from src.steps.consensus import StepsConsensus
|
||||||
@ -12,6 +10,37 @@ from src.test_data import DATA_TO_DISPERSE
|
|||||||
logger = get_custom_logger(__name__)
|
logger = get_custom_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
# Extract commitments from indexed shares
|
||||||
|
def extract_commitments(index_shares):
|
||||||
|
aggregated_column_commitments = []
|
||||||
|
rows_commitments = []
|
||||||
|
|
||||||
|
for index, shares in index_shares:
|
||||||
|
for share in shares:
|
||||||
|
a_c_c = share["aggregated_column_commitment"]
|
||||||
|
if a_c_c not in aggregated_column_commitments:
|
||||||
|
aggregated_column_commitments.append(a_c_c)
|
||||||
|
|
||||||
|
r_c = share["rows_commitments"]
|
||||||
|
for commitment in r_c:
|
||||||
|
if commitment not in rows_commitments:
|
||||||
|
rows_commitments.append(commitment)
|
||||||
|
|
||||||
|
return aggregated_column_commitments, rows_commitments
|
||||||
|
|
||||||
|
|
||||||
|
# Parse commitments received by get_shares_commitments
|
||||||
|
def parse_commitments(commitments):
|
||||||
|
aggregated_column_commitments = []
|
||||||
|
rows_commitments = []
|
||||||
|
for commitment in commitments:
|
||||||
|
aggregated_column_commitments.append(commitment["aggregated_column_commitment"])
|
||||||
|
for rows_commitment in commitment["rows_commitments"]:
|
||||||
|
rows_commitments.append(rows_commitment)
|
||||||
|
|
||||||
|
return aggregated_column_commitments, rows_commitments
|
||||||
|
|
||||||
|
|
||||||
class TestApiCompatibility(StepsDataAvailability, StepsConsensus, StepsStorage):
|
class TestApiCompatibility(StepsDataAvailability, StepsConsensus, StepsStorage):
|
||||||
main_nodes = []
|
main_nodes = []
|
||||||
|
|
||||||
@ -19,25 +48,13 @@ class TestApiCompatibility(StepsDataAvailability, StepsConsensus, StepsStorage):
|
|||||||
def test_da_consensus_compatibility(self):
|
def test_da_consensus_compatibility(self):
|
||||||
self.disperse_data(DATA_TO_DISPERSE[2], to_app_id(1), to_index(0))
|
self.disperse_data(DATA_TO_DISPERSE[2], to_app_id(1), to_index(0))
|
||||||
delay(5)
|
delay(5)
|
||||||
shares = self.get_data_range(self.node2, to_app_id(1), to_index(0), to_index(5))
|
index_shares = self.get_data_range(self.node2, to_app_id(1), to_index(0), to_index(5))
|
||||||
logger.debug(f"shares: {shares}")
|
column_commitments, rows_commitments = extract_commitments(index_shares)
|
||||||
aggregated_column_commitments = []
|
|
||||||
rows_commitments = []
|
|
||||||
for index_share in shares:
|
|
||||||
if len(index_share[1]) != 0:
|
|
||||||
for share in index_share[1]:
|
|
||||||
a_c_c = share["aggregated_column_commitment"]
|
|
||||||
if a_c_c not in aggregated_column_commitments:
|
|
||||||
aggregated_column_commitments.append(a_c_c)
|
|
||||||
|
|
||||||
r_c = share["rows_commitments"]
|
|
||||||
for commitment in r_c:
|
|
||||||
if commitment not in rows_commitments:
|
|
||||||
rows_commitments.append(commitment)
|
|
||||||
|
|
||||||
|
# Get headers of received blocks
|
||||||
headers = self.get_cryptarchia_headers(self.node2)
|
headers = self.get_cryptarchia_headers(self.node2)
|
||||||
|
|
||||||
# Get storage blocks for headerIDs
|
# Get storage blocks for headers
|
||||||
blob_ids = []
|
blob_ids = []
|
||||||
for header in headers:
|
for header in headers:
|
||||||
block = self.get_storage_block(self.node2, header)
|
block = self.get_storage_block(self.node2, header)
|
||||||
@ -52,16 +69,8 @@ class TestApiCompatibility(StepsDataAvailability, StepsConsensus, StepsStorage):
|
|||||||
commitment = self.get_shares_commitments(self.node2, blob_id)
|
commitment = self.get_shares_commitments(self.node2, blob_id)
|
||||||
commitments.append(commitment)
|
commitments.append(commitment)
|
||||||
|
|
||||||
rcv_aggregated_column_commitments = []
|
rcv_column_commitments, rcv_rows_commitments = parse_commitments(commitments)
|
||||||
rcv_rows_commitments = []
|
|
||||||
for commitment in commitments:
|
|
||||||
rcv_aggregated_column_commitments.append(commitment["aggregated_column_commitment"])
|
|
||||||
for rcv_rows_commitment in commitment["rows_commitments"]:
|
|
||||||
rcv_rows_commitments.append(rcv_rows_commitment)
|
|
||||||
|
|
||||||
# Check commitments from shares match commitments received based on consensus data
|
# Check commitments from shares match commitments received based on consensus data
|
||||||
for a_c_c in aggregated_column_commitments:
|
assert all(c in rcv_column_commitments for c in column_commitments), "Not all aggregated column commitments are present"
|
||||||
assert a_c_c in rcv_aggregated_column_commitments
|
assert all(r in rcv_rows_commitments for r in rows_commitments), "Not all rows commitments are present"
|
||||||
|
|
||||||
for r_c in rows_commitments:
|
|
||||||
assert r_c in rcv_rows_commitments
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user