-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(starknet_integration_tests): add revert flow integration test
- Loading branch information
1 parent
1a12ca7
commit 5481e4e
Showing
1 changed file
with
57 additions
and
1 deletion.
There are no files selected for viewing
58 changes: 57 additions & 1 deletion
58
...tests/src/bin/sequencer_node_end_to_end_integration_tests/revert_flow_integration_test.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,63 @@ | ||
use std::time::Duration; | ||
|
||
use starknet_api::block::BlockNumber; | ||
use starknet_infra_utils::test_utils::TestIdentifier; | ||
use starknet_integration_tests::integration_test_utils::integration_test_setup; | ||
use starknet_integration_tests::sequencer_manager::{ | ||
IntegrationTestManager, | ||
BLOCK_TO_WAIT_FOR_BOOTSTRAP, | ||
}; | ||
use tracing::info; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
integration_test_setup("revert").await; | ||
// TODO(noamsp): Add the revert flow test. | ||
const BLOCK_TO_REVERT_FROM: BlockNumber = BlockNumber(10); | ||
const N_TXS: usize = 50; | ||
/// The number of consolidated local sequencers that participate in the test. | ||
const N_CONSOLIDATED_SEQUENCERS: usize = 1; | ||
/// The number of distributed remote sequencers that participate in the test. | ||
const N_DISTRIBUTED_SEQUENCERS: usize = 0; | ||
|
||
const AWAIT_REVERT_INTERVAL_MS: u64 = 500; | ||
const MAX_ATTEMPTS: usize = 50; | ||
const AWAIT_REVERT_TIMEOUT_DURATION: Duration = Duration::from_secs(15); | ||
|
||
// Get the sequencer configurations. | ||
let mut integration_test_manager = IntegrationTestManager::new( | ||
N_CONSOLIDATED_SEQUENCERS, | ||
N_DISTRIBUTED_SEQUENCERS, | ||
None, | ||
None, | ||
TestIdentifier::EndToEndRevertFlowIntegrationTest, | ||
) | ||
.await; | ||
|
||
let node_indices = integration_test_manager.get_node_indices(); | ||
|
||
integration_test_manager.run_nodes(node_indices.clone()).await; | ||
// Run the first block scenario to bootstrap the accounts. | ||
integration_test_manager.send_bootstrap_txs_and_verify().await; | ||
integration_test_manager.send_invoke_txs_and_verify(N_TXS, BLOCK_TO_REVERT_FROM).await; | ||
|
||
info!("Shutting down nodes."); | ||
integration_test_manager.shutdown_nodes(node_indices.clone()); | ||
integration_test_manager | ||
.update_revert_config_to_all_idle_nodes(Some(BLOCK_TO_WAIT_FOR_BOOTSTRAP.unchecked_next())); | ||
integration_test_manager.run_nodes(node_indices.clone()).await; | ||
// Wait for the revert to complete. | ||
integration_test_manager | ||
.await_revert_all_running_nodes( | ||
BLOCK_TO_WAIT_FOR_BOOTSTRAP, | ||
AWAIT_REVERT_TIMEOUT_DURATION, | ||
AWAIT_REVERT_INTERVAL_MS, | ||
MAX_ATTEMPTS, | ||
) | ||
.await; | ||
info!("Shutting down nodes."); | ||
integration_test_manager.shutdown_nodes(node_indices.clone()); | ||
|
||
// TODO(noamsp): Rerun nodes, send and verify transactions after the revert completed. | ||
|
||
info!("Revert flow integration test completed successfully!"); | ||
} |