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

feat(dyn-abi): add arbitrary impls and proptests #175

Merged
merged 10 commits into from
Jul 6, 2023
Merged

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Jul 4, 2023

Motivation

  • impl Arbitrary (both ::arbitrary and proptest) for dyn-abi enums and fuzz test them with proptest.
  • add benchmark for DynSolType::{parse,sol_type_name}
  • add more examples and doctests

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@DaniPopes DaniPopes changed the base branch from main to dani/dyn-improvements July 4, 2023 19:40
@DaniPopes DaniPopes changed the base branch from dani/dyn-improvements to main July 4, 2023 19:57
@DaniPopes DaniPopes marked this pull request as ready for review July 4, 2023 19:59
@DaniPopes DaniPopes requested a review from prestwich as a code owner July 4, 2023 19:59
@DaniPopes DaniPopes marked this pull request as draft July 4, 2023 20:07
@DaniPopes DaniPopes marked this pull request as ready for review July 6, 2023 13:03
Comment on lines +48 to 52
EIP-712:

assert_eq!(decoded, my_values);
```rust,ignore
todo!()
```
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have an example for this anywhere? if not can you add one @prestwich

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still stewing on the interface, so i haven't wanted to write an example that will churn. the basic thing right now is "just deser the json"

#[inline]
pub fn as_tuple(&self) -> Option<&[Self]> {
match self {
Self::Tuple(t) => Some(t),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this use the. as_tuple macro or have similar behavior?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I think the as_<variant> should only return the variant

}
}

/// Returns wheter this type is contains a custom struct.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wheter

should this function only exist if the feature is enabled?

Copy link
Member Author

@DaniPopes DaniPopes Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want these to be available always, cfg is already annoying as it is with just one variant, especially inside of this crate itself

/// Fallible cast to the contents of a variant.
#[inline]
#[allow(clippy::missing_const_for_fn)]
pub fn as_custom_struct(&self) -> Option<(&str, &[String], &[Self])> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this function only exist if the feature is enabled?

Copy link
Member

@prestwich prestwich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glad i didn't write this code 🖖

@DaniPopes DaniPopes merged commit 1c2373e into main Jul 6, 2023
@DaniPopes DaniPopes deleted the dani/dyn-proptests branch July 6, 2023 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants