Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions crates/starknet_os_flow_tests/src/initial_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use starknet_types_core::felt::Felt;
use crate::state_trait::FlowTestState;
use crate::test_manager::{
block_context_for_flow_tests,
EXPECTED_STRK_FEE_TOKEN_ADDRESS,
FUNDED_ACCOUNT_ADDRESS,
STRK_FEE_TOKEN_ADDRESS,
};
Expand Down Expand Up @@ -302,8 +303,9 @@ pub(crate) fn get_deploy_contract_tx_and_address(
ctor_calldata,
nonce,
resource_bounds,
// Default salt.
ContractAddressSalt(Felt::ONE),
// Use the nonce as the salt so it's easy to deploy the same contract (with the same
// constructor calldata) multiple times.
ContractAddressSalt(nonce.0),
);
(
Transaction::new_for_sequencing(StarknetAPITransaction::Account(
Expand Down Expand Up @@ -368,10 +370,12 @@ pub(crate) fn get_deploy_fee_token_tx_and_address(nonce: Nonce) -> (Transaction,
*FUNDED_ACCOUNT_ADDRESS.0.key(), // provisional_governance_admin
10.into() // upgrade delay
];
get_deploy_contract_tx_and_address(
let (tx, address) = get_deploy_contract_tx_and_address(
class_hash,
constructor_calldata,
nonce,
ValidResourceBounds::create_for_testing_no_fee_enforcement(),
)
);
EXPECTED_STRK_FEE_TOKEN_ADDRESS.assert_debug_eq(&**address);
(tx, address)
}
20 changes: 16 additions & 4 deletions crates/starknet_os_flow_tests/src/test_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ use blockifier::transaction::transaction_execution::Transaction as BlockifierTra
use blockifier_test_utils::calldata::create_calldata;
use blockifier_test_utils::contracts::FeatureContract;
use cairo_vm::types::builtin_name::BuiltinName;
use expect_test::{expect, Expect};
use itertools::Itertools;
use starknet_api::abi::abi_utils::get_fee_token_var_address;
use starknet_api::block::{BlockHash, BlockInfo, BlockNumber, PreviousBlockNumber};
use starknet_api::contract_class::compiled_class_hash::{HashVersion, HashableCompiledClass};
use starknet_api::contract_class::ContractClass;
use starknet_api::core::{ChainId, ClassHash, ContractAddress, GlobalRoot, Nonce};
use starknet_api::core::{ChainId, ClassHash, ContractAddress, GlobalRoot, Nonce, PatriciaKey};
use starknet_api::executable_transaction::{
AccountTransaction,
DeclareTransaction,
Expand Down Expand Up @@ -57,7 +58,6 @@ use starknet_types_core::felt::Felt;

use crate::initial_state::{
create_default_initial_state_data,
get_deploy_fee_token_tx_and_address,
get_initial_deploy_account_tx,
InitialState,
InitialStateData,
Expand All @@ -76,8 +76,20 @@ use crate::utils::{
};

/// The STRK fee token address that was deployed when initializing the default initial state.
pub(crate) static STRK_FEE_TOKEN_ADDRESS: LazyLock<ContractAddress> =
LazyLock::new(|| get_deploy_fee_token_tx_and_address(Nonce::default()).1);
/// The resulting address depends on the nonce of the deploying account - if extra init transactions
/// are added to the initial state construction before the STRK fee token is deployed, the address
/// must be updated.
pub(crate) const EXPECTED_STRK_FEE_TOKEN_ADDRESS: Expect = expect![[r#"
0x1a465ff487205d561821685efff4903cb07d69f014b1688a560f8c6380cd025
"#]];
pub(crate) static STRK_FEE_TOKEN_ADDRESS: LazyLock<ContractAddress> = LazyLock::new(|| {
ContractAddress(
PatriciaKey::try_from(Felt::from_hex_unchecked(
EXPECTED_STRK_FEE_TOKEN_ADDRESS.data.trim(),
))
.unwrap(),
)
});

/// The address of a funded account that is able to pay fees for transactions.
/// This address was initialized when creating the default initial state.
Expand Down