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

chore: split the inner tx creator in blockifier test utils #660

Merged

Conversation

ArniStarkware
Copy link
Contributor

@ArniStarkware ArniStarkware commented Aug 29, 2024

This change is Reviewable

Copy link
Contributor Author

ArniStarkware commented Aug 29, 2024

Copy link

codecov bot commented Aug 29, 2024

Codecov Report

Attention: Patch coverage is 98.61111% with 1 line in your changes missing coverage. Please review.

Project coverage is 71.05%. Comparing base (c65f0b9) to head (4da7b0c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/blockifier/src/test_utils/declare.rs 97.95% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #660      +/-   ##
==========================================
- Coverage   75.83%   71.05%   -4.79%     
==========================================
  Files         352       85     -267     
  Lines       37423    10944   -26479     
  Branches    37423    10944   -26479     
==========================================
- Hits        28381     7776   -20605     
+ Misses       6726     2780    -3946     
+ Partials     2316      388    -1928     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ArniStarkware ArniStarkware force-pushed the arni/test_utils/tx_creator/split_inner_function branch 2 times, most recently from ce2991d to aa4e955 Compare September 1, 2024 10:33
@ArniStarkware ArniStarkware force-pushed the arni/test_utils/tx_creator/split_inner_function branch from aa4e955 to 3999ccf Compare September 1, 2024 14:44
@ArniStarkware ArniStarkware force-pushed the arni/test_utils/tx_creator/split_inner_function branch 2 times, most recently from a605f67 to d801238 Compare September 3, 2024 15:34
@ArniStarkware ArniStarkware force-pushed the arni/test_utils/tx_creator/split_inner_function branch from d801238 to 8d55175 Compare September 3, 2024 16:17
Copy link
Contributor

@MohammadNassar1 MohammadNassar1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArniStarkware)


crates/blockifier/src/test_utils/declare.rs line 78 at r1 (raw file):

}

fn inner_declare_tx(

Please change the order of the functions.
First, public methods, then private functions.

Also relevant for the below files.

Code quote:

fn inner_declare_tx(

Copy link
Contributor

@MohammadNassar1 MohammadNassar1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArniStarkware)


crates/blockifier/src/test_utils/declare.rs line 78 at r1 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Please change the order of the functions.
First, public methods, then private functions.

Also relevant for the below files.

If you plan to move this function to the sn-api crate, there is no need to reorder them in this PR.

@ArniStarkware ArniStarkware force-pushed the arni/test_utils/tx_creator/split_inner_function branch from 8d55175 to 53ca21d Compare September 5, 2024 10:50
Copy link
Contributor Author

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, all discussions resolved (waiting on @MohammadNassar1)


crates/blockifier/src/test_utils/declare.rs line 78 at r1 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

If you plan to move this function to the sn-api crate, there is no need to reorder them in this PR.

already done :) but TY!

Copy link
Contributor

@MohammadNassar1 MohammadNassar1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @ArniStarkware)


crates/blockifier/src/test_utils/invoke.rs line 83 at r2 (raw file):

    let default_tx_hash = TransactionHash::default();
    match only_query {

No need for additional variable.

Suggestion:

    let invoke_tx = inner_invoke_tx(invoke_args);

    let default_tx_hash = TransactionHash::default();
    match invoke_args.only_query {

Copy link
Contributor

@MohammadNassar1 MohammadNassar1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ArniStarkware)


crates/blockifier/src/test_utils/deploy_account.rs line 88 at r2 (raw file):

    let tx = inner_deploy_account_tx(deploy_tx_args, nonce_manager.next(contract_address));

    DeployAccountTransaction::new(tx, TransactionHash::default(), contract_address)

Do you know why the invoke and deploy account do not have a tx hash field, while declare does?

Code quote:

TransactionHash::default()

@ArniStarkware ArniStarkware force-pushed the arni/test_utils/tx_creator/split_inner_function branch from 53ca21d to b725862 Compare September 5, 2024 13:50
Copy link
Contributor Author

@ArniStarkware ArniStarkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 3 files reviewed, all discussions resolved (waiting on @MohammadNassar1)


crates/blockifier/src/test_utils/deploy_account.rs line 88 at r2 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

Do you know why the invoke and deploy account do not have a tx hash field, while declare does?

I don't know. Let us keep the option available and streamline the util across tx types.
I did not find why this util is used in declare - I see no instance of it's use (I deleted it and the blockifier's tests passed).


crates/blockifier/src/test_utils/invoke.rs line 83 at r2 (raw file):

Previously, MohammadNassar1 (mohammad-starkware) wrote…

No need for additional variable.

Your suggestion yields this error.

error[E0382]: use of moved value: `invoke_args`
  --> crates/blockifier/src/test_utils/invoke.rs:82:5
   |
78 | pub fn invoke_tx(invoke_args: InvokeTxArgs) -> InvokeTransaction {
   |                  ----------- move occurs because `invoke_args` has type `test_utils::invoke::InvokeTxArgs`, which does not implement the `Copy` trait
79 |     let invoke_tx = inner_invoke_tx(invoke_args);
   |                                     ----------- value moved here
...
82 |     match invoke_args.only_query {

#rust_things #blessed.

@ArniStarkware ArniStarkware force-pushed the arni/test_utils/tx_creator/split_inner_function branch from b725862 to 4da7b0c Compare September 5, 2024 14:47
Copy link
Contributor

@MohammadNassar1 MohammadNassar1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 3 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ArniStarkware)


crates/blockifier/src/test_utils/invoke.rs line 83 at r2 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

Your suggestion yields this error.

error[E0382]: use of moved value: `invoke_args`
  --> crates/blockifier/src/test_utils/invoke.rs:82:5
   |
78 | pub fn invoke_tx(invoke_args: InvokeTxArgs) -> InvokeTransaction {
   |                  ----------- move occurs because `invoke_args` has type `test_utils::invoke::InvokeTxArgs`, which does not implement the `Copy` trait
79 |     let invoke_tx = inner_invoke_tx(invoke_args);
   |                                     ----------- value moved here
...
82 |     match invoke_args.only_query {

#rust_things #blessed.

OMG

Copy link
Contributor Author

ArniStarkware commented Sep 8, 2024

Merge activity

@ArniStarkware ArniStarkware merged commit 2395f9a into main Sep 8, 2024
16 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants