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

Loading test data from files #242

Closed
akirillo opened this issue Jul 20, 2023 · 4 comments · Fixed by #445
Closed

Loading test data from files #242

akirillo opened this issue Jul 20, 2023 · 4 comments · Fixed by #445
Assignees
Labels
feature New feature request/description

Comments

@akirillo
Copy link

akirillo commented Jul 20, 2023

To what component is your bug related to?

Forge

Feature Request

Overview

Being able to read in test data from an external source, e.g. even just a flat file, would enable a massive unlock in testing flexibility while allowing developers to avoid the overhead of running a devnet node / blockifier / starknet_in_rust.

Use cases

Testing against reference implementations

This is my current use case. I have some rather complex Cairo code (we're doing Bulletproofs verification) that I would like to test against a reference implementation in another language.

This is generally a good practice for cryptographic code, other examples can include testing equivalency of the implementation of a hashing function, or of cryptographic data structures such as Merkle trees.

Integration testing

Something else I'd like to do - integration testing across a product stack that spans across more than just a system of smart contracts. In my case, I want to test the end-to-end flow of generating a ZKP -> verifying it in my smart contract.

Quick iteration on unimplemented features

This can be used to work around testing features that are not yet implemented in Starknet-Foundry. Like fuzzing, for example - I could generate fuzzed test data using e.g. Rust, write it to a flat file, and read it into my tests.

Potential implementation paths

I think the best initial approach is the simplest one - read in test data that is already calldata-serialized from a flat file. Testing functions can accept parameters - honestly, even just a single parameter (it can be an array/tuple if multiple values are necessary) - into which the calldata is deserialized. Of course, params must implement Serde.

Obviously, I defer to the maintainers on the desired implementation paths should this issue be taken on, I have little context on how Starknet-Foundry was built.

I'm not familiar with Foundry so I don't know if it implements something like this, but if there are any similar patterns for test data generation there, seems like a good place to start :)

@akirillo
Copy link
Author

Ah, looks like Foundry has a precedent for this with its file cheatcodes: https://book.getfoundry.sh/cheatcodes/fs

@ftupas
Copy link

ftupas commented Jul 26, 2023

Would be great to be able to use JSON based input for test data, as long as it's respecting Cairo context (range checks, string length, etc.).

@Arcticae
Copy link
Contributor

Also, see:
foundry-rs/foundry#858

@piotmag769 piotmag769 moved this from Triage to Backlog in Starknet foundry Jul 27, 2023
@MaksymilianDemitraszek MaksymilianDemitraszek changed the title Forge: Importing test data Loading test data from files Jul 31, 2023
@MaksymilianDemitraszek MaksymilianDemitraszek added the feature New feature request/description label Jul 31, 2023
@cptartur cptartur moved this from Backlog to TODO in Starknet foundry Aug 3, 2023
@cptartur cptartur moved this from TODO to Backlog in Starknet foundry Aug 3, 2023
@cptartur
Copy link
Member

cptartur commented Aug 3, 2023

Must be resolved before we start this #397

@piotmag769 piotmag769 moved this from Backlog to TODO in Starknet foundry Aug 8, 2023
@piotmag769 piotmag769 removed the blocked label Aug 8, 2023
@piotmag769 piotmag769 self-assigned this Aug 8, 2023
@piotmag769 piotmag769 moved this from TODO to In Progress in Starknet foundry Aug 9, 2023
@piotmag769 piotmag769 linked a pull request Aug 9, 2023 that will close this issue
5 tasks
@github-project-automation github-project-automation bot moved this from In Progress to Done in Starknet foundry Aug 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature request/description
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants