From 4d2cfff2d64469c8a6083845c95c6128d7e67d7e Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Mon, 12 Sep 2022 22:59:29 +0800 Subject: [PATCH] Add `test_key_validate_invalid_decompression` --- .../block_processing/test_process_deposit.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_deposit.py b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_deposit.py index f1a27f8ec..8922032b4 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_deposit.py +++ b/tests/core/pyspec/eth2spec/test/phase0/block_processing/test_process_deposit.py @@ -237,7 +237,7 @@ def test_bad_merkle_proof(spec, state): @with_all_phases @spec_state_test -def test_key_validate_invalid(spec, state): +def test_key_validate_invalid_subgroup(spec, state): validator_index = len(state.validators) amount = spec.MAX_EFFECTIVE_BALANCE @@ -247,3 +247,19 @@ def test_key_validate_invalid(spec, state): deposit = prepare_state_and_deposit(spec, state, validator_index, amount, pubkey=pubkey, signed=True) yield from run_deposit_processing(spec, state, deposit, validator_index) + + +@with_all_phases +@spec_state_test +def test_key_validate_invalid_decompression(spec, state): + validator_index = len(state.validators) + amount = spec.MAX_EFFECTIVE_BALANCE + + # `deserialization_fails_infinity_with_true_b_flag` BLS G1 deserialization test case. + # This pubkey would not pass `bls.KeyValidate`, but `process_deposit` would not throw exception. + pubkey_hex = 'c01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' + pubkey = bytes.fromhex(pubkey_hex) + + deposit = prepare_state_and_deposit(spec, state, validator_index, amount, pubkey=pubkey, signed=True) + + yield from run_deposit_processing(spec, state, deposit, validator_index)