mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-05-01 07:23:07 +00:00
Add topology_with helper and format scenario builder usage
This commit is contained in:
parent
dca7d79393
commit
c0555ca347
@ -43,11 +43,11 @@ async fn run_compose_case(
|
|||||||
"building scenario plan"
|
"building scenario plan"
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut plan = ScenarioBuilder::topology()
|
let mut plan = ScenarioBuilder::topology_with(|t| {
|
||||||
.network_star()
|
t.network_star()
|
||||||
.validators(validators)
|
.validators(validators)
|
||||||
.executors(executors)
|
.executors(executors)
|
||||||
.apply()
|
})
|
||||||
.enable_node_control()
|
.enable_node_control()
|
||||||
.chaos()
|
.chaos()
|
||||||
.restart()
|
.restart()
|
||||||
|
|||||||
@ -39,11 +39,11 @@ async fn run_k8s_case(
|
|||||||
duration_secs = run_duration.as_secs(),
|
duration_secs = run_duration.as_secs(),
|
||||||
"building scenario plan"
|
"building scenario plan"
|
||||||
);
|
);
|
||||||
let mut plan = ScenarioBuilder::topology()
|
let mut plan = ScenarioBuilder::topology_with(|t| {
|
||||||
.network_star()
|
t.network_star()
|
||||||
.validators(validators)
|
.validators(validators)
|
||||||
.executors(executors)
|
.executors(executors)
|
||||||
.apply()
|
})
|
||||||
.wallets(TOTAL_WALLETS)
|
.wallets(TOTAL_WALLETS)
|
||||||
.transactions()
|
.transactions()
|
||||||
.rate(MIXED_TXS_PER_BLOCK)
|
.rate(MIXED_TXS_PER_BLOCK)
|
||||||
|
|||||||
@ -47,11 +47,11 @@ async fn run_local_case(
|
|||||||
duration_secs = run_duration.as_secs(),
|
duration_secs = run_duration.as_secs(),
|
||||||
"building scenario plan"
|
"building scenario plan"
|
||||||
);
|
);
|
||||||
let mut plan = ScenarioBuilder::topology()
|
let mut plan = ScenarioBuilder::topology_with(|t| {
|
||||||
.network_star()
|
t.network_star()
|
||||||
.validators(validators)
|
.validators(validators)
|
||||||
.executors(executors)
|
.executors(executors)
|
||||||
.apply()
|
})
|
||||||
.wallets(TOTAL_WALLETS)
|
.wallets(TOTAL_WALLETS)
|
||||||
.transactions()
|
.transactions()
|
||||||
.rate(MIXED_TXS_PER_BLOCK)
|
.rate(MIXED_TXS_PER_BLOCK)
|
||||||
|
|||||||
@ -115,6 +115,15 @@ impl<Caps: Default> Builder<Caps> {
|
|||||||
pub fn topology() -> TopologyConfigurator<Caps> {
|
pub fn topology() -> TopologyConfigurator<Caps> {
|
||||||
TopologyConfigurator::new(Self::new(TopologyBuilder::new(TopologyConfig::empty())))
|
TopologyConfigurator::new(Self::new(TopologyBuilder::new(TopologyConfig::empty())))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Configure topology via a closure and return the scenario builder.
|
||||||
|
#[must_use]
|
||||||
|
pub fn topology_with(
|
||||||
|
f: impl FnOnce(TopologyConfigurator<Caps>) -> TopologyConfigurator<Caps>,
|
||||||
|
) -> Builder<Caps> {
|
||||||
|
let configurator = Self::topology();
|
||||||
|
f(configurator).apply()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Caps> Builder<Caps> {
|
impl<Caps> Builder<Caps> {
|
||||||
|
|||||||
@ -302,11 +302,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cfgsync_prebuilt_configs_preserve_genesis() {
|
fn cfgsync_prebuilt_configs_preserve_genesis() {
|
||||||
let scenario = ScenarioBuilder::topology()
|
let scenario = ScenarioBuilder::topology_with(|t| t.validators(1).executors(1)).build();
|
||||||
.validators(1)
|
|
||||||
.executors(1)
|
|
||||||
.apply()
|
|
||||||
.build();
|
|
||||||
let topology = scenario.topology().clone();
|
let topology = scenario.topology().clone();
|
||||||
let hosts = hosts_from_topology(&topology);
|
let hosts = hosts_from_topology(&topology);
|
||||||
let tracing_settings = tracing_settings(&topology);
|
let tracing_settings = tracing_settings(&topology);
|
||||||
@ -358,11 +354,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cfgsync_genesis_proofs_verify_against_ledger() {
|
fn cfgsync_genesis_proofs_verify_against_ledger() {
|
||||||
let scenario = ScenarioBuilder::topology()
|
let scenario = ScenarioBuilder::topology_with(|t| t.validators(1).executors(1)).build();
|
||||||
.validators(1)
|
|
||||||
.executors(1)
|
|
||||||
.apply()
|
|
||||||
.build();
|
|
||||||
let topology = scenario.topology().clone();
|
let topology = scenario.topology().clone();
|
||||||
let hosts = hosts_from_topology(&topology);
|
let hosts = hosts_from_topology(&topology);
|
||||||
let tracing_settings = tracing_settings(&topology);
|
let tracing_settings = tracing_settings(&topology);
|
||||||
@ -398,11 +390,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cfgsync_docker_overrides_produce_valid_genesis() {
|
fn cfgsync_docker_overrides_produce_valid_genesis() {
|
||||||
let scenario = ScenarioBuilder::topology()
|
let scenario = ScenarioBuilder::topology_with(|t| t.validators(1).executors(1)).build();
|
||||||
.validators(1)
|
|
||||||
.executors(1)
|
|
||||||
.apply()
|
|
||||||
.build();
|
|
||||||
let topology = scenario.topology().clone();
|
let topology = scenario.topology().clone();
|
||||||
let tracing_settings = tracing_settings(&topology);
|
let tracing_settings = tracing_settings(&topology);
|
||||||
let hosts = docker_style_hosts(&topology);
|
let hosts = docker_style_hosts(&topology);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user