Replies: 2 comments 10 replies
-
Great work in formalising ideas! Open questions:
|
Beta Was this translation helpful? Give feedback.
-
The part of the code that needs that detects whether it's a Cairo test or StarkNet code needs to be in the plugin of the Cargo-like tool. Pure Cairo tests should be run by Cairo Test Runner. There are many unknowns. I am not sure the impact of Cairo 1 on this change. How do you want to inject "the StarkNet fixture" into a test? Are we going to provide cheatcodes through hints or should we avoid them because they can cause issues with a language server? Can you provide an example how StarkNet tests are going to look like? I'd create a new Protostar component to implement new StarkNet tests. Before creating this functionality, I'd like to clearly assign responsibilities to containers. C1 and C2 diagrams from the C4 Model: |
Beta Was this translation helpful? Give feedback.
-
Background
In order to prepare for coming plugin system from the cairo 1.0 package manager (cargo-like tool), we are considering migrating away from the existing flow of testing in order to align the targets with the said project.
Terms:
Facts:
Current state
The testing flow is now basing on deploying the contracts into local in-memory SNTF as a test contract, even if no satellite external contracts are used.
Pros:
Cons:
The division of testing
In order to achieve better performance and cacheability, we need to differentiate somehow between integration and unit tests on the level of code, configuration or infer it automatically. This is needed in case we want to save the SNTF state and load it from file (loading cache).
The drawing below shows a separate flows for Starknet and Cairo tests, in which the Cairo tests act as a bundle of code, not connected with SNTF at all, and just runs on a Cairo VM (rust or a python one - depending on available implementation).
Following approach has a few properties:
storage_var
s will be no more in pure Cairo tests - it will apply only to StarkNet tests, because it doesn't make sense to build the whole context, making the tests logic just more confusing. Althoughstorage_var
s will no longer exists, we want to supportstore/load
cheatcodes in that approach. We could also consider an approach where storage is mocked automatically (or with a flag passed to the test), to make testing functions withstorage_var
usage easier (@MaksymilianDemitraszek review needed).Presented architecture is a draft and might change in the future.
Beta Was this translation helpful? Give feedback.
All reactions