1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0

use crate::generate_traffic;
use forge::{NetworkContext, NetworkTest, Result, Test};
use tokio::time::Duration;

pub struct FixedTpsTest;

impl Test for FixedTpsTest {
    fn name(&self) -> &'static str {
        "fixed-tps-test"
    }
}

impl NetworkTest for FixedTpsTest {
    fn run<'t>(&self, ctx: &mut NetworkContext<'t>) -> Result<()> {
        let duration = Duration::from_secs(240);
        let all_validators = ctx
            .swarm()
            .validators()
            .map(|v| v.peer_id())
            .collect::<Vec<_>>();

        // Generate some traffic with fixed tps 10
        let txn_stat = generate_traffic(ctx, &all_validators, duration, 0, Some(10))?;
        ctx.report
            .report_txn_stats(self.name().to_string(), txn_stat, duration);

        Ok(())
    }
}