Skip to content

Commit 3f13e9e

Browse files
Cleaned up code
1 parent 29bc98f commit 3f13e9e

3 files changed

Lines changed: 10 additions & 51 deletions

File tree

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ Alternatively, you can install it directly from git:
8080
cargo install --git https://github.com/nimiq/core-rs-albatross.git
8181
```
8282

83-
some changes here maybe
84-
8583
## Documentation
8684
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/).
8785

fuzz/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ workspace = true
1616
[dependencies]
1717
afl = { version = "0.15.11", optional = true }
1818

19+
nimiq-account = { workspace = true }
20+
nimiq-bls = { workspace = true }
1921
nimiq-collections = { workspace = true }
22+
nimiq-keys = { workspace = true }
2023
nimiq-primitives = { workspace = true, features = ["key-nibbles", "serde-derive", "trie"] }
2124
nimiq-serde = { workspace = true }
22-
nimiq-bls = { workspace = true }
23-
nimiq-keys = { workspace = true }
24-
nimiq-account = { workspace = true }
2525
nimiq-transaction = { workspace = true }
2626

27-
2827
[features]
2928
fuzz = ["afl"]

fuzz/src/bin/staking_contract.rs

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,18 @@ fn main() {
44
use nimiq_serde::{Deserialize, Serialize};
55
use nimiq_account::StakingContract;
66
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.
129
match res {
1310
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);
3215
},
3316
Err(e) => {
34-
// println!("Error thing!!!\n");
3517
return;
3618
},
3719
}
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);
45-
// Now check if they are equal:
46-
assert_eq!(data, serialized);
47-
}
48-
*/
49-
50-
5120
})
52-
}
53-
54-
/*
55-
let contract_2a =
56-
StakingContract::deserialize_from_vec(&contract_2.serialize_to_vec()).unwrap();
57-
58-
assert_eq!(contract_2, contract_2a);
59-
*/
21+
}

0 commit comments

Comments
 (0)