mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-20 22:13:10 +00:00
Fix tests
This commit is contained in:
parent
787062e1da
commit
f5f22a8c3d
@ -44,12 +44,10 @@ class Dispersal:
|
||||
pass
|
||||
|
||||
def disperse(self, encoded_data: EncodedData):
|
||||
attestations = []
|
||||
blob_data = zip(
|
||||
range(len(self.settings.nodes_ids)),
|
||||
self.settings.nodes_ids,
|
||||
self._prepare_data(encoded_data)
|
||||
)
|
||||
for i, node, blob in blob_data:
|
||||
for node, blob in blob_data:
|
||||
self._send_and_await_response(node, blob)
|
||||
|
||||
|
||||
@ -26,11 +26,15 @@ class TestDispersal(TestCase):
|
||||
encoded_data = DAEncoder(encoding_params).encode(data)
|
||||
|
||||
# mock send and await method with local verifiers
|
||||
def __send_and_await_response(blob: DABlob):
|
||||
verifiers_res = []
|
||||
def __send_and_await_response(_, blob: DABlob):
|
||||
verifier = DAVerifier()
|
||||
return verifier.verify(blob)
|
||||
res = verifier.verify(blob)
|
||||
verifiers_res.append(res)
|
||||
return res
|
||||
# inject mock send and await method
|
||||
self.dispersal._send_and_await_response = __send_and_await_response
|
||||
|
||||
self.assertTrue(self.dispersal.disperse(encoded_data))
|
||||
self.dispersal.disperse(encoded_data)
|
||||
for res in verifiers_res:
|
||||
self.assertTrue(res)
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@ class DAVerifierWApi:
|
||||
# Usually the certificate would be verifier here,
|
||||
# but we are assuming that this it is already coming from the verified block,
|
||||
# in which case all certificates had been already verified by the DA Node.
|
||||
self.api.write(vid.cert_id, vid.metadata)
|
||||
self.api.write(vid.blob_id, vid.metadata)
|
||||
|
||||
def read(self, app_id, indexes) -> List[Optional[DABlob]]:
|
||||
return self.api.read(app_id, indexes)
|
||||
@ -66,10 +66,9 @@ class TestFullFlow(TestCase):
|
||||
|
||||
# inject mock send and await method
|
||||
self.dispersal._send_and_await_response = __send_and_await_response
|
||||
certificate = self.dispersal.disperse(encoded_data)
|
||||
|
||||
blob_id = build_blob_id(encoded_data.aggregated_column_commitment, encoded_data.row_commitments)
|
||||
vid = BlobMetadata(
|
||||
certificate.id(),
|
||||
blob_id,
|
||||
Metadata(app_id, index)
|
||||
)
|
||||
|
||||
@ -103,12 +102,13 @@ class TestFullFlow(TestCase):
|
||||
|
||||
# inject mock send and await method
|
||||
self.dispersal._send_and_await_response = __send_and_await_response
|
||||
certificate = self.dispersal.disperse(encoded_data)
|
||||
self.dispersal.disperse(encoded_data)
|
||||
blob_id = build_blob_id(encoded_data.aggregated_column_commitment, encoded_data.row_commitments)
|
||||
|
||||
# Loop through each index and simulate dispersal with the same cert_id but different metadata
|
||||
for index in indexes:
|
||||
metadata = BlobMetadata(
|
||||
certificate.id(),
|
||||
blob_id,
|
||||
Metadata(app_id, index)
|
||||
)
|
||||
|
||||
@ -122,7 +122,7 @@ class TestFullFlow(TestCase):
|
||||
# as we do actually do dispersal.
|
||||
blobs = list(chain.from_iterable(
|
||||
node.read(app_id, [index])
|
||||
for node in sorted(self.api_nodes, key=lambda n: bls_pop.SkToPk(n.verifier.sk))
|
||||
for node in self.api_nodes
|
||||
))
|
||||
original_blobs = list(self.dispersal._prepare_data(encoded_data))
|
||||
self.assertEqual(blobs, original_blobs, f"Failed at index {index}")
|
||||
|
||||
@ -34,6 +34,7 @@ class TestVerifier(TestCase):
|
||||
verifier = DAVerifier()
|
||||
da_blob = DABlob(
|
||||
Column(column),
|
||||
i,
|
||||
encoded_data.column_commitments[i],
|
||||
encoded_data.aggregated_column_commitment,
|
||||
encoded_data.aggregated_column_proofs[i],
|
||||
@ -50,6 +51,7 @@ class TestVerifier(TestCase):
|
||||
i, column = next(columns)
|
||||
da_blob = DABlob(
|
||||
Column(column),
|
||||
i,
|
||||
encoded_data.column_commitments[i],
|
||||
encoded_data.aggregated_column_commitment,
|
||||
encoded_data.aggregated_column_proofs[i],
|
||||
@ -60,6 +62,7 @@ class TestVerifier(TestCase):
|
||||
for i, column in columns:
|
||||
da_blob = DABlob(
|
||||
Column(column),
|
||||
i,
|
||||
encoded_data.column_commitments[i],
|
||||
encoded_data.aggregated_column_commitment,
|
||||
encoded_data.aggregated_column_proofs[i],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user