diff --git a/storage/src/sc_db_utils.rs b/storage/src/sc_db_utils.rs index 691ba7e..0a72503 100644 --- a/storage/src/sc_db_utils.rs +++ b/storage/src/sc_db_utils.rs @@ -49,7 +49,7 @@ impl DataBlob { } } -#[derive(Debug, Clone, Copy, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] pub enum DataBlobChangeVariant { Created { id: usize, @@ -86,10 +86,29 @@ pub fn produce_blob_from_fit_vec(data: Vec) -> DataBlob { #[cfg(test)] mod tests { use super::*; + use serde_json; const TEST_BLOB_SIZE: usize = 256; // Define a test blob size for simplicity static SC_DATA_BLOB_SIZE: usize = TEST_BLOB_SIZE; + fn sample_vec() -> Vec { + (0..SC_DATA_BLOB_SIZE).collect::>().iter().map(|&x| x as u8).collect() + } + + fn sample_data_blob() -> DataBlob { + let vec: Vec = sample_vec(); + produce_blob_from_fit_vec(vec) + } + + #[test] + fn test_serialize_data_blob() { + let blob = sample_data_blob(); + let json = serde_json::to_string(&blob).unwrap(); + + let expected_json = serde_json::to_string(&sample_vec()).unwrap(); + assert_eq!(json, expected_json); + } + #[test] fn test_produce_blob_from_fit_vec() { let data = (0..0 + 255).collect(); diff --git a/template/zk_test_template/test_methods/guest/src/bin/template_sc.rs b/template/zk_test_template/test_methods/guest/src/bin/template_sc.rs index 86eb512..168277a 100644 --- a/template/zk_test_template/test_methods/guest/src/bin/template_sc.rs +++ b/template/zk_test_template/test_methods/guest/src/bin/template_sc.rs @@ -6,12 +6,7 @@ use {sc_name}::{SmartContract, InputParameters, PublicOutputs, PrivateOutputs}; use sc_core::traits::{IContract, IInputParameters, IPublicOutput, IPrivateOutput}; use sc_core::{{execution_type_trait}}; -use sc_core::PublicSCContext; - -//Not sure, how path will look like, so -//ToDo: Make it available from sc_core -//Curently in storage -use sc_core::{produce_blob_list_from_sc_public_state, compare_blob_lists}; +use sc_core::{PublicSCContext, produce_blob_list_from_sc_public_state, compare_blob_lists}; fn main() { let mut state: SmartContract = env::read();