-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip - tests running but still without cargo update
commit-id:c0132bbb
- Loading branch information
1 parent
fc17d2d
commit 9da1939
Showing
4 changed files
with
50 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,46 @@ | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use starknet_types_core::felt::Felt; | ||
|
||
use crate::component_definitions::{BincodeSerializable, SerdeWrapper}; | ||
use crate::trace_util::configure_tracing; | ||
|
||
|
||
#[test] | ||
fn test_serde_native_type() { | ||
configure_tracing(); | ||
let data: u32 = 8; | ||
|
||
let encoded = | ||
SerdeWrapper { data }.to_bincode().expect("Server error serialization should succeed"); | ||
let decoded = SerdeWrapper::<u32>::from_bincode(&encoded).unwrap(); | ||
|
||
assert_eq!(data, decoded.data); | ||
} | ||
|
||
let data : u32 = 8; | ||
#[test] | ||
fn test_serde_struct_type() { | ||
#[derive(Serialize, Deserialize, std::fmt::Debug, Clone, std::cmp::PartialEq, Copy)] | ||
struct TestStruct { | ||
a: u32, | ||
b: u32, | ||
} | ||
|
||
let encoded = SerdeWrapper { data } .to_bincode() .expect("Server error serialization should succeed"); | ||
let decoded = SerdeWrapper::<u32>::from_bincode(&encoded).unwrap(); | ||
let data: TestStruct = TestStruct { a: 17, b: 8 }; | ||
|
||
let encoded = | ||
SerdeWrapper { data }.to_bincode().expect("Server error serialization should succeed"); | ||
let decoded = SerdeWrapper::<TestStruct>::from_bincode(&encoded).unwrap(); | ||
|
||
assert_eq!(data, decoded.data); | ||
} | ||
|
||
#[test] | ||
fn test_serde_felt() { | ||
configure_tracing(); | ||
|
||
let data: Felt = Felt::ONE; | ||
|
||
let encoded = | ||
SerdeWrapper { data }.to_bincode().expect("Server error serialization should succeed"); | ||
let decoded = SerdeWrapper::<Felt>::from_bincode(&encoded).unwrap(); | ||
|
||
} | ||
assert_eq!(data, decoded.data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters