forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[comparison-testing-tool] Add more features to the comparison testing…
… tool (aptos-labs#11890) * add features * refactor * handling review comments * fix * always get aptos framework from git * simplify mismatch info * add failed cache * remove clean session * revert clean session * handle review comments * handle comments * comment followup * add gas meter to avoid hanging in loop * update package publish handling
- Loading branch information
1 parent
8891c10
commit e318636
Showing
17 changed files
with
895 additions
and
219 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
86 changes: 86 additions & 0 deletions
86
aptos-move/aptos-e2e-comparison-testing/src/data_state_view.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 |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright © Aptos Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use aptos_language_e2e_tests::data_store::FakeDataStore; | ||
use aptos_types::{ | ||
state_store::{ | ||
state_key::StateKey, state_storage_usage::StateStorageUsage, state_value::StateValue, | ||
Result as StateViewResult, TStateView, | ||
}, | ||
transaction::Version, | ||
}; | ||
use aptos_validator_interface::{AptosValidatorInterface, DebuggerStateView}; | ||
use std::{ | ||
collections::HashMap, | ||
sync::{Arc, Mutex}, | ||
}; | ||
|
||
pub struct DataStateView { | ||
debugger_view: DebuggerStateView, | ||
code_data: Option<FakeDataStore>, | ||
data_read_state_keys: Option<Arc<Mutex<HashMap<StateKey, StateValue>>>>, | ||
} | ||
use std::ops::DerefMut; | ||
|
||
impl DataStateView { | ||
pub fn new( | ||
db: Arc<dyn AptosValidatorInterface + Send>, | ||
version: Version, | ||
code_data: FakeDataStore, | ||
) -> Self { | ||
Self { | ||
debugger_view: DebuggerStateView::new(db, version), | ||
code_data: Some(code_data), | ||
data_read_state_keys: None, | ||
} | ||
} | ||
|
||
pub fn new_with_data_reads( | ||
db: Arc<dyn AptosValidatorInterface + Send>, | ||
version: Version, | ||
) -> Self { | ||
Self { | ||
debugger_view: DebuggerStateView::new(db, version), | ||
code_data: None, | ||
data_read_state_keys: Some(Arc::new(Mutex::new(HashMap::new()))), | ||
} | ||
} | ||
|
||
pub fn get_state_keys(self) -> Arc<Mutex<HashMap<StateKey, StateValue>>> { | ||
self.data_read_state_keys.unwrap() | ||
} | ||
} | ||
|
||
impl TStateView for DataStateView { | ||
type Key = StateKey; | ||
|
||
fn get_state_value(&self, state_key: &StateKey) -> StateViewResult<Option<StateValue>> { | ||
if let Some(code) = &self.code_data { | ||
if code.contains_key(state_key) { | ||
return code.get_state_value(state_key).map_err(Into::into); | ||
} | ||
} | ||
let ret = self.debugger_view.get_state_value(state_key); | ||
if let Some(reads) = &self.data_read_state_keys { | ||
if !state_key.is_aptos_code() | ||
&& !reads.lock().unwrap().contains_key(state_key) | ||
&& ret.is_ok() | ||
{ | ||
let val = ret?; | ||
if val.is_some() { | ||
reads | ||
.lock() | ||
.unwrap() | ||
.deref_mut() | ||
.insert(state_key.clone(), val.clone().unwrap()); | ||
}; | ||
return Ok(val); | ||
} | ||
} | ||
ret | ||
} | ||
|
||
fn get_usage(&self) -> StateViewResult<StateStorageUsage> { | ||
unreachable!() | ||
} | ||
} |
Oops, something went wrong.