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

Support for e2e tests in cairo with devnet #389

Closed
cptartur opened this issue Aug 3, 2023 · 10 comments
Closed

Support for e2e tests in cairo with devnet #389

cptartur opened this issue Aug 3, 2023 · 10 comments
Labels
feature New feature request/description

Comments

@cptartur
Copy link
Member

cptartur commented Aug 3, 2023

On Starknet, when calling contracts using starknet_call RPC method (without an account) info methods like get_caller_address etc. return default valeus e.g. 0. There is no transaction and block context.

However this is impossible to do in Starknet Foundry. It doesn't matter if the method accepts @ContractState or ref ContractState, we are always executing the method in cheated context - all cheatcoded values are present,get_caller_address returns non 0 value etc.

It should be possible to emulate starknet_call in Foundry. We should either change the behavior of Dispatchers or introduce a separate method for just calling contracts.

@cptartur cptartur converted this from a draft issue Aug 3, 2023
@cptartur cptartur added bug Something isn't working snforge and removed bug Something isn't working labels Aug 3, 2023
@cptartur cptartur changed the title Calling contracts is inconsistent with Starknet It is impossible to emulate starknet_call RPC method in Foundry Aug 3, 2023
@cptartur cptartur added the new label Aug 3, 2023
@MaksymilianDemitraszek
Copy link
Member

It should be possible to emulate starknet_call in Foundry.

I think it shouldn't, at least in the standard test target. Standard test target and dispatchers should operate on contract execution layer not on the transaction layer. Why? Because of use-cases like account testing (transaction layer assumes existence of an account) and testing contract designed to be called from other contracts.

We could consider introducing additional target #devnet-tests (name TBD) which could provide call and invoke dispatchers and take targetted devent url as argument which those be executed on.

@cptartur
Copy link
Member Author

cptartur commented Aug 4, 2023

I think it should be at least noted somewhere in the docs that calling in forge never behaves like starknet_call rpc method because it's not obvious. And I think protostars call did behave like an rpc call, so it may be confusing for the users migrating from that tool.

We could consider introducing additional target #devnet-tests (name TBD) which could provide call and invoke dispatchers and take targetted devent url as argument which those be executed on

We should definitely support that somehow.

@MaksymilianDemitraszek
Copy link
Member

MaksymilianDemitraszek commented Aug 4, 2023

And I think protostars call did behave like an rpc call, so it may be confusing for the users migrating from that tool.

Cairo 1 Protostar did, Protostar 0 didn't

@Arcticae Arcticae moved this from Triage to Backlog in Starknet foundry Aug 8, 2023
@Arcticae Arcticae removed the new label Aug 8, 2023
@Arcticae
Copy link
Contributor

Isn't this related to #18 somehow?
We could run deployment scripts on a local node and achieve the behavior you mean @cptartur

@Arcticae Arcticae added general and removed snforge labels Aug 25, 2023
@Arcticae
Copy link
Contributor

Moving this to general

@cptartur
Copy link
Member Author

This task is mostly about the whole discussion about the call/invoke architecture in tests as well as stateful tests. Not sure what component it should be attached to, perhaps both cheatnet and forge?

@piotmag769
Copy link
Member

Is it still relevant? @cptartur @MaksymilianDemitraszek

@cptartur
Copy link
Member Author

cptartur commented Sep 7, 2023

I think it kind of still is? In case we want to add some tests in the future that are not in the invoke transaction context.

@MaksymilianDemitraszek MaksymilianDemitraszek changed the title It is impossible to emulate starknet_call RPC method in Foundry support for e2e tests in cairo with devnet Sep 11, 2023
@MaksymilianDemitraszek MaksymilianDemitraszek changed the title support for e2e tests in cairo with devnet Support for e2e tests in cairo with devnet Sep 11, 2023
@MaksymilianDemitraszek MaksymilianDemitraszek added the feature New feature request/description label Sep 11, 2023
@MaksymilianDemitraszek
Copy link
Member

Renaming it to be more accurate

@cptartur cptartur moved this from Backlog to Triage in Starknet foundry Sep 28, 2023
@piotmag769 piotmag769 moved this from Triage to TODO in Starknet foundry Oct 24, 2023
@cptartur cptartur moved this from TODO to Triage in Starknet foundry Oct 24, 2023
@cptartur
Copy link
Member Author

cptartur commented Dec 7, 2023

Duplicate of #1033

@cptartur cptartur marked this as a duplicate of #1033 Dec 7, 2023
@cptartur cptartur closed this as not planned Won't fix, can't repro, duplicate, stale Dec 7, 2023
@github-project-automation github-project-automation bot moved this from Triage to Done in Starknet foundry Dec 7, 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

No branches or pull requests

4 participants