mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-04 22:23:07 +00:00
Fix tests
This commit is contained in:
parent
724352e19f
commit
8550ce6086
@ -41,11 +41,10 @@ class Dispersal:
|
||||
pass
|
||||
|
||||
def disperse(self, encoded_data: EncodedData):
|
||||
attestations = []
|
||||
blob_data = zip(
|
||||
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)
|
||||
|
||||
|
||||
@ -25,11 +25,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(blob_metadata.blob_id, blob_metadata.metadata)
|
||||
self.api.write(vid.blob_id, vid.metadata)
|
||||
|
||||
def read(self, app_id, indexes) -> List[Optional[DAShare]]:
|
||||
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)
|
||||
)
|
||||
|
||||
@ -104,12 +103,12 @@ class TestFullFlow(TestCase):
|
||||
# inject mock send and await method
|
||||
self.dispersal._send_and_await_response = __send_and_await_response
|
||||
self.dispersal.disperse(encoded_data)
|
||||
blob_id = build_blob_id(encoded_data.row_commitments)
|
||||
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)
|
||||
)
|
||||
|
||||
|
||||
@ -35,7 +35,9 @@ class TestVerifier(TestCase):
|
||||
da_blob = DABlob(
|
||||
Column(column),
|
||||
i,
|
||||
encoded_data.combined_column_proofs[i],
|
||||
encoded_data.column_commitments[i],
|
||||
encoded_data.aggregated_column_commitment,
|
||||
encoded_data.aggregated_column_proofs[i],
|
||||
encoded_data.row_commitments,
|
||||
)
|
||||
self.assertIsNotNone(verifier.verify(da_blob))
|
||||
@ -49,7 +51,9 @@ class TestVerifier(TestCase):
|
||||
da_blob = DAShare(
|
||||
Column(column),
|
||||
i,
|
||||
encoded_data.combined_column_proofs[i],
|
||||
encoded_data.column_commitments[i],
|
||||
encoded_data.aggregated_column_commitment,
|
||||
encoded_data.aggregated_column_proofs[i],
|
||||
encoded_data.row_commitments,
|
||||
)
|
||||
self.assertIsNotNone(self.verifier.verify(da_blob))
|
||||
@ -57,7 +61,9 @@ class TestVerifier(TestCase):
|
||||
da_blob = DAShare(
|
||||
Column(column),
|
||||
i,
|
||||
encoded_data.combined_column_proofs[i],
|
||||
encoded_data.column_commitments[i],
|
||||
encoded_data.aggregated_column_commitment,
|
||||
encoded_data.aggregated_column_proofs[i],
|
||||
encoded_data.row_commitments,
|
||||
)
|
||||
self.assertFalse(self.verifier.verify(da_blob))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user