Skip to content

Commit 3e6d322

Browse files
tcoratgerunnawut
andauthored
forkchoice tests: small touchup (leanEthereum#145)
* forkchoice tests: small touchup * rm useless folder * Update packages/testing/src/consensus_testing/test_fixtures/fork_choice.py Co-authored-by: Unnawut Leepaisalsuwanna <921194+unnawut@users.noreply.github.com> --------- Co-authored-by: Unnawut Leepaisalsuwanna <921194+unnawut@users.noreply.github.com>
1 parent a91a52a commit 3e6d322

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

packages/testing/src/consensus_testing/test_fixtures/fork_choice.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,23 @@ def make_fixture(self) -> ForkChoiceTest:
183183
# Use shared key manager if it has sufficient capacity, otherwise create a new one
184184
# This optimizes performance by reusing keys across tests when possible
185185
shared_key_manager = _get_shared_key_manager()
186-
if self.max_slot <= shared_key_manager.max_slot:
187-
key_manager = shared_key_manager
188-
else:
189-
# Test needs more slots than shared manager supports, create dedicated one
190-
key_manager = XmssKeyManager(max_slot=self.max_slot)
186+
key_manager = (
187+
shared_key_manager
188+
if self.max_slot <= shared_key_manager.max_slot
189+
else XmssKeyManager(max_slot=self.max_slot)
190+
)
191191

192192
# Update validator pubkeys to match key_manager's generated keys
193-
updated_validators = []
194-
for i, validator in enumerate(self.anchor_state.validators):
195-
key_pair = key_manager[ValidatorIndex(i)]
196-
pubkey_bytes = key_pair.public.to_bytes(DEFAULT_SIGNATURE_SCHEME.config)
197-
updated_validator = validator.model_copy(update={"pubkey": pubkey_bytes})
198-
updated_validators.append(updated_validator)
193+
updated_validators = [
194+
validator.model_copy(
195+
update={
196+
"pubkey": key_manager[ValidatorIndex(i)].public.to_bytes(
197+
DEFAULT_SIGNATURE_SCHEME.config
198+
)
199+
}
200+
)
201+
for i, validator in enumerate(self.anchor_state.validators)
202+
]
199203

200204
self.anchor_state = self.anchor_state.model_copy(
201205
update={"validators": Validators(data=updated_validators)}
@@ -211,10 +215,8 @@ def make_fixture(self) -> ForkChoiceTest:
211215
)
212216

213217
# Block registry for label-based fork creation
214-
self._block_registry: dict[str, Block] = {}
215-
216218
# Register genesis/anchor block with implicit label
217-
self._block_registry["genesis"] = self.anchor_block
219+
self._block_registry: dict[str, Block] = {"genesis": self.anchor_block}
218220

219221
# Process each step (immutable pattern: store = store.method())
220222
for i, step in enumerate(self.steps):

0 commit comments

Comments
 (0)