-
Notifications
You must be signed in to change notification settings - Fork 235
feat: mock_call with dynamic return data #2904
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
ptisserand
wants to merge
20
commits into
foundry-rs:master
Choose a base branch
from
ptisserand:feat/dynamic-mock-call
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+792
−44
Open
Changes from 10 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
0ff1663
feat(snforge_std): add "dynamic" return value for mock_call
ptisserand f21e510
feat(cheatnet): add "dynamic" return value fir mock_call
ptisserand 3c37814
forge: update test to support new mock_call cheatcode
ptisserand d1921ea
fix mock_call test
ptisserand 9594b5a
cheatnet: fixup clippy
ptisserand c097e3c
snforge_std: revert breaking changes on `mock_call`
ptisserand e70b4b1
fix(cheatnet): default to any calldata entry when specific CheatSpan:…
ptisserand 02a7dcd
docs: add `mock_call_when` cheatcode
ptisserand 3498701
use `calldata` instead of `call_data`
ptisserand f4bc282
cheatnet: add MockCalldata enum
ptisserand e15e00f
Merge remote-tracking branch 'upstream/master'
ptisserand 90cff00
fix: add missing argument for run_test_case
ptisserand 2cd43a4
scarb fmt
ptisserand e1293a8
Merge remote-tracking branch 'upstream/master' into feat/dynamic-mock…
ptisserand 2c5ec93
remove workaround for #2927
ptisserand 3aeb496
add test cases with interleaved start/stop mock_call and mock_call_when
ptisserand 1a20bbd
Merge remote-tracking branch 'upstream/master' into feat/dynamic-mock…
ptisserand f235bd7
cargo fmt
ptisserand da9bc28
Merge remote-tracking branch 'upstream/master' into master-merged
ptisserand 3ae2a28
add missing use for cheatcodes
ptisserand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After calling
get_mocked_function_cheat_status
, we call.decrement_cheat_span
on the returned value. It changes the CheatSpan toUncheated
after it decreases to0
.I don't think there can be a case where
TargetCalls
is equal to 0 unless explicitly set to this value somewhere.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this logic match arm was added to handle the case where entrypoint for specific calldata is no longer cheated but for any calldata still is, but it should already be handled by
_
case anyway.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out technically it could be set to
0
but it shouldn't be allowed.Created #2927
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure to understand what should I do here: remove my workaround?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to match for the case where cheat span is
CheatSpan::TargetCalls(0)
. Technically, user could have somehow created it like this (as explained in #2927), but during normal operation it will either beCheatSpan::TargetCalls(some value > 0)
orCheatStatus::Uncheated
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See this
starknet-foundry/crates/cheatnet/src/state.rs
Line 141 in f2e7d0d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workaround removed