Skip to content

Commit

Permalink
chore(tests_integration): return tx sender address
Browse files Browse the repository at this point in the history
commit-id:945de3b4
  • Loading branch information
Itay-Tsabary-Starkware committed Nov 14, 2024
1 parent 731b8d3 commit bd9ea66
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use papyrus_storage::StorageConfig;
use reqwest::{Client, Response};
use starknet_api::block::BlockNumber;
use starknet_api::contract_address;
use starknet_api::core::ContractAddress;
use starknet_api::rpc_transaction::RpcTransaction;
use starknet_api::transaction::TransactionHash;
use starknet_batcher::block_builder::BlockBuilderConfig;
Expand Down Expand Up @@ -185,12 +186,16 @@ fn create_txs_for_integration_test(
fn create_txs_for_tx_generator_test_scenario(
mut tx_generator: MultiAccountTransactionGenerator,
n_txs: usize,
) -> Vec<RpcTransaction> {
) -> (Vec<RpcTransaction>, ContractAddress) {
const ACCOUNT_ID_0: AccountId = 0;
let contract_address = tx_generator.account_with_id(ACCOUNT_ID_0).sender_address();

(0..n_txs)
.map(|_| tx_generator.account_with_id(ACCOUNT_ID_0).generate_invoke_with_tip(1))
.collect()
(
(0..n_txs)
.map(|_| tx_generator.account_with_id(ACCOUNT_ID_0).generate_invoke_with_tip(1))
.collect(),
contract_address,
)
}

async fn send_rpc_txs<'a, Fut>(
Expand Down Expand Up @@ -237,12 +242,14 @@ pub async fn run_transaction_generator_test_scenario<'a, Fut>(
tx_generator: MultiAccountTransactionGenerator,
n_txs: usize,
send_rpc_tx_fn: &'a mut dyn FnMut(RpcTransaction) -> Fut,
) where
) -> (Vec<TransactionHash>, ContractAddress)
where
Fut: Future<Output = TransactionHash> + 'a,
{
let rpc_txs = create_txs_for_tx_generator_test_scenario(tx_generator, n_txs);

send_rpc_txs(rpc_txs, send_rpc_tx_fn).await;
let (rpc_txs, contract_address) =
create_txs_for_tx_generator_test_scenario(tx_generator, n_txs);
let tx_hashes = send_rpc_txs(rpc_txs, send_rpc_tx_fn).await;
(tx_hashes, contract_address)
}

pub async fn create_gateway_config(chain_info: ChainInfo) -> GatewayConfig {
Expand Down

0 comments on commit bd9ea66

Please sign in to comment.