Skip to content

Commit cdaa05e

Browse files
committed
Serialize test vectors as JSON strings
1 parent e0365d6 commit cdaa05e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

nucypher-core/src/dkg.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,10 @@ mod tests {
638638
use serde::{Deserialize, Serialize};
639639
use serde_json;
640640
use x25519_dalek::{PublicKey, StaticSecret};
641+
#[cfg(feature = "deterministic_encryption")]
642+
use alloc::string::String;
643+
#[cfg(feature = "deterministic_encryption")]
644+
use alloc::format;
641645

642646
use crate::access_control::AccessControlPolicy;
643647
use crate::conditions::Context;
@@ -908,6 +912,16 @@ mod tests {
908912
test_vectors
909913
}
910914

915+
#[cfg(feature = "deterministic_encryption")]
916+
pub fn serialize_test_vector_to_json(vector: &TestVector) -> String {
917+
serde_json::to_string(vector).expect("Failed to serialize test vector to JSON")
918+
}
919+
920+
#[cfg(feature = "deterministic_encryption")]
921+
pub fn deserialize_test_vector_from_json(json: &str) -> TestVector {
922+
serde_json::from_str(json).expect("Failed to deserialize test vector from JSON")
923+
}
924+
911925
#[test]
912926
#[cfg(feature = "deterministic_encryption")]
913927
fn test_encryption_deterministic() {

0 commit comments

Comments
 (0)