-
Notifications
You must be signed in to change notification settings - Fork 153
Migrate remaining e2e test utilities to alloy primitives #4001
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
Conversation
MartinquaXD
left a comment
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.
Probably makes sense to still address the impersonation topic in this PR.
jmg-duarte
left a comment
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.
LGTM asides the impersonation question, IMO we can either revert the change on the API and merge the rest of the PR; or fix it now
crates/e2e/src/nodes/forked_node.rs
Outdated
| Ok(()) | ||
| } | ||
|
|
||
| pub fn set_chain_id(&self, chain_id: u64) -> CallFuture<(), T::Out> { |
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.
This function is unused, IMO we can remove this
crates/e2e/src/nodes/forked_node.rs
Outdated
| pub fn set_balance(&self, address: &Address, balance: U256) -> CallFuture<(), T::Out> { | ||
| let json_address = serde_json::json!(address); | ||
| let json_balance = serde_json::json!(format!("{:#032x}", balance)); |
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.
Nerd nit: if you expand the macro you'll see that json! simply calls serde_json::to_value (at least for these two cases)
But it also makes the value you pass, a reference, meaning address becomes a double reference (&&Address)
Unlike other parts of the codebase, where address is immediately de-referenced turning it into a copy, here we can simply remove the macro (which usually hides more magic than in this case) use the expanded API and avoid a double reference
For the second call, we could do .as_str() or just the reference even.
I know this is not directly related to the migration, but a migration is the perfect opportunity to improve the codebase like this
# Description Discussed in this thread: #4001 (comment) This PR moves the impersonation mechanisms to alloy, the migrated ones are only impersonated in the specific transaction, no changes to the actual tests were needed. Exposed the previous string oriented API under a trait to as discussed in a comment below. Anvil provides an anvil specific API that we're not using unless necessary as these ones are more general # Changes - [ ] Migrate the last `mine_pending_block` - [ ] Migrate the other evm calls to the new trait - [ ] Migrate the last impersonations - [ ] Remove the forked_node and local_node modules ## How to test Existing tests
|
This pull request has been marked as stale because it has been inactive a while. Please update this pull request or it will be automatically closed. |
Signed-off-by: Aryan Godara <aryangodara03@gmail.com>
70092ec to
47bf347
Compare
Description
Migrates internal
ethcontracttypes toalloyprimitives within thee2ecrate, reducing reliance on legacy types.Changes
ethcontract::primitiveswithalloy::primitivesAccountreturn was unused; alloy handles impersonation via provider without wallet +.from(address); now returning unit (), since function's return value wasn't being used.into_legacy()/into_alloy()conversionsNote:
ethcontractdependency remains for shared crate compatibility.How to test
cargo check -p e2e --tests