mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-02 13:23:10 +00:00
tests setup: mock structures and get_first_32_bytes
This commit is contained in:
parent
4f5f302177
commit
822c9cb77e
@ -95,3 +95,29 @@ impl<Leav: TreeLeavItem + Clone> HashStorageMerkleTree<Leav> {
|
||||
self.tree.commit();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
// Mock implementation of TreeLeavItem trait for testing
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
struct MockTransaction {
|
||||
pub hash: TreeHashType,
|
||||
}
|
||||
|
||||
impl TreeLeavItem for MockTransaction {
|
||||
fn hash(&self) -> TreeHashType {
|
||||
self.hash
|
||||
}
|
||||
}
|
||||
|
||||
fn get_first_32_bytes(s: &str) -> [u8; 32] {
|
||||
let mut buffer = [0u8; 32];
|
||||
let bytes = s.as_bytes();
|
||||
let len = std::cmp::min(32, bytes.len());
|
||||
|
||||
buffer[..len].copy_from_slice(&bytes[..len]);
|
||||
buffer
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user