Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test_long_chain_with_restart_from_snapshot #10193

Merged
merged 5 commits into from
Nov 20, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions integration-tests/src/tests/client/process_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3431,6 +3431,49 @@ fn test_catchup_no_sharding_change() {
}
}

/// Run `gc_num_epochs_to_keep` epochs + several blocks.
/// Start a second env from the "snapshot" of the first.
/// Run one more epoch.
/// "Restart from the snapshot" is to ensure that we can continue producing blocks without relying on caches.
#[test]
fn test_long_chain_with_restart_from_snapshot() {
init_test_logger();

let epoch_length = 25;

let mut genesis = Genesis::test(vec!["test0".parse().unwrap()], 1);

genesis.config.epoch_length = epoch_length;
let mut chain_genesis = ChainGenesis::test();
chain_genesis.epoch_length = epoch_length;
let mut env1 = TestEnv::builder(chain_genesis.clone())
.real_epoch_managers(&genesis.config)
.nightshade_runtimes(&genesis)
.archive(false)
.build();

env1.clients[0].config.gc.gc_blocks_limit = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can you add a small comment on why this is needed?


let max_height = epoch_length * env1.clients[0].config.gc.gc_num_epochs_to_keep + 3;

for h in 1..max_height {
let block = env1.clients[0].produce_block(h).unwrap().unwrap();
env1.process_block(0, block.clone(), Provenance::PRODUCED);
}

let mut env2 = TestEnv::builder(chain_genesis)
.stores(vec![env1.clients[0].chain.store().store().clone()])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat!

.real_epoch_managers(&genesis.config)
.nightshade_runtimes(&genesis)
.archive(false)
.build();

for h in max_height..(max_height + epoch_length) {
let block = env2.clients[0].produce_block(h).unwrap().unwrap();
env2.process_block(0, block.clone(), Provenance::PRODUCED);
}
}

/// These tests fail on aarch because the WasmtimeVM::precompile method doesn't populate the cache.
mod contract_precompilation_tests {
use super::*;
Expand Down
Loading