Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/testing/src/consensus_testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from typing import Type

from . import forks
from .genesis import build_anchor, generate_pre_state
from .test_fixtures import (
from consensus_testing import forks
from consensus_testing.genesis import build_anchor, generate_pre_state
from consensus_testing.test_fixtures import (
ApiEndpointTest,
BaseConsensusFixture,
DropComponentMessageBinding,
Expand All @@ -28,7 +28,7 @@
VerifySignaturesTest,
VerifySingleMessageProofsTest,
)
from .test_types import (
from consensus_testing.test_types import (
AggregatedAttestationCheck,
AggregatedAttestationSpec,
AttestationCheck,
Expand Down
4 changes: 2 additions & 2 deletions packages/testing/src/consensus_testing/forks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from framework.forks import BaseFork, BaseForkMeta, ForkRegistry

from . import forks as _forks_module
from .forks import Lstar
from consensus_testing.forks import forks as _forks_module
from consensus_testing.forks.forks import Lstar

Fork = Type[BaseFork]

Expand Down
3 changes: 1 addition & 2 deletions packages/testing/src/consensus_testing/genesis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Consensus layer pre-state generation."""

from consensus_testing.keys import XmssKeyManager
from lean_spec.spec.crypto.merkleization import hash_tree_root
from lean_spec.spec.forks import Slot, ValidatorIndex
from lean_spec.spec.forks.lstar.containers import (
Expand All @@ -13,8 +14,6 @@
from lean_spec.spec.forks.lstar.spec import LstarSpec
from lean_spec.spec.ssz import Bytes52, Uint64

from .keys import XmssKeyManager

_DEFAULT_GENESIS_TIME = Uint64(0)


Expand Down
28 changes: 14 additions & 14 deletions packages/testing/src/consensus_testing/test_fixtures/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
"""Consensus test fixture format definitions (Pydantic models)."""

from .api_endpoint import ApiEndpointTest
from .base import BaseConsensusFixture
from .fork_choice import ForkChoiceTest
from .gossipsub_handler import GossipsubHandlerTest
from .justifiability import JustifiabilityTest
from .networking_codec import NetworkingCodecTest
from .poseidon_permutation import PoseidonPermutationTest
from .slot_clock import SlotClockTest
from .ssz import SSZTest
from .state_transition import StateTransitionTest
from .sync import SyncTest
from .verify_multi_message_proofs import (
from consensus_testing.test_fixtures.api_endpoint import ApiEndpointTest
from consensus_testing.test_fixtures.base import BaseConsensusFixture
from consensus_testing.test_fixtures.fork_choice import ForkChoiceTest
from consensus_testing.test_fixtures.gossipsub_handler import GossipsubHandlerTest
from consensus_testing.test_fixtures.justifiability import JustifiabilityTest
from consensus_testing.test_fixtures.networking_codec import NetworkingCodecTest
from consensus_testing.test_fixtures.poseidon_permutation import PoseidonPermutationTest
from consensus_testing.test_fixtures.slot_clock import SlotClockTest
from consensus_testing.test_fixtures.ssz import SSZTest
from consensus_testing.test_fixtures.state_transition import StateTransitionTest
from consensus_testing.test_fixtures.sync import SyncTest
from consensus_testing.test_fixtures.verify_multi_message_proofs import (
DropComponentMessageBinding,
IncrementComponentSlot,
RebindComponentToAlternateHeadRoot,
SwapComponentMessageBindings,
SwapComponentParticipantPublicKey,
VerifyMultiMessageProofsTest,
)
from .verify_signatures import VerifySignaturesTest
from .verify_single_message_proofs import (
from consensus_testing.test_fixtures.verify_signatures import VerifySignaturesTest
from consensus_testing.test_fixtures.verify_single_message_proofs import (
IncrementEmittedSlot,
RebindToAlternateHeadRoot,
SwapParticipantPublicKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
from collections.abc import Callable
from typing import Any, ClassVar

from consensus_testing.genesis import build_anchor, generate_pre_state
from consensus_testing.test_fixtures.base import BaseConsensusFixture
from lean_spec.spec.crypto.merkleization import hash_tree_root
from lean_spec.spec.forks import Slot, ValidatorIndex
from lean_spec.spec.forks.lstar import Store
from lean_spec.spec.forks.lstar.containers import AggregatedAttestations, Block, BlockBody, State
from lean_spec.spec.forks.lstar.spec import LstarSpec
from lean_spec.spec.ssz import Bytes32, Uint64

from ..genesis import build_anchor, generate_pre_state
from .base import BaseConsensusFixture

EndpointHandler = Callable[[Store, "ApiEndpointTest"], dict[str, Any]]
"""Uniform signature for all endpoint response builders.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@

from pydantic import Field, model_validator

from consensus_testing.keys import XmssKeyManager
from consensus_testing.test_fixtures.base import BaseConsensusFixture
from consensus_testing.test_types import (
AttestationStep,
BlockStep,
ForkChoiceStep,
GossipAggregatedAttestationStep,
TickStep,
)
from lean_spec.node.chain.clock import SlotClock
from lean_spec.spec.crypto.merkleization import hash_tree_root
from lean_spec.spec.forks import Interval, Slot, ValidatorIndex
Expand All @@ -23,18 +32,6 @@
)
from lean_spec.spec.forks.lstar.spec import LstarSpec

from ..keys import (
XmssKeyManager,
)
from ..test_types import (
AttestationStep,
BlockStep,
ForkChoiceStep,
GossipAggregatedAttestationStep,
TickStep,
)
from .base import BaseConsensusFixture


class ForkChoiceTest(BaseConsensusFixture):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from typing import Any, ClassVar
from unittest.mock import patch

from consensus_testing.test_fixtures.base import BaseConsensusFixture
from lean_spec.node.networking import PeerId
from lean_spec.node.networking.gossipsub.behavior import GossipsubBehavior, PeerState
from lean_spec.node.networking.gossipsub.message import GossipsubMessage
Expand All @@ -29,8 +30,6 @@
)
from lean_spec.node.networking.gossipsub.types import MessageId, Timestamp, TopicId

from .base import BaseConsensusFixture

# Sentinel that satisfies `outbound_stream is not None` checks.
# The patched _send_rpc never touches the stream, so any non-None value works.
_FAKE_STREAM: Any = object()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@

from typing import Any, ClassVar

from consensus_testing.test_fixtures.base import BaseConsensusFixture
from lean_spec.spec.forks import Slot

from .base import BaseConsensusFixture


class JustifiabilityTest(BaseConsensusFixture):
"""Fixture for 3SF-mini justifiability conformance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from typing import Any, ClassVar

from consensus_testing.test_fixtures.base import BaseConsensusFixture
from lean_spec.node.networking.enr.enr import ENR
from lean_spec.node.networking.gossipsub.message import GossipsubMessage
from lean_spec.node.networking.gossipsub.rpc import (
Expand All @@ -27,8 +28,6 @@
from lean_spec.node.snappy import compress, decompress, frame_compress, frame_decompress
from lean_spec.spec.forks import SubnetId

from .base import BaseConsensusFixture


def _to_hex(data: bytes) -> str:
"""Format raw bytes as a 0x-prefixed hex string."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

from typing import Any, ClassVar

from consensus_testing.test_fixtures.base import BaseConsensusFixture
from lean_spec.spec.crypto.koalabear import Fp
from lean_spec.spec.crypto.poseidon import PARAMS_16, PARAMS_24, Poseidon

from .base import BaseConsensusFixture


class PoseidonPermutationTest(BaseConsensusFixture):
"""Fixture for Poseidon permutation conformance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from typing import Any, ClassVar

from consensus_testing.test_fixtures.base import BaseConsensusFixture
from lean_spec.node.chain.clock import SlotClock
from lean_spec.spec.forks import Interval, Slot
from lean_spec.spec.forks.lstar.config import (
Expand All @@ -16,8 +17,6 @@
)
from lean_spec.spec.ssz import Uint64

from .base import BaseConsensusFixture


class SlotClockTest(BaseConsensusFixture):
"""Fixture for slot clock timing conformance.
Expand Down
3 changes: 1 addition & 2 deletions packages/testing/src/consensus_testing/test_fixtures/ssz.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

from pydantic import field_serializer

from consensus_testing.test_fixtures.base import BaseConsensusFixture
from lean_spec.base import CamelModel
from lean_spec.spec.crypto.koalabear import Fp
from lean_spec.spec.crypto.merkleization import hash_tree_root
from lean_spec.spec.ssz.boolean import Boolean
from lean_spec.spec.ssz.ssz_base import SSZType

from .base import BaseConsensusFixture


class SSZTest(BaseConsensusFixture):
"""Fixture for SSZ conformance testing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

from pydantic import ConfigDict, PrivateAttr, field_serializer

from consensus_testing.keys import XmssKeyManager
from consensus_testing.test_fixtures.base import BaseConsensusFixture
from consensus_testing.test_types import AggregatedAttestationSpec, BlockSpec, StateExpectation
from lean_spec.spec.crypto.merkleization import hash_tree_root
from lean_spec.spec.forks import AggregationBits
from lean_spec.spec.forks.lstar.containers import (
Expand All @@ -18,10 +21,6 @@
from lean_spec.spec.forks.lstar.spec import LstarSpec
from lean_spec.spec.ssz import Bytes32

from ..keys import XmssKeyManager
from ..test_types import AggregatedAttestationSpec, BlockSpec, StateExpectation
from .base import BaseConsensusFixture


class StateTransitionTest(BaseConsensusFixture):
"""
Expand Down
5 changes: 2 additions & 3 deletions packages/testing/src/consensus_testing/test_fixtures/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@

from typing import Any, ClassVar

from consensus_testing.genesis import build_anchor, generate_pre_state
from consensus_testing.test_fixtures.base import BaseConsensusFixture
from lean_spec.node.sync.checkpoint_sync import verify_checkpoint_state
from lean_spec.spec.forks import Slot
from lean_spec.spec.forks.lstar.spec import LstarSpec
from lean_spec.spec.ssz import Uint64

from ..genesis import build_anchor, generate_pre_state
from .base import BaseConsensusFixture


class SyncTest(BaseConsensusFixture):
"""Fixture for sync-layer conformance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from pydantic import BaseModel, Field

from consensus_testing.keys import XmssKeyManager
from consensus_testing.test_fixtures.base import BaseConsensusFixture
from lean_spec.spec.crypto.merkleization import hash_tree_root
from lean_spec.spec.crypto.xmss.containers import PublicKey
from lean_spec.spec.forks import (
Expand All @@ -21,9 +23,6 @@
)
from lean_spec.spec.ssz import ByteList512KiB, Bytes32

from ..keys import XmssKeyManager
from .base import BaseConsensusFixture

ALTERNATE_HEAD_ROOT: Bytes32 = Bytes32(b"\xee" * 32)
"""Sentinel head root used by the rebind tamper to bind one component off-target."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

from pydantic import Field

from consensus_testing.keys import XmssKeyManager
from consensus_testing.test_fixtures.base import BaseConsensusFixture
from consensus_testing.test_types import BlockSpec
from lean_spec.spec.crypto.merkleization import hash_tree_root
from lean_spec.spec.forks import AggregationBits, Checkpoint, Slot, ValidatorIndex
from lean_spec.spec.forks.lstar.containers import (
Expand All @@ -19,10 +22,6 @@
from lean_spec.spec.forks.lstar.spec import LstarSpec
from lean_spec.spec.ssz import Boolean, ByteList512KiB, Bytes32

from ..keys import XmssKeyManager
from ..test_types import BlockSpec
from .base import BaseConsensusFixture


class VerifySignaturesTest(BaseConsensusFixture):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from pydantic import BaseModel, Field

from consensus_testing.keys import XmssKeyManager
from consensus_testing.test_fixtures.base import BaseConsensusFixture
from lean_spec.spec.crypto.merkleization import hash_tree_root
from lean_spec.spec.crypto.xmss.containers import PublicKey
from lean_spec.spec.forks import (
Expand All @@ -20,9 +22,6 @@
)
from lean_spec.spec.ssz import ByteList512KiB, Bytes32

from ..keys import XmssKeyManager
from .base import BaseConsensusFixture

ALTERNATE_HEAD_ROOT: Bytes32 = Bytes32(b"\xee" * 32)
"""Sentinel head root used by the rebind tamper to bind the proof off-target."""

Expand Down
20 changes: 13 additions & 7 deletions packages/testing/src/consensus_testing/test_types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
"""Test types for consensus test fixtures."""

from .aggregated_attestation_spec import AggregatedAttestationSpec
from .block_spec import BlockSpec
from .gossip_aggregated_attestation_spec import GossipAggregatedAttestationSpec
from .gossip_attestation_spec import GossipAttestationSpec
from .state_expectation import StateExpectation
from .step_types import (
from consensus_testing.test_types.aggregated_attestation_spec import AggregatedAttestationSpec
from consensus_testing.test_types.block_spec import BlockSpec
from consensus_testing.test_types.gossip_aggregated_attestation_spec import (
GossipAggregatedAttestationSpec,
)
from consensus_testing.test_types.gossip_attestation_spec import GossipAttestationSpec
from consensus_testing.test_types.state_expectation import StateExpectation
from consensus_testing.test_types.step_types import (
AttestationStep,
BaseForkChoiceStep,
BlockStep,
ForkChoiceStep,
GossipAggregatedAttestationStep,
TickStep,
)
from .store_checks import AggregatedAttestationCheck, AttestationCheck, StoreChecks
from consensus_testing.test_types.store_checks import (
AggregatedAttestationCheck,
AttestationCheck,
StoreChecks,
)

__all__ = [
"AggregatedAttestationSpec",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

from consensus_testing.keys import XmssKeyManager
from consensus_testing.test_types.utils import resolve_checkpoint
from lean_spec.base import CamelModel
from lean_spec.spec.forks import AggregationBits, Checkpoint, Slot, ValidatorIndex
from lean_spec.spec.forks.lstar.containers import (
Expand All @@ -14,9 +16,6 @@
)
from lean_spec.spec.ssz import ByteList512KiB, Bytes32

from ..keys import XmssKeyManager
from .utils import resolve_checkpoint


class AggregatedAttestationSpec(CamelModel):
"""
Expand Down
Loading
Loading