Skip to content

Fuzz tests ERC1155 #1348

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

immrsd
Copy link
Collaborator

@immrsd immrsd commented Feb 25, 2025

Adds fuzz test cases for ERC1155

@immrsd immrsd requested a review from ericnordelo February 25, 2025 12:56
@immrsd immrsd self-assigned this Feb 25, 2025
Copy link

codecov bot commented Feb 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.42%. Comparing base (5ab73fe) to head (930399d).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1348   +/-   ##
=======================================
  Coverage   89.42%   89.42%           
=======================================
  Files          81       81           
  Lines        3500     3500           
=======================================
  Hits         3130     3130           
  Misses        370      370           
Files with missing lines Coverage Δ
packages/testing/src/common.cairo 100.00% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ab73fe...930399d. Read the comment docs.

Copy link
Member

@ericnordelo ericnordelo left a comment

Choose a reason for hiding this comment

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

The PR looks good @immrsd, but let's use 0.38.0 feature for fuzzing to avoid the extra boilerplate.

values: Span<u256>,
}

fn prepare_tokens(ids_len_seed: u32, value_mult_seed: u32) -> TokenList {
Copy link
Member

Choose a reason for hiding this comment

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

We should be able to avoid this by using the new Fuzzing derivable trait from foundry 0.38.0. Let's update that before merging this to avoid the extra boilerplate.

@@ -71,3 +71,13 @@ pub fn assert_entrypoint_not_found_error<T, +Drop<T>>(
panic!("{selector} call was expected to fail, but succeeded");
}
}

/// Creates and returns a new array consisting of the given `element` repeated `n_times` times.
pub fn repeat<T, N, +Copy<T>, +Drop<T>, +Into<N, u256>>(element: T, n_times: N) -> Array<T> {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should export this as part of our external API from testing, it should be an internal test_common item instead. We don't want the testing API to grow to big, so we should include utilities that will be potentially often used, and I think this is not the case.

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