mirror of
https://github.com/logos-blockchain/logos-blockchain-specs.git
synced 2026-01-02 21:23:06 +00:00
* Modify and rename hash_commitment method. Now we just hash the column commitment itself. * Fix calls * Remove certificate from verifier * Update verifier * Fix tests * Fix verifier imports * Fix more imports * Fix dispersal * Fix more imports * Fix missing parameter in dispersal * Fix tests * Full flow renaming * Disperse encoded data in full flow test * Make da verification indempotent (#118) --------- Co-authored-by: Gusto <bacvinka@gmail.com> Co-authored-by: gusto <bacv@users.noreply.github.com>
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
from hashlib import sha3_256
|
|
from unittest import TestCase
|
|
|
|
from da.encoder import DAEncoderParams, DAEncoder
|
|
from da.test_encoder import TestEncoder
|
|
from da.verifier import DAVerifier, DABlob
|
|
from da.common import NodeId, NomosDaG2ProofOfPossession as bls_pop
|
|
from da.dispersal import Dispersal, DispersalSettings
|
|
|
|
|
|
class TestDispersal(TestCase):
|
|
def setUp(self):
|
|
self.n_nodes = 16
|
|
self.nodes_ids = [NodeId(x.to_bytes(length=32, byteorder='big')) for x in range(self.n_nodes)]
|
|
dispersal_settings = DispersalSettings(
|
|
self.nodes_ids,
|
|
self.n_nodes // 2 + 1
|
|
)
|
|
self.dispersal = Dispersal(dispersal_settings)
|
|
self.encoder_test = TestEncoder()
|
|
self.encoder_test.setUp()
|
|
|
|
def test_disperse(self):
|
|
data = self.encoder_test.data
|
|
encoding_params = DAEncoderParams(column_count=self.n_nodes // 2, bytes_per_chunk=31)
|
|
encoded_data = DAEncoder(encoding_params).encode(data)
|
|
|
|
# mock send and await method with local verifiers
|
|
verifiers_res = []
|
|
def __send_and_await_response(_, blob: DABlob):
|
|
verifier = DAVerifier()
|
|
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.dispersal.disperse(encoded_data)
|
|
for res in verifiers_res:
|
|
self.assertTrue(res)
|
|
|