From 63ef3820d2cd17e6f56823397aca5a1bd36fd23c Mon Sep 17 00:00:00 2001 From: Razvan Barbascu Date: Wed, 16 Oct 2024 15:10:42 +0300 Subject: [PATCH] fix integration test by reading parts from ext storage instead of DB --- .../src/tests/client/state_dump.rs | 18 ++++++++++-------- o | 9 +++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 o diff --git a/integration-tests/src/tests/client/state_dump.rs b/integration-tests/src/tests/client/state_dump.rs index f5488bdc928..2ac483c4e1f 100644 --- a/integration-tests/src/tests/client/state_dump.rs +++ b/integration-tests/src/tests/client/state_dump.rs @@ -15,13 +15,11 @@ use near_primitives::block::Tip; use near_primitives::shard_layout::ShardUId; use near_primitives::state::FlatStateValue; use near_primitives::state_part::PartId; -use near_primitives::state_sync::StatePartKey; use near_primitives::transaction::SignedTransaction; use near_primitives::types::BlockHeight; use near_primitives::validator_signer::{EmptyValidatorSigner, InMemoryValidatorSigner}; use near_primitives::views::{QueryRequest, QueryResponseKind}; use near_store::adapter::{StoreAdapter, StoreUpdateAdapter}; -use near_store::DBCol; use near_store::Store; use nearcore::state_sync::StateSyncDumper; use nearcore::test_utils::TestEnvNightshadeSetupExt; @@ -296,12 +294,10 @@ fn run_state_sync_with_dumped_parts( .await .unwrap(); - // Simulate state sync + // Simulate state sync by reading the dumped parts from the external storage and applying them to the other node tracing::info!("syncing node: simulating state sync.."); env.clients[1].chain.set_state_header(0, sync_hash, state_sync_header).unwrap(); let runtime_client_1 = Arc::clone(&env.clients[1].runtime_adapter); - let runtime_client_0 = Arc::clone(&env.clients[0].runtime_adapter); - let client_0_store = runtime_client_0.store(); let mut store_update = runtime_client_1.store().store_update(); assert!(runtime_client_1 .get_flat_storage_manager() @@ -311,10 +307,16 @@ fn run_state_sync_with_dumped_parts( ) .unwrap()); store_update.commit().unwrap(); - + let shard_id = 0; for part_id in 0..num_parts { - let key = borsh::to_vec(&StatePartKey(sync_hash, 0, part_id)).unwrap(); - let part = client_0_store.get(DBCol::StateParts, &key).unwrap().unwrap(); + let path = root_dir.path().join(external_storage_location( + &config.chain_id, + &epoch_id, + epoch_height, + shard_id, + &StateFileType::StatePart { part_id, num_parts }, + )); + let part = std::fs::read(&path).expect("Part file not found. It should exist"); runtime_client_1 .apply_state_part(0, &state_root, PartId::new(part_id, num_parts), &part, &epoch_id) diff --git a/o b/o new file mode 100644 index 00000000000..9114ca33a5c --- /dev/null +++ b/o @@ -0,0 +1,9 @@ + +running 0 tests + +successes: + +successes: + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 394 filtered out; finished in 0.00s +