Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Conversation

@aeyakovenko
Copy link
Member

No description provided.

@CriesofCarrots
Copy link
Contributor

I'll merge early, but I want to see the all token tests run here or locally first

@steviez
Copy link
Contributor

steviez commented Aug 3, 2022

Just checked - all other instances of .split_at() in this repo have length checks before calling split_at()

@CriesofCarrots
Copy link
Contributor

twotx CI failure is known and unrelated

}

#[test]
fn test_instruction_unpack_panic() {
Copy link
Contributor

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);
            }
        }
    }

Copy link
Contributor

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 :)

Copy link
Member Author

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);
        }
    }

@CriesofCarrots CriesofCarrots merged commit 22faa05 into solana-labs:master Aug 3, 2022
joncinque added a commit to joncinque/solana-program-library that referenced this pull request Aug 3, 2022
joncinque added a commit that referenced this pull request Aug 3, 2022
* token: Reassign and reallocate accounts on close

* Revert "Refactor unpack and make test more robust (#3417)"

This reverts commit c618de3.

* Revert "check that unpack is tolerant of small sizes (#3416)"

This reverts commit 22faa05.

* Also revert d7f352b
CriesofCarrots pushed a commit to CriesofCarrots/solana-program-library that referenced this pull request Aug 3, 2022
CriesofCarrots pushed a commit that referenced this pull request Aug 4, 2022
* 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 <[email protected]>

* Readd proptests without losing unit test, #3421

Co-authored-by: anatoly yakovenko <[email protected]>
Co-authored-by: Michael Vines <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants