use crate::dbs::node::Timestamp;
use crate::err::Error;
use crate::kvs::clock::{FakeClock, SizedClock};
pub struct TestContext {
pub(crate) db: Datastore,
pub(crate) kvs: Kvs,
pub(crate) context_id: String,
}
impl TestContext {
pub fn test_str(&self, prefix: &str) -> String {
format!("{}-{}", prefix, self.context_id)
}
}
pub(crate) async fn init(
node_id: Uuid,
clock: Arc<RwLock<SizedClock>>,
) -> Result<TestContext, Error> {
let (db, kvs) = new_ds(node_id, clock).await;
Ok(TestContext {
db,
kvs,
context_id: node_id.to_string(), })
}
async fn _debug_scan(tx: &mut Transaction, message: &str) {
let r = tx.scan(vec![0]..vec![u8::MAX], 100000).await.unwrap();
println!("START OF RANGE SCAN - {}", message);
for (k, _v) in r.iter() {
println!("{}", crate::key::debug::sprint_key(k));
}
println!("END OF RANGE SCAN - {}", message);
}