Skip to content

Commit

Permalink
fix: change n_accounts to usize (#372)
Browse files Browse the repository at this point in the history
Co-Authored-By: Gilad Chase <[email protected]>
  • Loading branch information
giladchase and Gilad Chase authored Jul 7, 2024
1 parent 8e3825b commit 2c7b230
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crates/tests-integration/src/integration_test_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ pub struct IntegrationTestSetup {
}

impl IntegrationTestSetup {
pub async fn new(n_initialized_account_contracts: u16) -> Self {
pub async fn new(n_accounts: usize) -> Self {
let handle = Handle::current();
let task_executor = TokioExecutor::new(handle);

// Spawn a papyrus rpc server for a papyrus storage reader.
let rpc_server_addr = spawn_test_rpc_state_reader(n_initialized_account_contracts).await;
let rpc_server_addr = spawn_test_rpc_state_reader(n_accounts).await;

// Derive the configuration for the mempool node.
let config = create_config(rpc_server_addr).await;
Expand Down
9 changes: 5 additions & 4 deletions crates/tests-integration/src/state_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn deploy_account_tx_contract_address() -> &'static ContractAddress {
/// Creates a papyrus storage reader and spawns a papyrus rpc server for it.
/// Returns the address of the rpc server.
/// A variable number of identical accounts and test contracts are initialized and funded.
pub async fn spawn_test_rpc_state_reader(n_accounts: u16) -> SocketAddr {
pub async fn spawn_test_rpc_state_reader(n_accounts: usize) -> SocketAddr {
let block_context = BlockContext::create_for_testing();
let account_contract_cairo0 = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo0);
let test_contract_cairo0 = FeatureContract::TestContract(CairoVersion::Cairo0);
Expand All @@ -79,7 +79,7 @@ pub async fn spawn_test_rpc_state_reader(n_accounts: u16) -> SocketAddr {
fn initialize_papyrus_test_state(
chain_info: &ChainInfo,
initial_balances: u128,
contract_instances: &[(FeatureContract, u16)],
contract_instances: &[(FeatureContract, usize)],
fund_additional_accounts: Vec<ContractAddress>,
) -> StorageReader {
let state_diff = prepare_state_diff(
Expand All @@ -97,7 +97,7 @@ fn initialize_papyrus_test_state(

fn prepare_state_diff(
chain_info: &ChainInfo,
contract_instances: &[(FeatureContract, u16)],
contract_instances: &[(FeatureContract, usize)],
initial_balances: u128,
fund_accounts: Vec<ContractAddress>,
) -> ThinStateDiff {
Expand All @@ -124,6 +124,7 @@ fn prepare_state_diff(
declared_classes.insert(contract.get_class_hash(), Default::default());
}
}
let instance = u16::try_from(instance).unwrap();
deployed_contracts
.insert(contract.get_instance_address(instance), contract.get_class_hash());
fund_feature_account_contract(
Expand All @@ -150,7 +151,7 @@ fn prepare_state_diff(
}

fn prepare_compiled_contract_classes(
contract_instances: &[(FeatureContract, u16)],
contract_instances: &[(FeatureContract, usize)],
) -> ContractClassesMap {
let mut cairo0_contract_classes = Vec::new();
let mut cairo1_contract_classes = Vec::new();
Expand Down

0 comments on commit 2c7b230

Please sign in to comment.