Skip to content

Commit

Permalink
fix(tests-integration): deploy tx constructors
Browse files Browse the repository at this point in the history
- Move `DeployAccountTransaction`s out of tx generator: it cannot
possibly be constructed through the `AccountTransactionGenerator`,
since the generator will soon needs a deploy account tx in its
constructor, to ensure consistent sender addresses for the account.

- Added salt, will also be needed later.

- Removed unused `deploy_account_tx` function.
  • Loading branch information
Gilad Chase committed Sep 26, 2024
1 parent 62fa5ac commit a966a02
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions crates/mempool_test_utils/src/starknet_api_test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use starknet_api::transaction::{
TransactionVersion,
ValidResourceBounds,
};
use starknet_api::{calldata, felt};
use starknet_api::{calldata, felt, nonce};
use starknet_types_core::felt::Felt;

use crate::{
Expand Down Expand Up @@ -195,13 +195,17 @@ pub fn executable_invoke_tx(cairo_version: CairoVersion) -> Transaction {
.generate_default_executable_invoke()
}

// TODO(Yael 18/6/2024): Get a final decision from product whether to support Cairo0.
pub fn deploy_account_tx() -> RpcTransaction {
let default_account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1);
pub fn generate_default_deploy_account_with_salt(
account: &FeatureContract,
contract_address_salt: ContractAddressSalt,
) -> RpcTransaction {
let deploy_account_args = deploy_account_tx_args!(
class_hash: account.get_class_hash(),
resource_bounds: test_resource_bounds_mapping(),
contract_address_salt
);

MultiAccountTransactionGenerator::new_for_account_contracts([default_account])
.account_with_id(0)
.generate_default_deploy_account()
rpc_deploy_account_tx(deploy_account_args)
}

// TODO: when moving this to Starknet API crate, move this const into a module alongside
Expand Down Expand Up @@ -311,18 +315,6 @@ impl AccountTransactionGenerator {
Transaction::Invoke(starknet_api::test_utils::invoke::executable_invoke_tx(invoke_args))
}

pub fn generate_default_deploy_account(&mut self) -> RpcTransaction {
let nonce = self.next_nonce();
assert_eq!(nonce, Nonce(Felt::ZERO));

let deploy_account_args = deploy_account_tx_args!(
nonce,
class_hash: self.account.get_class_hash(),
resource_bounds: test_resource_bounds_mapping()
);
rpc_deploy_account_tx(deploy_account_args)
}

// TODO: support more contracts, instead of this hardcoded type.
pub fn test_contract_address(&mut self) -> ContractAddress {
let cairo_version = self.account.cairo_version();
Expand Down

0 comments on commit a966a02

Please sign in to comment.