Skip to content

Commit c78d349

Browse files
committed
fix(specs,testing): Fix serializaiton to use camelCase; refactor model impl
1 parent 3fb2b01 commit c78d349

File tree

25 files changed

+84
-108
lines changed

25 files changed

+84
-108
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
2. Install dependencies: `uv sync --all-packages`
77
3. Make your changes
88
4. Run checks: `uvx tox -e all-checks`
9-
5. Run tests: `uvx pytest`
9+
5. Run tests: `uvx tox -e pytest`
1010
6. Submit a pull request
1111

1212
## Pull Request Guidelines

packages/testing/src/consensus_testing/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
from typing import Type
44

5-
from framework.base_types import CamelModel
6-
75
from . import forks
8-
from .block_spec import BlockSpec
9-
from .genesis import generate_pre_state
106
from .test_fixtures import (
117
BaseConsensusFixture,
128
ForkChoiceTest,
@@ -15,11 +11,13 @@
1511
from .test_types import (
1612
AttestationStep,
1713
BaseForkChoiceStep,
14+
BlockSpec,
1815
BlockStep,
1916
ForkChoiceStep,
2017
StateExpectation,
2118
StoreChecks,
2219
TickStep,
20+
generate_pre_state,
2321
)
2422

2523
StateTransitionTestFiller = Type[StateTransitionTest]
@@ -31,7 +29,6 @@
3129
"forks",
3230
"generate_pre_state",
3331
# Base types
34-
"CamelModel",
3532
# Fixture classes
3633
"BaseConsensusFixture",
3734
"StateTransitionTest",

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
from lean_spec.subspecs.ssz import hash_tree_root
2020
from lean_spec.types import Bytes32, Bytes4000, Uint64, ValidatorIndex
2121

22-
from ..block_spec import BlockSpec
23-
from ..test_types import AttestationStep, BlockStep, ForkChoiceStep, TickStep
22+
from ..test_types import AttestationStep, BlockSpec, BlockStep, ForkChoiceStep, TickStep
2423
from .base import BaseConsensusFixture
2524

2625

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
from lean_spec.subspecs.ssz.hash import hash_tree_root
1111
from lean_spec.types import Bytes32, ValidatorIndex
1212

13-
from ..block_spec import BlockSpec
14-
from ..test_types import StateExpectation
13+
from ..test_types import BlockSpec, StateExpectation
1514
from .base import BaseConsensusFixture
1615

1716

packages/testing/src/consensus_testing/test_types/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Test types for consensus test fixtures."""
22

3+
from .block_spec import BlockSpec
4+
from .genesis import generate_pre_state
35
from .state_expectation import StateExpectation
46
from .step_types import (
57
AttestationStep,
@@ -14,8 +16,10 @@
1416
"StateExpectation",
1517
"StoreChecks",
1618
"BaseForkChoiceStep",
19+
"BlockSpec",
1720
"TickStep",
1821
"BlockStep",
1922
"AttestationStep",
2023
"ForkChoiceStep",
24+
"generate_pre_state",
2125
]

packages/testing/src/consensus_testing/block_spec.py renamed to packages/testing/src/consensus_testing/test_types/block_spec.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
"""Lightweight block specification for test definitions."""
22

3-
from pydantic import BaseModel
4-
53
from lean_spec.subspecs.containers.block import BlockBody
64
from lean_spec.subspecs.containers.slot import Slot
7-
from lean_spec.types import Bytes32, ValidatorIndex
5+
from lean_spec.types import Bytes32, CamelModel, ValidatorIndex
86

97

10-
class BlockSpec(BaseModel):
8+
class BlockSpec(CamelModel):
119
"""
1210
Block specification for test definitions.
1311

packages/testing/src/consensus_testing/genesis.py renamed to packages/testing/src/consensus_testing/test_types/genesis.py

File renamed without changes.

packages/testing/src/consensus_testing/test_types/state_expectation.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
from typing import TYPE_CHECKING
44

5-
from pydantic import BaseModel
6-
75
from lean_spec.subspecs.containers.slot import Slot
8-
from lean_spec.types import Bytes32
6+
from lean_spec.types import Bytes32, CamelModel
97

108
if TYPE_CHECKING:
119
from lean_spec.subspecs.containers.state import State
1210

1311

14-
class StateExpectation(BaseModel):
12+
class StateExpectation(CamelModel):
1513
"""
1614
Expected State fields after state transition (selective validation).
1715

packages/testing/src/consensus_testing/test_types/step_types.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
from typing import Annotated, Any, Literal, Union
44

5-
from pydantic import BaseModel, ConfigDict, Field, PrivateAttr, field_serializer
5+
from pydantic import ConfigDict, Field, PrivateAttr, field_serializer
66

77
from lean_spec.subspecs.containers import SignedAttestation
88
from lean_spec.subspecs.containers.block.block import Block
9+
from lean_spec.types import CamelModel
910

10-
from ..block_spec import BlockSpec
11+
from .block_spec import BlockSpec
1112
from .store_checks import StoreChecks
1213

1314

14-
class BaseForkChoiceStep(BaseModel):
15+
class BaseForkChoiceStep(CamelModel):
1516
"""
1617
Base class for fork choice event steps.
1718

packages/testing/src/consensus_testing/test_types/store_checks.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
from typing import TYPE_CHECKING
44

5-
from pydantic import BaseModel
6-
75
from lean_spec.subspecs.containers.slot import Slot
8-
from lean_spec.types import Bytes32, Uint64
6+
from lean_spec.types import Bytes32, CamelModel, Uint64
97

108
if TYPE_CHECKING:
119
from lean_spec.subspecs.forkchoice.store import Store
1210

1311

14-
class StoreChecks(BaseModel):
12+
class StoreChecks(CamelModel):
1513
"""
1614
Store state checks for fork choice tests.
1715

0 commit comments

Comments
 (0)