-
Notifications
You must be signed in to change notification settings - Fork 61
fuzz: FlatChainstore targets #529
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
base: master
Are you sure you want to change the base?
fuzz: FlatChainstore targets #529
Conversation
1834fc8
to
3f9f3ab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add these new fuzz targets in doc/fuzzing.md
This commit adds three fuzz targets for `FlatChainstore`, that makes sure our code memory access is sane. We insert, retrieve headers and reorg the chain to stress multiple code paths and check their soundness.
3f9f3ab
to
b58e555
Compare
@brunoerg removed the non-determinism and added the targets to |
|
||
// Create a temporary directory for our chainstore | ||
let mut id: [u8; 4] = [0; 4]; | ||
id.copy_from_slice(&data[0..4]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't make sense that way it is playing with data
. Instead of consuming it, it's simply accessing it. Note that it's using the same part of data in different places here.
}; | ||
|
||
// Initialize the chainstore | ||
let mut store = match FlatChainStore::new(config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is creating a FlatChainStore from a simple FlatChainStoreConfig (and static?), so we can surely expect it to succeed. In this case, it makes sense to crash when Err
?
What is the purpose of this pull request?
Which crates are being modified?
Description
This commit adds three fuzz targets for
FlatChainstore
, that makes sure our code memory access is sane. We insert, retrieve headers and reorg the chain to stress multiple code paths and check their soundness.PSA: These targets were generated by A.I. O.o I was testing some A.I. tool and the end result was actually great, so I've decided to fix some minor problems I've found and make a PR with it.