Skip to content

Commit

Permalink
feat(starknet_integration_tests): add update revert config
Browse files Browse the repository at this point in the history
  • Loading branch information
noamsp-starkware committed Feb 12, 2025
1 parent 1893bc2 commit 4093bd4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
26 changes: 26 additions & 0 deletions crates/starknet_integration_tests/src/integration_test_setup.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use std::fs;
use std::net::SocketAddr;
use std::path::{Path, PathBuf};

use blockifier::context::ChainInfo;
use mempool_test_utils::starknet_api_test_utils::AccountTransactionGenerator;
use papyrus_storage::StorageConfig;
use serde_json::Value;
use starknet_api::block::BlockNumber;
use starknet_api::rpc_transaction::RpcTransaction;
use starknet_api::transaction::TransactionHash;
use starknet_class_manager::test_utils::FileHandles;
Expand Down Expand Up @@ -168,4 +171,27 @@ impl ExecutableSetup {
pub async fn assert_add_tx_success(&self, tx: RpcTransaction) -> TransactionHash {
self.add_tx_http_client.assert_add_tx_success(tx).await
}

// TODO(noamsp): Change this into change_config once we need to change other values in the
// config.
pub fn update_revert_config(&self, value: Option<BlockNumber>) {
let config_path = self.node_config_path.clone();
let config_path = config_path.to_str().unwrap();
let mut data = fs::read_to_string(config_path).unwrap();
let mut json_data: Value = serde_json::from_str(&data).unwrap();

match value {
Some(value) => {
json_data["revert_config.revert_up_to_and_including"] = Value::from(value.0);
json_data["revert_config.should_revert"] = Value::from(true);
}
// If should revert is false, the revert_up_to_and_including value is irrelevant.
None => {
json_data["revert_config.should_revert"] = Value::from(false);
}
}

data = serde_json::to_string_pretty(&json_data).unwrap();
fs::write(config_path, data).unwrap();
}
}
9 changes: 9 additions & 0 deletions crates/starknet_integration_tests/src/sequencer_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,15 @@ impl IntegrationTestManager {
self.await_alive(5000, 50).await;
}

pub fn update_revert_config_to_all_idle_nodes(&mut self, value: Option<BlockNumber>) {
info!("Updating revert config to all idle nodes.");
self.idle_nodes.values().for_each(|idle_node| {
idle_node.executables.iter().for_each(|executable| {
executable.update_revert_config(value);
});
});
}

pub fn get_node_indices(&self) -> HashSet<usize> {
self.node_indices.clone()
}
Expand Down

0 comments on commit 4093bd4

Please sign in to comment.