Open odesenfans opened 7 months ago
For the first point, the VirtualMachine
methods set_ap
, set_fp
and set_pc
are public, they are hidden from the docs but they should be safe to use in tests.
And I agree that some testing macros could be made public under the test_utils
feature (particularly the segments
and memory
macros as their usage is not tied to knowing how the vm works internally)
The problem with segments!
is that it requires vm.segments
to be public as well. I can make a PR and we can discuss it there if this suits you.
Hello,
We're currently developing some hints for a project. These hints live in a different Git repository. We developed hints for the bootloader in a fork of
cairo-vm
so I hadn't noticed yet, but it is surprisingly way more difficult to write unit tests out of the repository. Example:If we take a hint
We can easily write a unit test for this in the
cairo-vm
repository like this:But out of tree, things become more complex / impossible.
So we're in a situation where AP/FP manipulations are impossible because of VM members being
pub(crate)
and the utils macros are not public so they need to be reimplemented manually.The first point is the one that actually is blocking, so I would like your opinion on the matter. What's a good solution there? Making VM fields
pub
instead ofpub(crate)
? Adding accessors? Another solution I have not thought of?Describe the solution you'd like Ideally, it should be possible to write unit tests the same way independently of where the implementation lives.
Additional context This is related to the implementation of hints for the bootloader and Starknet OS.