open-dust / cairo-foundry

Foundry like framework for starknet contracts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mock_call mocked return value should be an array of felt rather than a single felt

tdelabro opened this issue · comments

https://github.com/onlydustxyz/cairo-foundry/blob/main/test_cairo_hints/test_mock_call.cairo#L4-L6

As for now, we can only return a single felt from a mocked call.
func_to_mock should stay as it is.
mock_ret_value should become ptr_mock_ret_value and contain a pointer to a memory address where the first value to return is stored
ptr_mock_ret_value_len should be introduced.

Taken from review (in French):

Je suis sur ta PR mock felt
Le gros problème que je vois c'est qu'on a un deux hints différents et pas de support pour les structs
et aussi qu'on return des pointeurs sans size
Je pense qu'il faudrait 1 seul hint qui gère tout ça
la solution que je vois ça serait de load la signature des différents fonctions du compiled.json dans l'ExecutionScope
Comme ça quand on reçoit la mock_value on sait comment la traiter.
On considère que la mock_value est tjrs une array de felt [felt], d'une longueur inconnue de base, mais connue grace à la signature de la fonction qui nous permet de déduire si c'est un seul felt, une struct (aka une array de felt), ou une paire (size_ptr, ptr*)