#![cfg(feature = "ef_tests")] use ef_tests::*; use std::path::PathBuf; use types::*; // Check that the config from the Eth2.0 spec tests matches our minimal/mainnet config. fn config_test() { let config_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("eth2.0-spec-tests") .join("tests") .join(E::name()) .join("config.yaml"); let yaml_config = YamlConfig::from_file(&config_path).expect("config file loads OK"); let spec = E::default_spec(); let yaml_from_spec = YamlConfig::from_spec::(&spec); assert_eq!(yaml_config.apply_to_chain_spec::(&spec), Some(spec)); assert_eq!(yaml_from_spec, yaml_config); } #[test] fn mainnet_config_ok() { config_test::(); } #[test] fn minimal_config_ok() { config_test::(); } #[test] fn shuffling() { ShufflingHandler::::run(); ShufflingHandler::::run(); } #[test] fn operations_deposit() { OperationsHandler::::run(); OperationsHandler::::run(); } #[test] fn operations_exit() { OperationsHandler::::run(); OperationsHandler::::run(); } #[test] fn operations_proposer_slashing() { OperationsHandler::::run(); OperationsHandler::::run(); } #[test] fn operations_attester_slashing() { OperationsHandler::>::run(); OperationsHandler::>::run(); } #[test] fn operations_attestation() { OperationsHandler::>::run(); OperationsHandler::>::run(); } #[test] fn operations_block_header() { OperationsHandler::>::run(); OperationsHandler::>::run(); } #[test] fn sanity_blocks() { SanityBlocksHandler::::run(); SanityBlocksHandler::::run(); } #[test] fn sanity_slots() { SanitySlotsHandler::::run(); SanitySlotsHandler::::run(); } #[test] #[cfg(not(feature = "fake_crypto"))] fn bls_aggregate() { BlsAggregateSigsHandler::run(); } #[test] #[cfg(not(feature = "fake_crypto"))] fn bls_sign() { BlsSignMsgHandler::run(); } #[test] #[cfg(not(feature = "fake_crypto"))] fn bls_verify() { BlsVerifyMsgHandler::run(); } #[test] #[cfg(not(feature = "fake_crypto"))] fn bls_aggregate_verify() { BlsAggregateVerifyHandler::run(); } #[test] #[cfg(not(feature = "fake_crypto"))] fn bls_fast_aggregate_verify() { BlsFastAggregateVerifyHandler::run(); } #[cfg(feature = "fake_crypto")] macro_rules! ssz_static_test { // Non-tree hash caching ($test_name:ident, $typ:ident$(<$generics:tt>)?) => { ssz_static_test!($test_name, SszStaticHandler, $typ$(<$generics>)?); }; // Generic ($test_name:ident, $handler:ident, $typ:ident<_>) => { ssz_static_test!( $test_name, $handler, { ($typ, MinimalEthSpec), ($typ, MainnetEthSpec) } ); }; // Non-generic ($test_name:ident, $handler:ident, $typ:ident) => { ssz_static_test!( $test_name, $handler, { ($typ, MinimalEthSpec), ($typ, MainnetEthSpec) } ); }; // Base case ($test_name:ident, $handler:ident, { $(($($typ:ty),+)),+ }) => { #[test] fn $test_name() { $( $handler::<$($typ),+>::run(); )+ } }; } #[cfg(feature = "fake_crypto")] mod ssz_static { use ef_tests::{Handler, SszStaticHandler, SszStaticTHCHandler}; use types::*; ssz_static_test!(attestation, Attestation<_>); ssz_static_test!(attestation_data, AttestationData); ssz_static_test!(attester_slashing, AttesterSlashing<_>); ssz_static_test!(beacon_block, BeaconBlock<_>); ssz_static_test!(beacon_block_body, BeaconBlockBody<_>); ssz_static_test!(beacon_block_header, BeaconBlockHeader); ssz_static_test!( beacon_state, SszStaticTHCHandler, { (BeaconState, BeaconTreeHashCache, MinimalEthSpec), (BeaconState, BeaconTreeHashCache, MainnetEthSpec) } ); ssz_static_test!(checkpoint, Checkpoint); ssz_static_test!(deposit, Deposit); ssz_static_test!(deposit_data, DepositData); ssz_static_test!(eth1_data, Eth1Data); ssz_static_test!(fork, Fork); ssz_static_test!(historical_batch, HistoricalBatch<_>); ssz_static_test!(indexed_attestation, IndexedAttestation<_>); ssz_static_test!(pending_attestation, PendingAttestation<_>); ssz_static_test!(proposer_slashing, ProposerSlashing); ssz_static_test!(validator, Validator); ssz_static_test!(voluntary_exit, VoluntaryExit); } #[test] fn ssz_generic() { SszGenericHandler::::run(); SszGenericHandler::::run(); SszGenericHandler::::run(); SszGenericHandler::::run(); SszGenericHandler::::run(); SszGenericHandler::::run(); } #[test] fn epoch_processing_justification_and_finalization() { EpochProcessingHandler::::run(); EpochProcessingHandler::::run(); } #[test] fn epoch_processing_rewards_and_penalties() { EpochProcessingHandler::::run(); // Note: there are no reward and penalty tests for mainnet yet } #[test] fn epoch_processing_registry_updates() { EpochProcessingHandler::::run(); EpochProcessingHandler::::run(); } #[test] fn epoch_processing_slashings() { EpochProcessingHandler::::run(); EpochProcessingHandler::::run(); } #[test] fn epoch_processing_final_updates() { EpochProcessingHandler::::run(); EpochProcessingHandler::::run(); } #[test] fn genesis_initialization() { GenesisInitializationHandler::::run(); } #[test] fn genesis_validity() { GenesisValidityHandler::::run(); // Note: there are no genesis validity tests for mainnet }