let block_time = 20u32; // seconds
let config = Config {
// This is how you specify the time between blocks
block_production: Trigger::Interval {
block_time: std::time::Duration::from_secs(block_time.into()),
},
..Config::default()
};
let wallets =
launch_custom_provider_and_get_wallets(WalletsConfig::default(), Some(config), None)
.await?;
let wallet = &wallets[0];
let provider = wallet.try_provider()?;
assert_eq!(provider.latest_block_height().await?, 0u32);
let origin_block_time = provider.latest_block_time().await?.unwrap();
let blocks_to_produce = 3;
provider.produce_blocks(blocks_to_produce, None).await?;
assert_eq!(provider.latest_block_height().await?, blocks_to_produce);
let expected_latest_block_time = origin_block_time
.checked_add_signed(Duration::seconds((blocks_to_produce * block_time) as i64))
.unwrap();
assert_eq!(
provider.latest_block_time().await?.unwrap(),
expected_latest_block_time
);