Convert assert to return False
This commit is contained in:
parent
e02cbab59f
commit
3984bd3604
|
@ -73,11 +73,16 @@ def verify_data_column_sidecar(sidecar: DataColumnSidecar) -> bool:
|
||||||
Verify if the data column sidecar is valid.
|
Verify if the data column sidecar is valid.
|
||||||
"""
|
"""
|
||||||
# The sidecar index must be within the valid range
|
# The sidecar index must be within the valid range
|
||||||
assert sidecar.index < NUMBER_OF_COLUMNS
|
if sidecar.index >= NUMBER_OF_COLUMNS
|
||||||
|
return False
|
||||||
|
|
||||||
# A sidecar for zero blobs is invalid
|
# A sidecar for zero blobs is invalid
|
||||||
assert len(sidecar.kzg_commitments) > 0
|
if len(sidecar.kzg_commitments) == 0:
|
||||||
|
return False
|
||||||
|
|
||||||
# There should be an equal number of cells/commitments/proofs
|
# There should be an equal number of cells/commitments/proofs
|
||||||
assert len(sidecar.column) == len(sidecar.kzg_commitments) == len(sidecar.kzg_proofs)
|
if len(sidecar.column) != len(sidecar.kzg_commitments) or len(sidecar.column) != len(sidecar.kzg_proofs):
|
||||||
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import random
|
import random
|
||||||
from eth2spec.test.context import (
|
from eth2spec.test.context import (
|
||||||
expect_assertion_error,
|
|
||||||
single_phase,
|
single_phase,
|
||||||
spec_state_test,
|
spec_state_test,
|
||||||
spec_test,
|
spec_test,
|
||||||
|
@ -62,7 +61,7 @@ def test_verify_data_column_sidecar__invalid_zero_blobs(spec, state):
|
||||||
sidecar.column = []
|
sidecar.column = []
|
||||||
sidecar.kzg_commitments = []
|
sidecar.kzg_commitments = []
|
||||||
sidecar.kzg_proofs = []
|
sidecar.kzg_proofs = []
|
||||||
expect_assertion_error(lambda: spec.verify_data_column_sidecar(sidecar))
|
assert not spec.verify_data_column_sidecar(sidecar)
|
||||||
|
|
||||||
|
|
||||||
@with_eip7594_and_later
|
@with_eip7594_and_later
|
||||||
|
@ -71,7 +70,7 @@ def test_verify_data_column_sidecar__invalid_zero_blobs(spec, state):
|
||||||
def test_verify_data_column_sidecar__invalid_index(spec, state):
|
def test_verify_data_column_sidecar__invalid_index(spec, state):
|
||||||
sidecar = compute_data_column_sidecar(spec, state)
|
sidecar = compute_data_column_sidecar(spec, state)
|
||||||
sidecar.index = 128
|
sidecar.index = 128
|
||||||
expect_assertion_error(lambda: spec.verify_data_column_sidecar(sidecar))
|
assert not spec.verify_data_column_sidecar(sidecar)
|
||||||
|
|
||||||
|
|
||||||
@with_eip7594_and_later
|
@with_eip7594_and_later
|
||||||
|
@ -80,7 +79,7 @@ def test_verify_data_column_sidecar__invalid_index(spec, state):
|
||||||
def test_verify_data_column_sidecar__invalid_mismatch_len_column(spec, state):
|
def test_verify_data_column_sidecar__invalid_mismatch_len_column(spec, state):
|
||||||
sidecar = compute_data_column_sidecar(spec, state)
|
sidecar = compute_data_column_sidecar(spec, state)
|
||||||
sidecar.column = sidecar.column[1:]
|
sidecar.column = sidecar.column[1:]
|
||||||
expect_assertion_error(lambda: spec.verify_data_column_sidecar(sidecar))
|
assert not spec.verify_data_column_sidecar(sidecar)
|
||||||
|
|
||||||
|
|
||||||
@with_eip7594_and_later
|
@with_eip7594_and_later
|
||||||
|
@ -89,7 +88,7 @@ def test_verify_data_column_sidecar__invalid_mismatch_len_column(spec, state):
|
||||||
def test_verify_data_column_sidecar__invalid_mismatch_len_kzg_commitments(spec, state):
|
def test_verify_data_column_sidecar__invalid_mismatch_len_kzg_commitments(spec, state):
|
||||||
sidecar = compute_data_column_sidecar(spec, state)
|
sidecar = compute_data_column_sidecar(spec, state)
|
||||||
sidecar.kzg_commitments = sidecar.kzg_commitments[1:]
|
sidecar.kzg_commitments = sidecar.kzg_commitments[1:]
|
||||||
expect_assertion_error(lambda: spec.verify_data_column_sidecar_kzg_proofs(sidecar))
|
assert not spec.verify_data_column_sidecar(sidecar)
|
||||||
|
|
||||||
|
|
||||||
@with_eip7594_and_later
|
@with_eip7594_and_later
|
||||||
|
@ -98,7 +97,7 @@ def test_verify_data_column_sidecar__invalid_mismatch_len_kzg_commitments(spec,
|
||||||
def test_verify_data_column_sidecars__invalid_mismatch_len_kzg_proofs(spec, state):
|
def test_verify_data_column_sidecars__invalid_mismatch_len_kzg_proofs(spec, state):
|
||||||
sidecar = compute_data_column_sidecar(spec, state)
|
sidecar = compute_data_column_sidecar(spec, state)
|
||||||
sidecar.kzg_proofs = sidecar.kzg_proofs[1:]
|
sidecar.kzg_proofs = sidecar.kzg_proofs[1:]
|
||||||
expect_assertion_error(lambda: spec.verify_data_column_sidecar_kzg_proofs(sidecar))
|
assert not spec.verify_data_column_sidecar(sidecar)
|
||||||
|
|
||||||
|
|
||||||
# Tests for verify_data_column_sidecar_kzg_proofs
|
# Tests for verify_data_column_sidecar_kzg_proofs
|
||||||
|
|
Loading…
Reference in New Issue