Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup beacon test config #1102

Merged
merged 2 commits into from
Jan 10, 2024
Merged
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
29 changes: 5 additions & 24 deletions parachain/pallets/ethereum-beacon-client/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ use sp_core::H256;
use sp_runtime::traits::{BlakeTwo256, IdentityLookup};
use std::{fs::File, path::PathBuf};

#[cfg(feature = "beacon-spec-minimal")]
Copy link
Collaborator

@vgeddes vgeddes Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: add a new line after the imports and before the definition of SPEC

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

16f73df :)

const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";

fn load_fixture<T>(basename: String) -> Result<T, serde_json::Error>
where
T: for<'de> serde::Deserialize<'de>,
Expand All @@ -21,60 +26,36 @@ where
}

pub fn load_execution_header_update_fixture() -> primitives::ExecutionHeaderUpdate {
#[cfg(feature = "beacon-spec-minimal")]
const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";
let basename = format!("execution-header-update.{}.json", SPEC);
load_fixture(basename).unwrap()
}

pub fn load_checkpoint_update_fixture(
) -> primitives::CheckpointUpdate<{ config::SYNC_COMMITTEE_SIZE }> {
#[cfg(feature = "beacon-spec-minimal")]
const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";
let basename = format!("initial-checkpoint.{}.json", SPEC);
load_fixture(basename).unwrap()
}

pub fn load_sync_committee_update_fixture(
) -> primitives::Update<{ config::SYNC_COMMITTEE_SIZE }, { config::SYNC_COMMITTEE_BITS_SIZE }> {
#[cfg(feature = "beacon-spec-minimal")]
const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";
let basename = format!("sync-committee-update.{}.json", SPEC);
load_fixture(basename).unwrap()
}

pub fn load_finalized_header_update_fixture(
) -> primitives::Update<{ config::SYNC_COMMITTEE_SIZE }, { config::SYNC_COMMITTEE_BITS_SIZE }> {
#[cfg(feature = "beacon-spec-minimal")]
const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";
let basename = format!("finalized-header-update.{}.json", SPEC);
load_fixture(basename).unwrap()
}

pub fn load_next_sync_committee_update_fixture(
) -> primitives::Update<{ config::SYNC_COMMITTEE_SIZE }, { config::SYNC_COMMITTEE_BITS_SIZE }> {
#[cfg(feature = "beacon-spec-minimal")]
const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";
let basename = format!("next-sync-committee-update.{}.json", SPEC);
load_fixture(basename).unwrap()
}

pub fn load_next_finalized_header_update_fixture(
) -> primitives::Update<{ config::SYNC_COMMITTEE_SIZE }, { config::SYNC_COMMITTEE_BITS_SIZE }> {
#[cfg(feature = "beacon-spec-minimal")]
const SPEC: &str = "minimal";
#[cfg(not(feature = "beacon-spec-minimal"))]
const SPEC: &str = "mainnet";
let basename = format!("next-finalized-header-update.{}.json", SPEC);
load_fixture(basename).unwrap()
}
Expand Down
Loading