multiformats / rust-multiaddr

multiaddr implementation in rust
https://crates.io/crates/multiaddr
Other
86 stars 45 forks source link

tests/lib: Update `impl Arbitrary for Proto` #65

Closed mxinden closed 1 year ago

mxinden commented 1 year ago

Arbitrary implementation seems to be missing some enum variants.

Protocol has 30 variants. Arbitrary implementation generates 25.

Ideally this would be fixed by removing the need to list every Protocol variant. Though I can not think of a clean way of doing that. Simply updating the Arbitrary implementation seems fine for now.

https://github.com/multiformats/rust-multiaddr/blob/1cfb9239d7447285bfb0f329320945a5e8afabe8/tests/lib.rs#L88-L139

mxinden commented 1 year ago

One option would be to use variant_count to make sure the above 26 doesn't become outdated. @jxs any other ideas?

thomaseizinger commented 1 year ago

One option would be to use variant_count to make sure the above 26 doesn't become outdated. @jxs any other ideas?

That is nightly-only though, right?

thomaseizinger commented 1 year ago

We could add a test that only runs on nightly which asserts a constant that we use in the stable tests and run tests on nightly in CI.