Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some more fuzzers in to the source #3003

Open
wants to merge 6 commits into
base: albatross
Choose a base branch
from

Conversation

personnumber3377
Copy link

What's in this pull request?

This pull request adds some more fuzzers to the codebase.

Pull request checklist

  • All tests pass. The project builds and runs.
  • I have resolved any merge conflicts.
  • I have resolved all clippy and rustfmt warnings.

fuzz/Cargo.toml Outdated
@@ -19,6 +19,11 @@ afl = { version = "0.15.11", optional = true }
nimiq-collections = { workspace = true }
nimiq-primitives = { workspace = true, features = ["key-nibbles", "serde-derive", "trie"] }
nimiq-serde = { workspace = true }
nimiq-bls = { workspace = true }
nimiq-keys = { workspace = true }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually we try to keep dependency names in alphabetical order

use nimiq_account::StakingContract;
let res = StakingContract::deserialize_from_vec(data); // err I think is of type DeserializeError

// 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.
// 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.


// 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.

// The existance of error implies that contr does not exist.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// The existance of error implies that contr does not exist.
// The existence of error implies that contract does not exist.


// arg[..30].try_into().unwrap()

let bullshit: &[u8] = data[..(otherdata.len())].try_into().unwrap(); // Yuck!!!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a proper name for the variable 😉

if (err == None) {
// Contr exists
assert!(contr, "contr didn't exist, even though err == None!!!!"); // Debug.
// Now try to serialize to vec
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clean up the code in general. Redundant/commented code, test sections, etc.

@Eligioo
Copy link
Member

Eligioo commented Oct 31, 2024

Can you squash the commits?

@personnumber3377
Copy link
Author

Hi @Eligioo !

Sorry for my late reply. How do I do that? 😅 I am quite new to git. Is it just git reset --soft main and then git add * and then git commit -m "Squashed commits" as described here ? I am a bit unsure.

Thanks in advance!

@personnumber3377
Copy link
Author

Hi! I cleaned up the code in this commit: 3f13e9e .

@Eligioo
Copy link
Member

Eligioo commented Nov 4, 2024

Hi @Eligioo !

Sorry for my late reply. How do I do that? 😅 I am quite new to git. Is it just git reset --soft main and then git add * and then git commit -m "Squashed commits" as described here ? I am a bit unsure.

Thanks in advance!

You can squash them through git rebase: https://www.youtube.com/watch?v=V5KrD7CmO4o

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants