-
Notifications
You must be signed in to change notification settings - Fork 65
starknet_os_flow_tests: migrate test_os_logic and some small refactors #9484
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
starknet_os_flow_tests: migrate test_os_logic and some small refactors #9484
Conversation
58cc596 to
97906d9
Compare
0d96759 to
40cdcc7
Compare
97906d9 to
54669b5
Compare
40cdcc7 to
7ae9c81
Compare
54669b5 to
331d175
Compare
7ae9c81 to
f661e8b
Compare
331d175 to
eccbbad
Compare
b1c6cea to
a010edf
Compare
6ba2a44 to
3de0895
Compare
a010edf to
1460e98
Compare
3de0895 to
ac793d6
Compare
68be87e to
87b8d4e
Compare
ac793d6 to
5f4fc35
Compare
87b8d4e to
4fddda3
Compare
5f4fc35 to
65aee29
Compare
AvivYossef-starkware
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.
Q:
The Py test parametrized with private_keys and os_test_variant. What are the equivalents here?
possible TODOs:
- Use a macro or a function to create calldata with an inner call
- I don't think that the test adds an empty block in the multi-block ( let me know if I`m wrong )
@AvivYossef-starkware reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @meship-starkware and @Yoni-Starkware)
crates/starknet_os_flow_tests/src/initial_state.rs line 306 at r1 (raw file):
nonce, resource_bounds, Felt::ONE,
Suggestion:
// Default salt.
Felt::ONEcrates/starknet_os_flow_tests/src/initial_state.rs line 321 at r1 (raw file):
nonce: Nonce, resource_bounds: ValidResourceBounds, contract_address_salt: Felt,
Suggestion:
contract_address_salt: ContractAddressSaltcrates/starknet_os_flow_tests/src/tests.rs line 419 at r1 (raw file):
.add_cairo0_declare_tx(tx, get_class_hash_of_feature_contract(cairo0_test_contract)); // Deploy some instances of the test contract.
Suggestion:
// Deploy some instances of the deprecated test contract.crates/starknet_os_flow_tests/src/tests.rs line 440 at r1 (raw file):
let calldata = create_calldata( contract_addresses[0], "test_storage_read_write",
Note that in the py test we call set_value but Im ok with that.
Code quote:
test_storage_read_writecrates/starknet_os_flow_tests/src/tests.rs line 495 at r1 (raw file):
if block_number_offset * txs_per_block < test_manager.total_txs() + 1 { block_number_offset += 1; }
I don't think that we add an empty block here, like in split_txs_into_blocks_in_multi_blocks
Code quote:
// Calculate the block number of the next transaction.
let txs_per_block = n_expected_txs / n_blocks_in_multi_block;
// Calculate the block number of tx 'len(txs) + 1' without the added empty block.
let mut block_number_offset = (test_manager.total_txs() + 1) / txs_per_block;
if block_number_offset * txs_per_block < test_manager.total_txs() + 1 {
block_number_offset += 1;
}crates/starknet_os_flow_tests/src/tests.rs line 516 at r1 (raw file):
contract_addresses[0], "test_call_contract", &[**contract_addresses[0], selector_from_name("send_message").0, Felt::ONE, Felt::from(85)],
Suggestion:
// Call contract -> send message to L1.
let inner_selector_name = "test_call_contract";
let inner_calldata = Felt::from(85);
let inner_calldata_len = Felt::ONE;
let calldata = create_calldata(
contract_addresses[0],
"test_call_contract",
&[**contract_addresses[0], selector_from_name("send_message").0, inner_calldata_len, inner_calldata],crates/starknet_os_flow_tests/src/tests.rs line 525 at r1 (raw file):
}; // Test get_contract_address.
Suggestion:
// Test get_caller_address syscall.crates/starknet_os_flow_tests/src/tests.rs line 532 at r1 (raw file):
*contract_addresses[1].0.key(), selector_from_name("test_get_caller_address").0, Felt::ONE,
Suggestion:
Felt::ONE, // Inner calldata len.crates/starknet_os_flow_tests/src/tests.rs line 682 at r1 (raw file):
], ); let signature = TransactionSignature(Arc::new(vec![Felt::from(100)]));
Why is it needed?
Code quote:
let signature = TransactionSignature(Arc::new(vec![Felt::from(100)]));crates/starknet_os_flow_tests/src/tests.rs line 699 at r1 (raw file):
], ); let signature = TransactionSignature(Arc::new(vec![Felt::from(100)]));
Why is it needed?
Code quote:
let signature = TransactionSignature(Arc::new(vec![Felt::from(100)]));4fddda3 to
a6e3a01
Compare
65aee29 to
cd53bd6
Compare
dorimedini-starkware
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.
good catch! this parametrization was added after I migrated the test...
I'll add the private keys parametrization now.
the os_test_variant is unecessary; it's just for converage. I'll update the coverage PR (later in the stack)
as for your questions:
- this, and other improvements (e.g. reduce boilerplate when adding declare/deploy txs), are a good idea, but the stack is already huge; we can do this later :)
- correct, no empty block is added. do you think it's important?
Reviewable status: 2 of 4 files reviewed, 2 unresolved discussions (waiting on @AvivYossef-starkware, @meship-starkware, and @Yoni-Starkware)
crates/starknet_os_flow_tests/src/tests.rs line 495 at r1 (raw file):
Previously, AvivYossef-starkware wrote…
I don't think that we add an empty block here, like in
split_txs_into_blocks_in_multi_blocks
yes, this is why the expected_block_number has the -1
crates/starknet_os_flow_tests/src/tests.rs line 682 at r1 (raw file):
Previously, AvivYossef-starkware wrote…
Why is it needed?
seems it really doesn't test anything interesting (was like this in the original test), removed
crates/starknet_os_flow_tests/src/tests.rs line 699 at r1 (raw file):
Previously, AvivYossef-starkware wrote…
Why is it needed?
ditto
crates/starknet_os_flow_tests/src/tests.rs line 516 at r1 (raw file):
contract_addresses[0], "test_call_contract", &[**contract_addresses[0], selector_from_name("send_message").0, Felt::ONE, Felt::from(85)],
how about like this? better?
AvivYossef-starkware
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.
- Sababa
- @meship-starkware WDYT?
@AvivYossef-starkware reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware, @meship-starkware, and @Yoni-Starkware)
crates/starknet_os_flow_tests/src/tests.rs line 516 at r1 (raw file):
Previously, dorimedini-starkware wrote…
how about like this? better?
Yes
AvivYossef-starkware
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.
Reviewable status:
complete! all files reviewed, all discussions resolved (waiting on @meship-starkware and @Yoni-Starkware)
dorimedini-starkware
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.
good catch! this parametrization was added after I migrated the test...
I'll add the private keys parametrization now.
the os_test_variant is unecessary; it's just for converage. I'll update the coverage PR (later in the stack)
as for your questions:
- this, and other improvements (e.g. reduce boilerplate when adding declare/deploy txs), are a good idea, but the stack is already huge; we can do this later :)
- correct, no empty block is added. do you think it's important?
Reviewable status:
complete! all files reviewed, all discussions resolved (waiting on @meship-starkware and @Yoni-Starkware)
a6e3a01 to
5309233
Compare
cd53bd6 to
bce8534
Compare
dorimedini-starkware
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.
@dorimedini-starkware reviewed 1 of 1 files at r3, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @meship-starkware and @Yoni-Starkware)
|
Artifacts upload workflows: |
dorimedini-starkware
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.
@dorimedini-starkware reviewed 1 of 4 files at r1, 2 of 2 files at r2, 10 of 10 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @meship-starkware and @Yoni-Starkware)

No description provided.