mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-01-02 13:23:13 +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"
|
||||
);
|
||||
|
||||
let mut plan = ScenarioBuilder::topology()
|
||||
.network_star()
|
||||
.validators(validators)
|
||||
.executors(executors)
|
||||
.apply()
|
||||
let mut plan = ScenarioBuilder::topology_with(|t| {
|
||||
t.network_star()
|
||||
.validators(validators)
|
||||
.executors(executors)
|
||||
})
|
||||
.enable_node_control()
|
||||
.chaos()
|
||||
.restart()
|
||||
|
||||
@ -39,11 +39,11 @@ async fn run_k8s_case(
|
||||
duration_secs = run_duration.as_secs(),
|
||||
"building scenario plan"
|
||||
);
|
||||
let mut plan = ScenarioBuilder::topology()
|
||||
.network_star()
|
||||
.validators(validators)
|
||||
.executors(executors)
|
||||
.apply()
|
||||
let mut plan = ScenarioBuilder::topology_with(|t| {
|
||||
t.network_star()
|
||||
.validators(validators)
|
||||
.executors(executors)
|
||||
})
|
||||
.wallets(TOTAL_WALLETS)
|
||||
.transactions()
|
||||
.rate(MIXED_TXS_PER_BLOCK)
|
||||
|
||||
@ -47,11 +47,11 @@ async fn run_local_case(
|
||||
duration_secs = run_duration.as_secs(),
|
||||
"building scenario plan"
|
||||
);
|
||||
let mut plan = ScenarioBuilder::topology()
|
||||
.network_star()
|
||||
.validators(validators)
|
||||
.executors(executors)
|
||||
.apply()
|
||||
let mut plan = ScenarioBuilder::topology_with(|t| {
|
||||
t.network_star()
|
||||
.validators(validators)
|
||||
.executors(executors)
|
||||
})
|
||||
.wallets(TOTAL_WALLETS)
|
||||
.transactions()
|
||||
.rate(MIXED_TXS_PER_BLOCK)
|
||||
|
||||
@ -115,6 +115,15 @@ impl<Caps: Default> Builder<Caps> {
|
||||
pub fn topology() -> TopologyConfigurator<Caps> {
|
||||
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> {
|
||||
|
||||
@ -302,11 +302,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn cfgsync_prebuilt_configs_preserve_genesis() {
|
||||
let scenario = ScenarioBuilder::topology()
|
||||
.validators(1)
|
||||
.executors(1)
|
||||
.apply()
|
||||
.build();
|
||||
let scenario = ScenarioBuilder::topology_with(|t| t.validators(1).executors(1)).build();
|
||||
let topology = scenario.topology().clone();
|
||||
let hosts = hosts_from_topology(&topology);
|
||||
let tracing_settings = tracing_settings(&topology);
|
||||
@ -358,11 +354,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn cfgsync_genesis_proofs_verify_against_ledger() {
|
||||
let scenario = ScenarioBuilder::topology()
|
||||
.validators(1)
|
||||
.executors(1)
|
||||
.apply()
|
||||
.build();
|
||||
let scenario = ScenarioBuilder::topology_with(|t| t.validators(1).executors(1)).build();
|
||||
let topology = scenario.topology().clone();
|
||||
let hosts = hosts_from_topology(&topology);
|
||||
let tracing_settings = tracing_settings(&topology);
|
||||
@ -398,11 +390,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn cfgsync_docker_overrides_produce_valid_genesis() {
|
||||
let scenario = ScenarioBuilder::topology()
|
||||
.validators(1)
|
||||
.executors(1)
|
||||
.apply()
|
||||
.build();
|
||||
let scenario = ScenarioBuilder::topology_with(|t| t.validators(1).executors(1)).build();
|
||||
let topology = scenario.topology().clone();
|
||||
let tracing_settings = tracing_settings(&topology);
|
||||
let hosts = docker_style_hosts(&topology);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user