-
Notifications
You must be signed in to change notification settings - Fork 11
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 deploy_account to integration test #302
test: add deploy_account to integration test #302
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #302 +/- ##
==========================================
+ Coverage 81.76% 82.77% +1.01%
==========================================
Files 30 30
Lines 1431 1469 +38
Branches 1431 1469 +38
==========================================
+ Hits 1170 1216 +46
+ Misses 201 193 -8
Partials 60 60 ☔ View full report in Codecov by Sentry. |
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.
Reviewed 2 of 5 files at r1.
Reviewable status: 2 of 5 files reviewed, 3 unresolved discussions (waiting on @dafnamatsry, @giladchase, and @Yael-Starkware)
crates/tests-integration/src/state_reader.rs
line 60 at r1 (raw file):
ContractAddress::default(), ) .unwrap()
What do you think about wrapping this into a function as a test util?
Suggestion:
let deploy_account_tx = assert_matches!(
deploy_tx,
RPCTransaction::DeployAccount(deploy_account_tx) => deploy_account_tx
);
return deployed_account_contract_address(deploy_account_tx);
fn deployed_account_contract_address(deploy_account_tx: RPCDeployAccountTransaction) -> ContractAddress {
let RPCDeployAccountTransaction::V3(tx) = deploy_account_tx;
calculate_contract_address(
tx.contract_address_salt,
tx.class_hash,
&tx.constructor_calldata,
ContractAddress::default(),
)
.unwrap()
}
crates/tests-integration/src/state_reader.rs
line 62 at r1 (raw file):
.unwrap() }; }
Do we have other examples for this? Is there something I can look for a reference?
(Nice!)
Code quote:
lazy_static! {
static ref DEPLOY_ACCCOUNT_TX_CONTRACT_ADDRESS: ContractAddress = {
let deploy_tx = deploy_account_tx();
let tx = assert_matches!(
deploy_tx,
RPCTransaction::DeployAccount(RPCDeployAccountTransaction::V3(tx)) => tx
);
calculate_contract_address(
tx.contract_address_salt,
tx.class_hash,
&tx.constructor_calldata,
ContractAddress::default(),
)
.unwrap()
};
}
crates/tests-integration/src/state_reader.rs
line 295 at r1 (raw file):
.extend(key_value.clone()); } }
IIUC.
Suggestion:
fn fund_feature_account_contract(
storage_diffs: &mut IndexMap<ContractAddress, IndexMap<StorageKey, StarkFelt>>,
contract: &FeatureContract,
instance: u16,
initial_balances: u128,
chain_info: &ChainInfo,
) {
match contract {
FeatureContract::AccountWithLongValidate(_)
| FeatureContract::AccountWithoutValidations(_)
| FeatureContract::FaultyAccount(_) => {
fund_account(
storage_diffs,
&contract.get_instance_address(instance),
initial_balances,
chain_info,
);
}
_ => (),
}
}
fn fund_account(
storage_diffs: &mut IndexMap<ContractAddress, IndexMap<StorageKey, StarkFelt>>,
account_address: &ContractAddress,
initial_balances: u128,
chain_info: &ChainInfo,
) {
let key_value = indexmap! {
get_fee_token_var_address(*account_address) => stark_felt!(initial_balances),
};
for fee_type in FeeType::iter() {
storage_diffs
.entry(chain_info.fee_token_address(&fee_type))
.or_default()
.extend(key_value.clone());
}
}
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.
Reviewed 1 of 5 files at r1.
Reviewable status: 3 of 5 files reviewed, 3 unresolved discussions (waiting on @dafnamatsry, @giladchase, and @Yael-Starkware)
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.
Reviewed 5 of 5 files at r1, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @giladchase and @Yael-Starkware)
crates/tests-integration/src/state_reader.rs
line 173 at r1 (raw file):
let erc20 = FeatureContract::ERC20; let mut cairo0_contract_classes: Vec<(ClassHash, DeprecatedContractClass)> = vec![(erc20.get_class_hash(), serde_json::from_str(&erc20.get_raw_class()).unwrap())];
Maybe pass the erc20 contract as an input as part of contract_instances
?
Code quote:
let erc20 = FeatureContract::ERC20;
let mut cairo0_contract_classes: Vec<(ClassHash, DeprecatedContractClass)> =
vec![(erc20.get_class_hash(), serde_json::from_str(&erc20.get_raw_class()).unwrap())];
94e9014
to
8b4d292
Compare
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: all files reviewed, 3 unresolved discussions (waiting on @ArniStarkware, @dafnamatsry, and @giladchase)
crates/tests-integration/src/state_reader.rs
line 60 at r1 (raw file):
Previously, ArniStarkware (Arnon Hod) wrote…
What do you think about wrapping this into a function as a test util?
done.
crates/tests-integration/src/state_reader.rs
line 62 at r1 (raw file):
Previously, ArniStarkware (Arnon Hod) wrote…
Do we have other examples for this? Is there something I can look for a reference?
(Nice!)
Papyrus is using it:
https://github.com/starkware-libs/papyrus/blob/c4d829c978d45a6d49be50da76ebde68e019ccd5/crates/papyrus_rpc/src/v0_7/transaction_test.rs#L35
crates/tests-integration/src/state_reader.rs
line 173 at r1 (raw file):
Previously, dafnamatsry wrote…
Maybe pass the erc20 contract as an input as part of
contract_instances
?
Done.
crates/tests-integration/src/state_reader.rs
line 295 at r1 (raw file):
Previously, ArniStarkware (Arnon Hod) wrote…
IIUC.
Done.
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.
Reviewed 4 of 4 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ArniStarkware, @giladchase, and @Yael-Starkware)
crates/gateway/Cargo.toml
line 16 at r2 (raw file):
[dependencies] axum.workspace = true assert_matches.workspace = true
I think there is a way to define the starknet_api_test_utils.rs
for tests? and then keep this as dev-dependency.
Take a look at #[cfg(test)]
in lib.rs
.
Code quote:
assert_matches.workspace = true
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: all files reviewed, 3 unresolved discussions (waiting on @ArniStarkware, @dafnamatsry, and @giladchase)
crates/gateway/Cargo.toml
line 16 at r2 (raw file):
Previously, dafnamatsry wrote…
I think there is a way to define the
starknet_api_test_utils.rs
for tests? and then keep this as dev-dependency.Take a look at
#[cfg(test)]
inlib.rs
.
yes, I was thinking the same thing exactly and was planning to fix in a the next PR. There is one function in this file that is being used by the gateway so I couldn't make it a test file instantly, will open a separate PR to move the function and then solve this.
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: all files reviewed, 3 unresolved discussions (waiting on @ArniStarkware, @dafnamatsry, and @giladchase)
crates/gateway/Cargo.toml
line 16 at r2 (raw file):
Previously, Yael-Starkware (YaelD) wrote…
yes, I was thinking the same thing exactly and was planning to fix in a the next PR. There is one function in this file that is being used by the gateway so I couldn't make it a test file instantly, will open a separate PR to move the function and then solve this.
here is the PR: https://reviewable.io/reviews/starkware-libs/mempool/329
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: all files reviewed, 2 unresolved discussions (waiting on @ArniStarkware and @giladchase)
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 @giladchase)
8b4d292
to
1f55f90
Compare
1f55f90
to
6db50c2
Compare
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.
Reviewed 3 of 3 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @giladchase)
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)