-
Notifications
You must be signed in to change notification settings - Fork 2k
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
guards #3416
guards #3416
Conversation
6f6cd63
to
d07fce2
Compare
I'll merge early, but I want to see the all token tests run here or locally first |
Just checked - all other instances of |
|
@@ -1689,4 +1704,12 @@ mod test { | |||
let unpacked = TokenInstruction::unpack(&expect).unwrap(); | |||
assert_eq!(unpacked, check); | |||
} | |||
|
|||
#[test] | |||
fn test_instruction_unpack_panic() { |
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.
As a follow-up, perhaps something more exhaustive?
#[test]
fn test_instruction_unpack_panic() {
for i in 0..255u8 {
for j in 1..10 {
let mut data = vec![0;j];
data[0] = i;
let _no_panic = TokenInstruction::unpack(&data);
}
}
}
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.
Yep, on my list already :)
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.
I am fuzzing it with
#[test]
fn test_instruction_unpack_fuzz() {
for _ in 0..10000000 {
let r: usize = rand::thread_rng().gen_range(0..10);
let data: Vec<u8> = (0..r).map(|_| rand::thread_rng().gen()).collect();
_ = TokenInstruction::unpack(&data);
}
}
This reverts commit 22faa05.
* check that unpack is tolerant of small sizes (#3416) * Refactor unpack and make test more robust (#3417) * Refactor hasty fix to match token-2022 * Make test exhaustive * cargo fmt Co-authored-by: Michael Vines <mvines@gmail.com> * Readd proptests without losing unit test, #3421 Co-authored-by: anatoly yakovenko <anatoly@solana.com> Co-authored-by: Michael Vines <mvines@gmail.com>
No description provided.