This repository was archived by the owner on Oct 19, 2024. It is now read-only.
Conversation
84c99a2 to
a4405f8
Compare
a4405f8 to
2e05148
Compare
mattsse
suggested changes
Feb 24, 2022
| assert_eq!(res, 100.into()); | ||
|
|
||
| assert!(!provider.cache().unwrap().requests.is_empty()); | ||
| dbg!(&provider.cache()); |
Collaborator
There was a problem hiding this comment.
Suggested change
| dbg!(&provider.cache()); |
|
|
||
| impl Drop for Cache { | ||
| fn drop(&mut self) { | ||
| let file = match File::options().write(true).read(true).create(true).open(&self.path) { |
Collaborator
There was a problem hiding this comment.
this should be File::create? which
Opens a file in write-only mode. reate a file if it does not exist, and will truncate it if it does.
| pub struct Cache { | ||
| path: PathBuf, | ||
| // serialized request / response pair | ||
| requests: DashMap<String, String>, |
Collaborator
There was a problem hiding this comment.
should this be <String, serde_json::Value>?
Owner
Author
|
@brockelmore curious what you think on this approach? |
Contributor
|
Depending on how forge implements its caching strategy, it might be useful to have a way to clear the cache |
Owner
Author
|
Closing - will make it part of the Forking provider on Foundry https://github.com/gakonst/foundry/pull/835 |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
We want to avoid repeating requests which we expect to have the same response. This is useful when used together with Forge's mainnet forking tests.
Solution
Add a
Cachewhich stores all request/responses pairs in-memory, which then proceeds to store them in disk when it gets Dropped