From 85b0ae854f6958c6c6815fdfd3d14cd052ee805a Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Thu, 27 Jul 2023 23:12:49 +0800 Subject: [PATCH] handle `len(blobs) == 0` case --- tests/core/pyspec/eth2spec/test/helpers/fork_choice.py | 10 ++++++---- tests/formats/fork_choice/README.md | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/helpers/fork_choice.py b/tests/core/pyspec/eth2spec/test/helpers/fork_choice.py index c3f496a49..a6babefd3 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/fork_choice.py +++ b/tests/core/pyspec/eth2spec/test/helpers/fork_choice.py @@ -173,10 +173,12 @@ def add_block(spec, # Check blob_data if blob_data is not None: - assert len(blob_data.blobs) == len(blob_data.proofs) blobs = spec.List[spec.Blob, spec.MAX_BLOBS_PER_BLOCK](blob_data.blobs) - blobs_root = blobs.hash_tree_root() - yield get_blobs_file_name(blobs_root=blobs_root), blobs + if len(blobs) > 0: + blobs_root = blobs.hash_tree_root() + yield get_blobs_file_name(blobs_root=blobs_root), blobs + else: + blobs_root = None is_blob_data_test = blob_data is not None @@ -184,7 +186,7 @@ def add_block(spec, if is_blob_data_test: test_steps.append({ 'block': get_block_file_name(signed_block), - 'blobs': get_blobs_file_name(blobs_root=blobs_root), + 'blobs': None if blobs_root is None else get_blobs_file_name(blobs_root=blobs_root), 'proofs': [encode_hex(proof) for proof in blob_data.proofs], 'valid': valid, }) diff --git a/tests/formats/fork_choice/README.md b/tests/formats/fork_choice/README.md index bfc8a423d..4347e95f2 100644 --- a/tests/formats/fork_choice/README.md +++ b/tests/formats/fork_choice/README.md @@ -85,8 +85,9 @@ The parameter that is required for executing `on_block(store, block)`. { block: string -- the name of the `block_<32-byte-root>.ssz_snappy` file. To execute `on_block(store, block)` with the given attestation. - blobs: string -- optional, the name of the `blobs_<32-byte-root>.ssz_snappy` file. + blobs: string or `null` -- optional, the name of the `blobs_<32-byte-root>.ssz_snappy` file. The blobs file content is a `List[Blob, MAX_BLOBS_PER_BLOCK]` SSZ object. + If it's `null`, `blobs` is an empty list. proofs: array of byte48 hex string -- optional, the proofs of blob commitments. valid: bool -- optional, default to `true`. If it's `false`, this execution step is expected to be invalid.