From 3019a92460cb2564e809179fca7453f012efb47a Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Quiros Date: Wed, 6 Mar 2024 17:18:13 +0100 Subject: [PATCH] Use square size data for encoder tests --- da/encoder.py | 2 +- da/test_common.py | 3 +++ da/test_encoder.py | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/da/encoder.py b/da/encoder.py index 70a10db..87e5f09 100644 --- a/da/encoder.py +++ b/da/encoder.py @@ -33,7 +33,7 @@ class DAEncoder: def _chunkify_data(self, data: bytes) -> ChunksMatrix: size: int = self.params.column_count * self.params.bytes_per_field_element return ChunksMatrix( - Row([bytes(chunk) for chunk in batched(b, self.params.bytes_per_field_element)]) + Row(Chunk(bytes(chunk)) for chunk in batched(b, self.params.bytes_per_field_element)) for b in batched(data, size) ) diff --git a/da/test_common.py b/da/test_common.py index 26ea40b..9982270 100644 --- a/da/test_common.py +++ b/da/test_common.py @@ -15,3 +15,6 @@ class TestCommon(TestCase): matrix = ChunksMatrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) expected = ChunksMatrix([[1, 4, 7], [2, 5, 8], [3, 6, 9]]) self.assertEqual(matrix.transposed(), expected) + matrix = ChunksMatrix([[1, 2, 3], [4, 5, 6]]) + expected = ChunksMatrix([[1, 4], [2, 5], [3, 6]]) + self.assertEqual(matrix.transposed(), expected) diff --git a/da/test_encoder.py b/da/test_encoder.py index 5227ba3..e431d2d 100644 --- a/da/test_encoder.py +++ b/da/test_encoder.py @@ -14,7 +14,7 @@ class TestEncoder(TestCase): def setUp(self): self.params: DAEncoderParams = DAEncoderParams(column_count=16, bytes_per_field_element=32) self.encoder: DAEncoder = DAEncoder(self.params) - self.elements = 100 + self.elements = 32 self.data = bytearray( chain.from_iterable( randrange(BLS_MODULUS).to_bytes(length=self.params.bytes_per_field_element, byteorder='big') @@ -76,9 +76,9 @@ class TestEncoder(TestCase): def test_compute_column_kzg_commitments(self): chunks_matrix = self.encoder._chunkify_data(self.data) - polynomials, commitments = zip(*self.encoder._compute_row_kzg_commitments(chunks_matrix.transposed())) - self.assertEqual(len(commitments), len(chunks_matrix)) - self.assertEqual(len(polynomials), len(chunks_matrix)) + polynomials, commitments = zip(*self.encoder._compute_column_kzg_commitments(chunks_matrix)) + self.assertEqual(len(commitments), len(chunks_matrix[0])) + self.assertEqual(len(polynomials), len(chunks_matrix[0])) def test_generate_aggregated_column_commitments(self): pass