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

feat(starknet_integration_tests): add update revert config #4074

Open
wants to merge 1 commit into
base: noam.s/feat_starknet_state_sync_add_revert_up_to_and_including_option
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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
Loading