Skip to main content

zebra_state/service/finalized_state/disk_format/
tests.rs

1//! Tests for the finalized disk format.
2
3#![allow(clippy::unwrap_in_result)]
4
5use serde::{Deserialize, Serialize};
6
7#[cfg(test)]
8mod prop;
9#[cfg(test)]
10mod snapshot;
11
12/// A formatting struct for raw key-value data
13#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
14pub struct KV {
15    /// The raw key bytes, as a hexadecimal-encoded string.
16    k: String,
17
18    /// The raw value bytes, as a hexadecimal-encoded string.
19    v: String,
20}
21
22impl KV {
23    /// Create a new `KV` from raw key-value data.
24    pub fn new<K, V>(key: K, value: V) -> KV
25    where
26        K: AsRef<[u8]>,
27        V: AsRef<[u8]>,
28    {
29        KV::new_hex(hex::encode(key), hex::encode(value))
30    }
31
32    /// Create a new `KV` from hex-encoded key-value data.
33    pub fn new_hex(key: String, value: String) -> KV {
34        KV { k: key, v: value }
35    }
36}