mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-06 23:33:10 +00:00
add test_serialize_data_blob
This commit is contained in:
parent
a4622a07ca
commit
15e6cded2f
@ -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<u8>) -> 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<u8> {
|
||||
(0..SC_DATA_BLOB_SIZE).collect::<Vec<usize>>().iter().map(|&x| x as u8).collect()
|
||||
}
|
||||
|
||||
fn sample_data_blob() -> DataBlob {
|
||||
let vec: Vec<u8> = 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();
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user