Increasing the block height
You can use produce_blocks
to help achieve an arbitrary block height; this is useful when you want to do any testing regarding transaction maturity.
Note: For the
produce_blocks
API to work, it is imperative to havemanual_blocks_enabled = true
in the config for the running node. See example below.
let config = Config {
manual_blocks_enabled: true, // Necessary so the `produce_blocks` API can be used locally
..Config::local_node()
};
let wallets =
launch_custom_provider_and_get_wallets(WalletsConfig::default(), Some(config)).await;
let wallet = &wallets[0];
let provider = wallet.get_provider()?;
assert_eq!(provider.latest_block_height().await?, 0);
provider.produce_blocks(3).await?;
assert_eq!(provider.latest_block_height().await?, 3);