2020-04-02 07:47:00 +00:00
|
|
|
#![cfg(test)]
|
|
|
|
|
|
|
|
use environment::EnvironmentBuilder;
|
2020-11-23 23:54:03 +00:00
|
|
|
use eth2_testnet_config::{Eth2TestnetConfig, DEFAULT_HARDCODED_TESTNET};
|
2020-04-02 07:47:00 +00:00
|
|
|
use std::path::PathBuf;
|
2020-10-28 22:19:38 +00:00
|
|
|
use types::{V012LegacyEthSpec, YamlConfig};
|
2020-04-02 07:47:00 +00:00
|
|
|
|
2020-10-28 22:19:38 +00:00
|
|
|
fn builder() -> EnvironmentBuilder<V012LegacyEthSpec> {
|
|
|
|
EnvironmentBuilder::v012_legacy()
|
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-10-28 22:19:38 +00:00
|
|
|
fn eth2_testnet_config() -> Option<Eth2TestnetConfig> {
|
2020-11-23 23:54:03 +00:00
|
|
|
Eth2TestnetConfig::constant(DEFAULT_HARDCODED_TESTNET).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-06-03 03:34:01 +00:00
|
|
|
if let Some(mut eth2_testnet_config) = eth2_testnet_config() {
|
|
|
|
let config_yaml = PathBuf::from("./tests/testnet_dir/config.yaml");
|
|
|
|
|
|
|
|
eth2_testnet_config.yaml_config = Some(
|
|
|
|
YamlConfig::from_file(config_yaml.as_path()).expect("should load yaml config"),
|
|
|
|
);
|
|
|
|
|
|
|
|
let environment = builder()
|
|
|
|
.eth2_testnet_config(eth2_testnet_config)
|
|
|
|
.expect("should setup eth2_config")
|
|
|
|
.build()
|
|
|
|
.expect("should build environment");
|
|
|
|
|
|
|
|
assert_eq!(
|
2020-09-26 01:58:29 +00:00
|
|
|
environment.eth2_config.spec.max_committees_per_slot,
|
|
|
|
128 // see testnet_dir/config.yaml
|
2020-06-03 03:34:01 +00:00
|
|
|
);
|
|
|
|
}
|
2020-04-02 07:47:00 +00:00
|
|
|
}
|
|
|
|
}
|