-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
keystore: Property based testing #3538
Conversation
License: MIT Signed-off-by: Mateusz Naściszewski <matin1111@wp.pl>
License: MIT Signed-off-by: Mateusz Naściszewski <matin1111@wp.pl>
License: MIT Signed-off-by: Mateusz Naściszewski <matin1111@wp.pl>
License: MIT Signed-off-by: Mateusz Naściszewski <matin1111@wp.pl>
Hrm... This is pretty nice to have. I wonder if we should have this as part of the main go-ipfs codebase, or a separate 'testing' repo that can have must larger and longer tests. I also think we need to take a look at the library in use here to make sure its the one we want to move forward with. |
Regarding using Gopter for property tests, there exists a builtin alternative ( |
Hey @mateon1 thanks for this :) However i'm not sure we want to add 17 seconds (definitely more on slow CI boxes) to the tests, plus i'm always leery of adding new dependencies. That said, gopter seems pretty cool. Any insight on how it compares to https://github.com/dvyukov/go-fuzz ? |
I somehow lost @whyrusleeping 's reply in my notifications, sorry. There is a difference between fuzzing, and property testing. In this PR, I use a pattern I first saw in Erlang automated testing, where you QuickCheck a series of commands, along with a simple state machine of what you expect to happen if these commands run. If there is a mismatch, that might be a potential bug. I don't mind if this is closed and forgotten, as it was mostly just a go at learning gopter (and learning Go). By the way, I'm probably going to have some fun with the go-fuzz thing as well :) |
@mateon1 See my usage of go-fuzz for example in go-cid |
@mateon1 I am trying to clean up PRs so I will close this. |
I'm playing around with property based testing, this PR implements a test that randomly performs
Get(key)
,Put(key, value)
,Delete(key)
andList()
operations, and compares results from the keystore and its internal model. (a map of strings to keys)On my Windows machine the test takes 17s to run, since gopter performs the test 100 times by default.