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

test: add tests for add tx on declare tx #235

Merged
merged 1 commit into from
Jun 30, 2024

Conversation

ArniStarkware
Copy link
Contributor

@ArniStarkware ArniStarkware commented Jun 10, 2024

This change is Reviewable

Copy link
Contributor Author

ArniStarkware commented Jun 10, 2024

@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.21%. Comparing base (c1827fc) to head (a70795b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #235      +/-   ##
==========================================
+ Coverage   76.98%   83.21%   +6.22%     
==========================================
  Files          28       28              
  Lines        1382     1382              
  Branches     1382     1382              
==========================================
+ Hits         1064     1150      +86     
+ Misses        265      173      -92     
- Partials       53       59       +6     

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

@ArniStarkware ArniStarkware force-pushed the arni/declare/compile_in_gateway branch from bfed131 to 6b57043 Compare June 13, 2024 05:50
@ArniStarkware ArniStarkware force-pushed the arni/declare/compile/tests branch 2 times, most recently from 480bd63 to 3d3c37b Compare June 13, 2024 06:05
@ArniStarkware ArniStarkware force-pushed the arni/declare/compile_in_gateway branch from 6b57043 to 7557759 Compare June 13, 2024 07:36
Copy link
Contributor

@Yael-Starkware Yael-Starkware 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 6 files reviewed, 1 unresolved discussion (waiting on @ArniStarkware and @dafnamatsry)


crates/gateway/src/starknet_api_test_utils.rs line 96 at r2 (raw file):

pub fn declare_tx() -> ExternalTransaction {
    env::set_current_dir(get_absolute_path(TEST_FILES_FOLDER)).expect("Couldn't set working dir.");
    let json_file_path = Path::new(DECLARE_V3_TX_FILE);

I don't think we should take the transaction from a json file, we should create it in the code as we do with invoke.

Copy link
Contributor

@Yael-Starkware Yael-Starkware 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 6 files reviewed, 1 unresolved discussion (waiting on @ArniStarkware and @dafnamatsry)


crates/gateway/src/starknet_api_test_utils.rs line 96 at r2 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

I don't think we should take the transaction from a json file, we should create it in the code as we do with invoke.

(and also as in deploy_account - PR https://reviewable.io/reviews/starkware-libs/mempool/239#-)

@ArniStarkware
Copy link
Contributor Author

crates/gateway/src/starknet_api_test_utils.rs line 96 at r2 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

(and also as in deploy_account - PR https://reviewable.io/reviews/starkware-libs/mempool/239#-)

The difference between Invoke/DeployAccount and Declare is that the declare tx is much bigger. The Sierra program is long.

I agree - this is also bad for consistency.
I think the solution is to load from a json only the contract_class / only the sierra_program.
WDYT?

Copy link
Contributor

@Yael-Starkware Yael-Starkware 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 6 files reviewed, 1 unresolved discussion (waiting on @ArniStarkware and @dafnamatsry)


crates/gateway/src/starknet_api_test_utils.rs line 96 at r2 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

The difference between Invoke/DeployAccount and Declare is that the declare tx is much bigger. The Sierra program is long.

I agree - this is also bad for consistency.
I think the solution is to load from a json only the contract_class / only the sierra_program.
WDYT?

I agree.

@ArniStarkware ArniStarkware force-pushed the arni/declare/compile_in_gateway branch from af43060 to 42eaf2b Compare June 17, 2024 13:39
@ArniStarkware ArniStarkware force-pushed the arni/declare/compile_in_gateway branch from 42eaf2b to f3b59f6 Compare June 18, 2024 11:12
@ArniStarkware ArniStarkware force-pushed the arni/declare/compile_in_gateway branch from f3b59f6 to 71b97d2 Compare June 19, 2024 11:13
@ArniStarkware ArniStarkware force-pushed the arni/declare/compile/tests branch 2 times, most recently from 7a0d0e9 to 05f268b Compare June 19, 2024 11:17
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 7 files reviewed, 1 unresolved discussion (waiting on @dafnamatsry and @Yael-Starkware)


crates/gateway/src/starknet_api_test_utils.rs line 96 at r2 (raw file):

Previously, Yael-Starkware (YaelD) wrote…

I agree.

Done.

@ArniStarkware ArniStarkware changed the title test: Add tests for add tx on declare tx test: add tests for add tx on declare tx Jun 19, 2024
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: 1 of 8 files reviewed, all discussions resolved (waiting on @dafnamatsry and @Yael-Starkware)


crates/gateway/src/stateful_transaction_validator_test.rs line 28 at r7 (raw file):

    local_test_state_reader_factory(CairoVersion::Cairo1, false),
    Ok(TransactionHash(StarkFelt::try_from(
        "0x007d70505b4487a4e1c1a4b4e4342cb5aa9e73b86d031891170c45a57ad8b4e6"

why was this hash affected?

Code quote:

       "0x007d70505b4487a4e1c1a4b4e4342cb5aa9e73b86d031891170c45a57ad8b4e6"

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: 1 of 8 files reviewed, all discussions resolved (waiting on @dafnamatsry and @Yael-Starkware)


crates/gateway/src/stateful_transaction_validator_test.rs line 28 at r7 (raw file):

Previously, ArniStarkware (Arnon Hod) wrote…

why was this hash affected?

Because I changed VALID_L1_GAS_MAX_AMOUNT.

@ArniStarkware ArniStarkware force-pushed the arni/declare/compile_in_gateway branch from dc20f13 to 7c93ecc Compare June 25, 2024 13:38
@ArniStarkware ArniStarkware force-pushed the arni/declare/compile/tests branch 2 times, most recently from d7aba7b to d628146 Compare June 25, 2024 13:49
@ArniStarkware ArniStarkware changed the base branch from arni/declare/compile_in_gateway to main June 25, 2024 13:50
Copy link
Contributor

@Yael-Starkware Yael-Starkware left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 7 files at r5, 5 of 5 files at r7, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @dafnamatsry)

Copy link
Collaborator

@dafnamatsry dafnamatsry 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 7 files at r5, 5 of 5 files at r7, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ArniStarkware)


crates/gateway/src/gateway_test.rs line 74 at r7 (raw file):

    local_test_state_reader_factory_for_deploy_account(&tx)
)]
#[case::declare_tx(declare_tx(), local_test_state_reader_factory(CairoVersion::Cairo1, false))]

to be consistent with the other test cases.

Suggestion:

valid_declare_tx

crates/gateway/src/gateway_test.rs line 102 at r7 (raw file):

    assert_eq!(tx_hash, serde_json::from_slice(response_bytes).unwrap());
}

Please add a test for bad declare tx (bad sierra program).


crates/gateway/src/starknet_api_test_utils.rs line 102 at r7 (raw file):

    let cairo_version = CairoVersion::Cairo1;
    let account_contract = FeatureContract::AccountWithoutValidations(cairo_version);

Suggestion:

    let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1);

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: 6 of 8 files reviewed, 3 unresolved discussions (waiting on @dafnamatsry and @Yael-Starkware)


crates/gateway/src/gateway_test.rs line 74 at r7 (raw file):

Previously, dafnamatsry wrote…

to be consistent with the other test cases.

Done.


crates/gateway/src/gateway_test.rs line 102 at r7 (raw file):

Previously, dafnamatsry wrote…

Please add a test for bad declare tx (bad sierra program).

I think it is redundant, as there are unit tests for the compile util.

Anyway - Covered in #246.


crates/gateway/src/starknet_api_test_utils.rs line 102 at r7 (raw file):

    let cairo_version = CairoVersion::Cairo1;
    let account_contract = FeatureContract::AccountWithoutValidations(cairo_version);

Done.

Copy link
Collaborator

@dafnamatsry dafnamatsry left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r8, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Yael-Starkware)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants