zebra_state/service/finalized_state/disk_format/
tests.rs

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