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

fuzzing example: fuzz_target_2 Config::setup is wrong #286

Open
brson opened this issue Oct 31, 2023 · 2 comments
Open

fuzzing example: fuzz_target_2 Config::setup is wrong #286

brson opened this issue Oct 31, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@brson
Copy link
Contributor

brson commented Oct 31, 2023

This example uses snapshots to reset the environment, but the way it initializes the first environment should not be recommended:

    fn setup() -> Env {
        let snapshot = {
            let init_ledger = LedgerInfo {
                protocol_version: 1,
                sequence_number: 10,
                timestamp: 12345,
                network_id: Default::default(),
                base_reserve: 10,
                min_temp_entry_ttl: u32::MAX,
                min_persistent_entry_ttl: u32::MAX,
                max_entry_ttl: u32::MAX,
            };

            LedgerSnapshot::from(init_ledger, None)
        };

        let env = Env::from_snapshot(snapshot);
        env.mock_all_auths();

        env
    }

Instead of calling Env::default it creates a snapshot from scratch and converts that to an env. This fails to do a bunch of initialization that Env::default does for the testutils config, and also configures the initial snapshot with strange values for ttl etc.

Instead, the initial snapshot should be created with Env::default, subsequent time advances can still use snapshots to destroy and reconstruct the env.

@brson brson added the bug Something isn't working label Oct 31, 2023
@brson
Copy link
Contributor Author

brson commented Oct 31, 2023

There are additional revisions to be made to the fuzzing examples and I will get back to them soon.

@brson
Copy link
Contributor Author

brson commented Oct 31, 2023

Using snapshots to destroy and recreate the environment may not be a good idea at all since Env::from_snapshot doesn't do the same test setup that Env::default does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants
@brson and others