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

Add more integration-test tests #118

Closed
11 of 12 tasks
jakoschiko opened this issue Feb 12, 2024 · 6 comments
Closed
11 of 12 tasks

Add more integration-test tests #118

jakoschiko opened this issue Feb 12, 2024 · 6 comments

Comments

@jakoschiko
Copy link
Collaborator

jakoschiko commented Feb 12, 2024

We need to write tests using the integration-test framework introduced in #114.

For each case we need to consider whether we want to test client, server, or both.

@duesee duesee added this to the 9. Higher-level, async-first, IMAP library for client- and server milestone Feb 20, 2024
@jakoschiko
Copy link
Collaborator Author

arbtest looks like a good candidate for tests with random data.

@duesee
Copy link
Owner

duesee commented Feb 23, 2024

Uuuuh, looks nice.

@jakoschiko
Copy link
Collaborator Author

Hmm, I'm not happy with arbtest. I wasn't able to generate Vec<Vec<u8>> with significant lengths. See this example.

use arbtest::arbtest;

fn main() {
    arbtest(|u| {
        let x: Vec<Vec<u8>> = u.arbitrary()?;
        println!("{x:?}");
        Ok(())
    })
    .budget_ms(1000)
    .size_min(100000)
    .size_max(100000000);
}

produces

[]
[[]]
[]
[[156], [215], [19, 242, 169], [52, 80]]
[]
[[], [187], [188, 201], []]
[[254]]
[[67, 103, 177, 41], [248, 238, 176]]
[]
[[46], [64, 132, 79, 59, 79], [], [], [235], [], []]
[]
[[112]]
[]
[]
[]
[]
[[], [87, 206], [233], [], []]
[]
[]
[]
[[50]]
[]
[[], []]
[[234], [46, 49]]
[]
[[11]]
[[191], [], [76, 242, 1]]
[[]]
[]
[[37]]
[]
[]
[]
[]
[]
[]
[]
[]
[[], [], [], []]
[]
[]
[[]]
[[38, 136, 103], [10]]
[[], [221]]
[]

Quite disappointing for 1s runtime and 100000 min bytes. Not sure if I'm doing something wrong.

@duesee
Copy link
Owner

duesee commented Feb 28, 2024

Hm... What happens if you put an assert!(x.len() < 500) after the println? Hm... nothing.

@jakoschiko
Copy link
Collaborator Author

You can see all (!) generated values in my comment.

@jakoschiko
Copy link
Collaborator Author

My conclusion: arbtest is inherently flawed and we shouldn't use arbitrary for property testing.

arbitrary expects that it is used with some kind of feedback loop for its Unstructured. All collections are generated using this Iterator for generating elements:

impl<'a, ElementType: Arbitrary<'a>> Iterator for ArbitraryTakeRestIter<'a, ElementType> {
    type Item = Result<ElementType>;
    fn next(&mut self) -> Option<Result<ElementType>> {
        let keep_going = self.u.arbitrary().unwrap_or(false);
        if keep_going {
            Some(Arbitrary::arbitrary(&mut self.u))
        } else {
            None
        }
    }
}

If Unstructured is just random bytes, then the collection is very short with a high probabilty. And arbtest is using random bytes. I don't see how arbtest could fix that without mutating into a full-fledged fuzzing tool.

@jakoschiko jakoschiko changed the title Add more flow-test tests Add more integration-test tests Jun 28, 2024
@duesee duesee removed this from the 9.2 -- Higher-level, async-first, IMAP library for client- and server milestone Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants