Skip to content

Commit ca4fd3f

Browse files
committed
Capitalize Signed and Main
1 parent 3e272f4 commit ca4fd3f

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/frontend/serialization.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ impl Serialize for SignedPod {
3333
let signature = self.pod.serialized_proof();
3434

3535
state.serialize_field("proof", &signature)?;
36-
state.serialize_field("pod_class", "signed")?;
36+
state.serialize_field("pod_class", "Signed")?;
37+
state.serialize_field("pod_type", "Mock")?;
3738
state.end()
3839
}
3940
}
@@ -48,11 +49,15 @@ impl<'de> Deserialize<'de> for SignedPod {
4849
entries: HashMap<String, Value>,
4950
proof: String,
5051
pod_class: String,
52+
pod_type: String,
5153
}
5254

5355
let helper = SignedPodHelper::deserialize(deserializer)?;
54-
if helper.pod_class != "signed" {
55-
return Err(serde::de::Error::custom("pod_class is not signed"));
56+
if helper.pod_class != "Signed" {
57+
return Err(serde::de::Error::custom("pod_class is not Signed"));
58+
}
59+
if helper.pod_type != "Mock" {
60+
return Err(serde::de::Error::custom("pod_type is not Mock"));
5661
}
5762
let kvs = helper.entries;
5863
let dict = Dictionary::new(kvs.clone()).middleware_dict().clone();
@@ -72,9 +77,10 @@ impl Serialize for MainPod {
7277
let mut state = serializer.serialize_struct("MainPod", 2)?;
7378
state.serialize_field("public_statements", &self.public_statements)?;
7479
state.serialize_field("proof", &self.pod.serialized_proof())?;
75-
state.serialize_field("pod_class", "main")?;
80+
state.serialize_field("pod_class", "Main")?;
81+
state.serialize_field("pod_type", "Mock")?;
7682
state.end()
77-
}
83+
}
7884
}
7985

8086
impl<'de> Deserialize<'de> for MainPod {
@@ -87,11 +93,15 @@ impl<'de> Deserialize<'de> for MainPod {
8793
public_statements: Vec<Statement>,
8894
proof: String,
8995
pod_class: String,
90-
}
96+
pod_type: String,
97+
}
9198

9299
let helper = MainPodHelper::deserialize(deserializer)?;
93-
if helper.pod_class != "main" {
94-
return Err(serde::de::Error::custom("pod_class is not main"));
100+
if helper.pod_class != "Main" {
101+
return Err(serde::de::Error::custom("pod_class is not Main"));
102+
}
103+
if helper.pod_type != "Mock" {
104+
return Err(serde::de::Error::custom("pod_type is not Mock"));
95105
}
96106
let proof = String::from_utf8(BASE64_STANDARD.decode(&helper.proof).unwrap()).unwrap();
97107
let pod: MockMainPod = serde_json::from_str(&proof).unwrap();
@@ -204,7 +214,7 @@ mod tests {
204214
}
205215

206216
#[test]
207-
fn test_serialized_pod() {
217+
fn test_serialized_signed_pod() {
208218
let mut entries = HashMap::new();
209219
entries.insert("name".to_string(), Value::String("test".to_string()));
210220
entries.insert("age".to_string(), Value::Int(30));

0 commit comments

Comments
 (0)