2025-12-16 06:55:44 +01:00
|
|
|
use testing_framework_core::scenario::ScenarioBuilder;
|
|
|
|
|
use testing_framework_workflows::ScenarioBuilderExt;
|
|
|
|
|
|
2025-12-18 22:48:45 +01:00
|
|
|
use crate::SnippetResult;
|
|
|
|
|
|
|
|
|
|
pub fn declarative_over_imperative() -> SnippetResult<()> {
|
2025-12-16 06:55:44 +01:00
|
|
|
// Good: declarative
|
|
|
|
|
let _plan = ScenarioBuilder::topology_with(|t| t.network_star().validators(2).executors(1))
|
|
|
|
|
.transactions_with(|txs| {
|
|
|
|
|
txs.rate(5) // 5 transactions per block
|
|
|
|
|
})
|
|
|
|
|
.expect_consensus_liveness()
|
2025-12-18 22:48:45 +01:00
|
|
|
.build()?;
|
2025-12-16 06:55:44 +01:00
|
|
|
|
|
|
|
|
// Bad: imperative (framework doesn't work this way)
|
|
|
|
|
// spawn_validator(); spawn_executor();
|
|
|
|
|
// loop { submit_tx(); check_block(); }
|
2025-12-18 22:48:45 +01:00
|
|
|
|
|
|
|
|
Ok(())
|
2025-12-16 06:55:44 +01:00
|
|
|
}
|