You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extensive documentation explaining how the protocol is built up, the JSON-RPC specification, how to get started building applications on top of Nimiq and more can be found at the [Nimiq Developer Center](https://www.nimiq.com/developers/).
Copy file name to clipboardExpand all lines: fuzz/src/bin/staking_contract.rs
+7-45Lines changed: 7 additions & 45 deletions
Original file line number
Diff line number
Diff line change
@@ -4,56 +4,18 @@ fn main() {
4
4
use nimiq_serde::{Deserialize,Serialize};
5
5
use nimiq_account::StakingContract;
6
6
let res = StakingContract::deserialize_from_vec(data);// err I think is of type DeserializeError
7
-
8
-
// Now check if contr exists. If it does (aka. the original data was a valid staking contract) then try to serialize it back to a vector, then check if the original vector and the new vector are the same, if they aren't then there is a bug in the parsing logic.
9
-
10
-
// The existance of error implies that contr does not exist.
11
-
7
+
// Now check if contract exists. If it does (aka. the original data was a valid staking contract) then try to serialize it back to a vector, then check if the original vector and the new vector are the same, if they aren't then there is a bug in the parsing logic.
8
+
// The existence of error implies that contract does not exist.
12
9
match res {
13
10
Ok(v) => {
14
-
// First calculate the minimum of the two.
15
-
let otherdata = StakingContract::serialize_to_vec(&v);
16
-
17
-
/*
18
-
let buf = (0..64).collect::<Vec<u8>>();
19
-
let z: &[u8; 64] = &(&buf[..]).try_into().unwrap();
20
-
*/
21
-
22
-
assert!((otherdata.len() <= data.len()),"The size of the serialized version was bigger than the original vector! This shouldn't happen!");
23
-
//data.resize((otherdata.len()), 0);
24
-
25
-
// let comparison_bullshit = data.collect::<Vec<u8>>(); // Collect the stuff
26
-
27
-
// arg[..30].try_into().unwrap()
28
-
29
-
let bullshit:&[u8] = data[..(otherdata.len())].try_into().unwrap();// Yuck!!!
30
-
31
-
assert_eq!(bullshit, otherdata);
11
+
let serialized = StakingContract::serialize_to_vec(&v);
12
+
assert!((serialized.len() <= data.len()),"The size of the serialized version was bigger than the original vector! This shouldn't happen!");
13
+
let original_data_segment:&[u8] = data[..(serialized.len())].try_into().unwrap();// This ugly stuff has to be done, because the serialization function ignores extra bytes at the end so we can not compare the byte vectors by themselves. Yuck!!!
14
+
assert_eq!(original_data_segment, serialized);
32
15
},
33
16
Err(e) => {
34
-
// println!("Error thing!!!\n");
35
17
return;
36
18
},
37
19
}
38
-
39
-
/*
40
-
if (err == None) {
41
-
// Contr exists
42
-
assert!(contr, "contr didn't exist, even though err == None!!!!"); // Debug.
43
-
// Now try to serialize to vec
44
-
let serialized = StakingContract::serialize_to_vec(contr);
0 commit comments