Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Tests Refactor (paritytech#670)
Browse files Browse the repository at this point in the history
* Move tests to one file.

* Progress on test refactor

* Fixed tests

* Finish test cleanup.

* Tests refactor
  • Loading branch information
claravanstaden authored Aug 15, 2022
1 parent 664e41c commit c4a0974
Show file tree
Hide file tree
Showing 17 changed files with 2,967 additions and 6,912 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub const SLOTS_PER_EPOCH: u64 = 32;
pub const EPOCHS_PER_SYNC_COMMITTEE_PERIOD: u64 = 256;
pub const SYNC_COMMITTEE_SIZE: usize = 512;
pub const SYNC_COMMITTEE_SIZE: usize = 512;
pub const IS_MINIMAL: bool = false;
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub const SLOTS_PER_EPOCH: u64 = 8;
pub const EPOCHS_PER_SYNC_COMMITTEE_PERIOD: u64 = 8;
pub const SYNC_COMMITTEE_SIZE: usize = 32;
pub const SYNC_COMMITTEE_SIZE: usize = 32;
pub const IS_MINIMAL: bool = true;
47 changes: 2 additions & 45 deletions parachain/pallets/ethereum-beacon-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,59 +9,16 @@ mod mock;
mod tests;
mod ssz;

use codec::{Decode, Encode};
use frame_support::{dispatch::DispatchResult, log, transactional};
use frame_system::ensure_signed;
use scale_info::TypeInfo;
use sp_core::H256;
use sp_io::hashing::sha2_256;
use sp_runtime::RuntimeDebug;
use sp_std::prelude::*;
use snowbridge_beacon_primitives::{SyncCommittee, BeaconHeader, SyncAggregate, ForkData, Root, Domain, PublicKey, SigningData, ExecutionHeader, BeaconBlock, ProofBranch, ForkVersion};
use snowbridge_beacon_primitives::{SyncCommittee, BeaconHeader, ForkData, Root, Domain, PublicKey, SigningData, ExecutionHeader,
ProofBranch, ForkVersion, SyncCommitteePeriodUpdate, FinalizedHeaderUpdate, InitialSync, BlockUpdate};
use snowbridge_core::{Message, Verifier};
use crate::merkleization::get_sync_committee_bits;

#[derive(Clone, Default, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub struct InitialSync {
pub header: BeaconHeader,
pub current_sync_committee: SyncCommittee,
pub current_sync_committee_branch: ProofBranch,
pub validators_root: Root,
}

#[derive(Clone, Default, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)]
pub struct SyncCommitteePeriodUpdate {
pub attested_header: BeaconHeader,
pub next_sync_committee: SyncCommittee,
pub next_sync_committee_branch: ProofBranch,
pub finalized_header: BeaconHeader,
pub finality_branch: ProofBranch,
pub sync_aggregate: SyncAggregate,
pub fork_version: ForkVersion,
pub sync_committee_period: u64,
}

#[derive(Clone, Default, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)]
pub struct FinalizedHeaderUpdate {
pub attested_header: BeaconHeader,
pub finalized_header: BeaconHeader,
pub finality_branch: ProofBranch,
pub sync_aggregate: SyncAggregate,
pub fork_version: ForkVersion,
}

#[derive(Clone, Default, Encode, Decode, PartialEq, RuntimeDebug, TypeInfo)]
pub struct BlockUpdate {
pub block: BeaconBlock,
// // Only used for debugging purposes, to compare the hash tree
// root of the block body to the body hash retrieved from the API.
// Can be removed later.
pub block_body_root: H256,
pub sync_aggregate: SyncAggregate,
pub fork_version: ForkVersion,
}

pub use pallet::*;

#[frame_support::pallet]
Expand Down
Loading

0 comments on commit c4a0974

Please sign in to comment.