Skip to content

Commit

Permalink
update beacon api to 2.3.0 (#2616)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolovim authored and Paul Robinson committed Sep 8, 2022
1 parent dbef96a commit 6158844
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 43 deletions.
4 changes: 2 additions & 2 deletions docs/web3.beacon.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Eth 2.0 Beacon API
=======================
Beacon API
==========

.. warning:: This API Is experimental. Client support is incomplete and the API itself is still evolving.

Expand Down
1 change: 1 addition & 0 deletions newsfragments/2616.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update Beacon API to v2.3.0
68 changes: 34 additions & 34 deletions tests/beacon/test_beacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,151 +15,151 @@ def beacon():
# Beacon endpoint tests:


def test_eth2_beacon_get_genesis(beacon):
def test_cl_beacon_get_genesis(beacon):
response = beacon.get_genesis()
assert response is not None


def test_eth2_beacon_get_hash_root(beacon):
def test_cl_beacon_get_hash_root(beacon):
response = beacon.get_hash_root()
assert response is not None


def test_eth2_beacon_get_fork_data(beacon):
def test_cl_beacon_get_fork_data(beacon):
response = beacon.get_fork_data()
assert response is not None


def test_eth2_beacon_get_finality_checkpoint(beacon):
def test_cl_beacon_get_finality_checkpoint(beacon):
response = beacon.get_finality_checkpoint()
assert response is not None


def test_eth2_beacon_get_validators(beacon):
def test_cl_beacon_get_validators(beacon):
response = beacon.get_validators()
assert response is not None


def test_eth2_beacon_get_validator(beacon):
pyrmont_validator_pub_key = "0xa09c261fc2b44badc0059b6eeb8e6935f2b795f15dad32449afeec3bc635ef0ae92fe0bab5edba31aebfde1947e2acf5" # noqa: E501
response = beacon.get_validator(pyrmont_validator_pub_key)
def test_cl_beacon_get_validator(beacon):
sepolia_validator_pub_key = "0xa9f6b6b04e36850d2dbbc390a9614013da239375f105b0f3738138431f0a3a8c685445f6c518e0b0e72fb3244ddc0d9e" # noqa: E501
response = beacon.get_validator(sepolia_validator_pub_key)
assert response is not None


def test_eth2_beacon_get_validator_balances(beacon):
def test_cl_beacon_get_validator_balances(beacon):
response = beacon.get_validator_balances()
assert response is not None


def test_eth2_beacon_get_epoch_committees(beacon):
def test_cl_beacon_get_epoch_committees(beacon):
response = beacon.get_epoch_committees()
assert response is not None


def test_eth2_beacon_get_block_headers(beacon):
def test_cl_beacon_get_block_headers(beacon):
response = beacon.get_block_headers()
assert response is not None


def test_eth2_beacon_get_block_header(beacon):
response = beacon.get_block_header("123")
def test_cl_beacon_get_block_header(beacon):
response = beacon.get_block_header("head")
assert response is not None


def test_eth2_beacon_get_block(beacon):
response = beacon.get_block("123")
def test_cl_beacon_get_block(beacon):
response = beacon.get_block("head")
assert response is not None


def test_eth2_beacon_get_block_root(beacon):
response = beacon.get_block_root("123")
def test_cl_beacon_get_block_root(beacon):
response = beacon.get_block_root("head")
assert response is not None


def test_eth2_beacon_get_block_attestations(beacon):
response = beacon.get_block_attestations("123")
def test_cl_beacon_get_block_attestations(beacon):
response = beacon.get_block_attestations("head")
assert response is not None


def test_eth2_beacon_get_attestations(beacon):
def test_cl_beacon_get_attestations(beacon):
response = beacon.get_attestations()
assert response is not None


def test_eth2_beacon_get_attester_slashings(beacon):
def test_cl_beacon_get_attester_slashings(beacon):
response = beacon.get_attester_slashings()
assert response is not None


def test_eth2_beacon_get_proposer_slashings(beacon):
def test_cl_beacon_get_proposer_slashings(beacon):
response = beacon.get_proposer_slashings()
assert response is not None


def test_eth2_beacon_get_voluntary_exits(beacon):
def test_cl_beacon_get_voluntary_exits(beacon):
response = beacon.get_voluntary_exits()
assert response is not None


# Config endpoint tests:


def test_eth2_config_get_fork_schedule(beacon):
def test_cl_config_get_fork_schedule(beacon):
response = beacon.get_fork_schedule()
assert response is not None


def test_eth2_config_get_spec(beacon):
def test_cl_config_get_spec(beacon):
response = beacon.get_spec()
assert response is not None


def test_eth2_config_get_deposit_contract(beacon):
def test_cl_config_get_deposit_contract(beacon):
response = beacon.get_deposit_contract()
assert response is not None


# Debug endpoint tests:


def test_eth2_debug_get_beacon_state(beacon):
def test_cl_debug_get_beacon_state(beacon):
response = beacon.get_beacon_state()
assert response is not None


def test_eth2_debug_get_beacon_heads(beacon):
def test_cl_debug_get_beacon_heads(beacon):
response = beacon.get_beacon_heads()
assert response is not None


# Node endpoint tests:


def test_eth2_node_get_node_identity(beacon):
def test_cl_node_get_node_identity(beacon):
response = beacon.get_node_identity()
assert response is not None


def test_eth2_node_get_peers(beacon):
def test_cl_node_get_peers(beacon):
response = beacon.get_peers()
assert response is not None


def test_eth2_node_get_peer(beacon):
def test_cl_node_get_peer(beacon):
response = beacon.get_peer("")
assert response is not None


def test_eth2_node_get_health(beacon):
def test_cl_node_get_health(beacon):
response = beacon.get_health()
assert response <= 206


def test_eth2_node_get_version(beacon):
def test_cl_node_get_version(beacon):
response = beacon.get_version()
assert response is not None


def test_eth2_node_get_syncing(beacon):
def test_cl_node_get_syncing(beacon):
response = beacon.get_syncing()
assert response is not None
6 changes: 0 additions & 6 deletions web3/beacon/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
import warnings
from .main import Beacon # noqa: F401

warnings.warn(
"Beacon node APIs are experimental and may not be "
"implemented consistently by all clients.",
)
2 changes: 1 addition & 1 deletion web3/beacon/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def get_block_header(self, block_id: str) -> Dict[str, Any]:
return self._make_get_request(endpoint)

def get_block(self, block_id: str) -> Dict[str, Any]:
endpoint = f"/eth/v1/beacon/blocks/{block_id}"
endpoint = f"/eth/v2/beacon/blocks/{block_id}"
return self._make_get_request(endpoint)

def get_block_root(self, block_id: str) -> Dict[str, Any]:
Expand Down

0 comments on commit 6158844

Please sign in to comment.