Skip to content

Closure cheatcode for interacting with contract_state_for_testing #3331

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
cptartur opened this issue May 12, 2025 · 0 comments
Open

Closure cheatcode for interacting with contract_state_for_testing #3331

cptartur opened this issue May 12, 2025 · 0 comments
Labels

Comments

@cptartur
Copy link
Member

Current State

Currently, contract_state_for_testing doesn't play nicely with normal flow of tests - changes to the storage made through it aren't reflected in the standard test execution (using dispatchers).

The state not being reflected is caused by ContractState returned by contract_state_for_testing using different storage addresses than the contract used by dispatcher (details to be researched, supposedly it assumes the contract address to be 0).

By cheating the contract address, we can make the ContractState work with the normal fow

Objective

Implement the closure cheatcode for interacting with contract_state_for_testing

Additional Context

Example interface should be something along the lines of this

fn modify_state<
    F, 
    +Drop<F>,
    impl func: core::ops::Fn<F, ()>,
>(contract_address: ContractAddress, f: F) -> func::Output {
    // start cheat
    f()
    // end cheat
}
@cptartur cptartur moved this to New in Starknet foundry May 12, 2025
@github-actions github-actions bot added the new label May 12, 2025
@cptartur cptartur removed the new label May 12, 2025
@cptartur cptartur moved this from New to Backlog in Starknet foundry May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Backlog
Development

No branches or pull requests

1 participant