make tests work for all forks

This commit is contained in:
realbigsean
2023-05-02 10:00:07 -04:00
parent 93bcd6281c
commit 8edefb7e0d
7 changed files with 847 additions and 677 deletions

View File

@@ -118,6 +118,20 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run operation_pool tests for all known forks - name: Run operation_pool tests for all known forks
run: make test-op-pool run: make test-op-pool
network-minimal-tests:
name: network-minimal-tests
runs-on: ubuntu-latest
needs: cargo-fmt
steps:
- uses: actions/checkout@v3
- name: Get latest version of stable Rust
run: rustup update stable
- name: Install Protoc
uses: arduino/setup-protoc@e52d9eb8f7b63115df1ac544a1376fdbf5a39612
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Run network tests for all known forks using the minimal spec
run: make test-network-minimal
slasher-tests: slasher-tests:
name: slasher-tests name: slasher-tests
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -143,6 +143,13 @@ test-op-pool-%:
--features 'beacon_chain/fork_from_env'\ --features 'beacon_chain/fork_from_env'\
-p operation_pool -p operation_pool
test-network-minimal: $(patsubst %,test-network-minimal-%,$(FORKS))
test-network-minimal-%:
env FORK_NAME=$* cargo test --release \
--features 'fork_from_env,spec-minimal'\
-p network
# Run the tests in the `slasher` crate for all supported database backends. # Run the tests in the `slasher` crate for all supported database backends.
test-slasher: test-slasher:
cargo test --release -p slasher --features mdbx cargo test --release -p slasher --features mdbx

View File

@@ -61,7 +61,7 @@ use types::{typenum::U4294967296, *};
// 4th September 2019 // 4th September 2019
pub const HARNESS_GENESIS_TIME: u64 = 1_567_552_690; pub const HARNESS_GENESIS_TIME: u64 = 1_567_552_690;
// Environment variable to read if `fork_from_env` feature is enabled. // Environment variable to read if `fork_from_env` feature is enabled.
const FORK_NAME_ENV_VAR: &str = "FORK_NAME"; pub const FORK_NAME_ENV_VAR: &str = "FORK_NAME";
// Default target aggregators to set during testing, this ensures an aggregator at each slot. // Default target aggregators to set during testing, this ensures an aggregator at each slot.
// //

View File

@@ -3,7 +3,10 @@
//! determines whether attestations should be aggregated and/or passed to the beacon node. //! determines whether attestations should be aggregated and/or passed to the beacon node.
use super::SubnetServiceMessage; use super::SubnetServiceMessage;
#[cfg(any(test, feature = "deterministic_long_lived_attnets"))] #[cfg(any(
all(test, feature = "spec-mainnet"),
feature = "deterministic_long_lived_attnets"
))]
use std::collections::HashSet; use std::collections::HashSet;
use std::collections::{HashMap, VecDeque}; use std::collections::{HashMap, VecDeque};
use std::pin::Pin; use std::pin::Pin;
@@ -201,7 +204,7 @@ impl<T: BeaconChainTypes> AttestationService<T> {
} }
/// Return count of all currently subscribed subnets (long-lived **and** short-lived). /// Return count of all currently subscribed subnets (long-lived **and** short-lived).
#[cfg(test)] #[cfg(all(test, feature = "spec-mainnet"))]
pub fn subscription_count(&self) -> usize { pub fn subscription_count(&self) -> usize {
if self.subscribe_all_subnets { if self.subscribe_all_subnets {
self.beacon_chain.spec.attestation_subnet_count as usize self.beacon_chain.spec.attestation_subnet_count as usize
@@ -225,7 +228,7 @@ impl<T: BeaconChainTypes> AttestationService<T> {
} }
/// Returns whether we are subscribed to a subnet for testing purposes. /// Returns whether we are subscribed to a subnet for testing purposes.
#[cfg(test)] #[cfg(all(test, feature = "spec-mainnet"))]
pub(crate) fn is_subscribed( pub(crate) fn is_subscribed(
&self, &self,
subnet_id: &SubnetId, subnet_id: &SubnetId,

View File

@@ -87,7 +87,7 @@ impl<T: BeaconChainTypes> SyncCommitteeService<T> {
} }
/// Return count of all currently subscribed subnets. /// Return count of all currently subscribed subnets.
#[cfg(test)] #[cfg(all(test, feature = "spec-mainnet"))]
pub fn subscription_count(&self) -> usize { pub fn subscription_count(&self) -> usize {
use types::consts::altair::SYNC_COMMITTEE_SUBNET_COUNT; use types::consts::altair::SYNC_COMMITTEE_SUBNET_COUNT;
if self.subscribe_all_subnets { if self.subscribe_all_subnets {

View File

@@ -1,3 +1,4 @@
#![cfg(feature = "spec-mainnet")]
use super::*; use super::*;
use beacon_chain::{ use beacon_chain::{
builder::{BeaconChainBuilder, Witness}, builder::{BeaconChainBuilder, Witness},

File diff suppressed because it is too large Load Diff