2020-04-02 07:47:00 +00:00
|
|
|
#![cfg(test)]
|
|
|
|
|
|
|
|
use environment::EnvironmentBuilder;
|
2020-12-08 05:41:10 +00:00
|
|
|
use eth2_network_config::{Eth2NetworkConfig, DEFAULT_HARDCODED_NETWORK};
|
2020-04-02 07:47:00 +00:00
|
|
|
use std::path::PathBuf;
|
2021-07-09 06:15:32 +00:00
|
|
|
use types::{Config, MainnetEthSpec};
|
2020-04-02 07:47:00 +00:00
|
|
|
|
2021-07-09 06:15:32 +00:00
|
|
|
fn builder() -> EnvironmentBuilder<MainnetEthSpec> {
|
|
|
|
EnvironmentBuilder::mainnet()
|
2020-11-28 05:30:57 +00:00
|
|
|
.multi_threaded_tokio_runtime()
|
2020-04-02 07:47:00 +00:00
|
|
|
.expect("should set runtime")
|
|
|
|
.null_logger()
|
|
|
|
.expect("should set logger")
|
|
|
|
}
|
|
|
|
|
2020-12-08 05:41:10 +00:00
|
|
|
fn eth2_network_config() -> Option<Eth2NetworkConfig> {
|
|
|
|
Eth2NetworkConfig::constant(DEFAULT_HARDCODED_NETWORK).expect("should decode mainnet params")
|
2020-04-02 07:47:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mod setup_eth2_config {
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn update_spec_with_yaml_config() {
|
2020-12-08 05:41:10 +00:00
|
|
|
if let Some(mut eth2_network_config) = eth2_network_config() {
|
2021-07-09 06:15:32 +00:00
|
|
|
let testnet_dir = PathBuf::from("./tests/testnet_dir");
|
|
|
|
let config = testnet_dir.join("config.yaml");
|
2020-06-03 03:34:01 +00:00
|
|
|
|
2021-07-09 06:15:32 +00:00
|
|
|
eth2_network_config.config =
|
|
|
|
Config::from_file(config.as_path()).expect("should load yaml config");
|
2020-06-03 03:34:01 +00:00
|
|
|
|
|
|
|
let environment = builder()
|
2020-12-08 05:41:10 +00:00
|
|
|
.eth2_network_config(eth2_network_config)
|
2020-06-03 03:34:01 +00:00
|
|
|
.expect("should setup eth2_config")
|
|
|
|
.build()
|
|
|
|
.expect("should build environment");
|
|
|
|
|
|
|
|
assert_eq!(
|
2021-07-09 06:15:32 +00:00
|
|
|
environment
|
|
|
|
.eth2_config
|
|
|
|
.spec
|
|
|
|
.min_genesis_active_validator_count,
|
|
|
|
100000 // see testnet_dir/config.yaml
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
environment.eth2_config.spec.inactivity_score_bias,
|
|
|
|
2 // see testnet_dir/config.yaml
|
2020-06-03 03:34:01 +00:00
|
|
|
);
|
|
|
|
}
|
2020-04-02 07:47:00 +00:00
|
|
|
}
|
|
|
|
}
|