This commit is contained in:
Rostyslav Tyshko 2024-12-09 04:18:27 +01:00
parent 4e0ad2b47b
commit 81cf5a4039
3 changed files with 7 additions and 10 deletions

View File

@ -38,12 +38,11 @@ mod tests {
fn pad_to_32(slice: &[u8]) -> [u8; 32] { fn pad_to_32(slice: &[u8]) -> [u8; 32] {
let mut padded = [0u8; 32]; let mut padded = [0u8; 32];
let len = slice.len().min(32); let len = slice.len().min(32);
padded[..len].copy_from_slice(&slice[..len]); padded[..len].copy_from_slice(&slice[..len]);
padded padded
} }
#[test] #[test]
fn test_create_empty_store() { fn test_create_empty_store() {
let store = NodeAccountsStore::new(); let store = NodeAccountsStore::new();

View File

@ -1,6 +1,6 @@
use std::path::Path; use std::path::Path;
use anyhow::{Result, anyhow}; use anyhow::{anyhow, Result};
use storage::{block::Block, RocksDBIO}; use storage::{block::Block, RocksDBIO};
pub struct NodeBlockStore { pub struct NodeBlockStore {
@ -42,9 +42,9 @@ impl NodeBlockStore {
mod tests { mod tests {
use super::*; use super::*;
use std::path::PathBuf; use std::path::PathBuf;
use tempfile::tempdir;
use storage::block::{Block, BlockHash, BlockId, Data}; use storage::block::{Block, BlockHash, BlockId, Data};
use storage::transaction::Transaction; use storage::transaction::Transaction;
use tempfile::tempdir;
fn create_genesis_block() -> Block { fn create_genesis_block() -> Block {
Block { Block {
@ -74,8 +74,8 @@ mod tests {
let path = temp_dir.path(); let path = temp_dir.path();
let genesis_block = create_genesis_block(); let genesis_block = create_genesis_block();
let node_store = NodeBlockStore::open_db_with_genesis(path, Some(genesis_block.clone())) let node_store =
.unwrap(); NodeBlockStore::open_db_with_genesis(path, Some(genesis_block.clone())).unwrap();
// Verify the genesis block is stored // Verify the genesis block is stored
let stored_block = node_store.get_block_at_id(0).unwrap(); let stored_block = node_store.get_block_at_id(0).unwrap();

View File

@ -102,10 +102,8 @@ impl RocksDBIO {
let mut db_opts = Options::default(); let mut db_opts = Options::default();
db_opts.create_missing_column_families(true); db_opts.create_missing_column_families(true);
db_opts.create_if_missing(true); db_opts.create_if_missing(true);
DBWithThreadMode::<MultiThreaded>::destroy( DBWithThreadMode::<MultiThreaded>::destroy(&db_opts, path)
&db_opts, .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))
path,
).map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))
} }
pub fn meta_column(&self) -> Arc<BoundColumnFamily> { pub fn meta_column(&self) -> Arc<BoundColumnFamily> {