Skip to content

Commit

Permalink
refactor(blockifier): impl .into() from api executable tx to blockifi…
Browse files Browse the repository at this point in the history
…er AccountTransaction
  • Loading branch information
avivg-starkware committed Nov 10, 2024
1 parent 8f7eddc commit 1684532
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
3 changes: 2 additions & 1 deletion crates/blockifier/src/test_utils/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::transaction::transactions::DeclareTransaction;
pub fn declare_tx(declare_tx_args: DeclareTxArgs, class_info: ClassInfo) -> AccountTransaction {
let tx_hash = declare_tx_args.tx_hash;
let declare_tx = starknet_api::test_utils::declare::declare_tx(declare_tx_args);
let executable_declare = DeclareTransaction::new(declare_tx, tx_hash, class_info).unwrap();

AccountTransaction::Declare(DeclareTransaction::new(declare_tx, tx_hash, class_info).unwrap())
executable_declare.into()
}
3 changes: 2 additions & 1 deletion crates/blockifier/src/test_utils/deploy_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ pub fn deploy_account_tx(
);
let executable_deploy_account_tx =
DeployAccountTransaction::new(deploy_account_tx, tx_hash, contract_address);
AccountTransaction::DeployAccount(executable_deploy_account_tx)

executable_deploy_account_tx.into()
}
4 changes: 3 additions & 1 deletion crates/blockifier/src/test_utils/invoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ pub fn invoke_tx(invoke_args: InvokeTxArgs) -> AccountTransaction {
entry_point_selector: selector_from_name(EXECUTE_ENTRY_POINT_NAME),
})
} else {
// TODO(AvivG): Have test util 'invoke_tx' support creation of TransactionVersion::ZERO
// invoke transactions.
starknet_api::test_utils::invoke::invoke_tx(invoke_args)
};

let invoke_tx = match only_query {
true => InvokeTransaction::new_for_query(invoke_tx, tx_hash),
false => InvokeTransaction::new(invoke_tx, tx_hash),
};
AccountTransaction::Invoke(invoke_tx)
invoke_tx.into()
}
21 changes: 10 additions & 11 deletions crates/blockifier/src/transaction/account_transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -759,17 +759,16 @@ fn test_fail_declare(block_context: BlockContext, max_fee: Fee) {
state.set_contract_class(class_hash, contract_class.clone().try_into().unwrap()).unwrap();
state.set_compiled_class_hash(class_hash, declare_tx.compiled_class_hash).unwrap();
let class_info = calculate_class_info_for_testing(contract_class);
let declare_account_tx = AccountTransaction::Declare(
DeclareTransaction::new(
starknet_api::transaction::DeclareTransaction::V2(DeclareTransactionV2 {
nonce: next_nonce,
..declare_tx
}),
TransactionHash::default(),
class_info,
)
.unwrap(),
);
let declare_account_tx: AccountTransaction = DeclareTransaction::new(
starknet_api::transaction::DeclareTransaction::V2(DeclareTransactionV2 {
nonce: next_nonce,
..declare_tx
}),
TransactionHash::default(),
class_info,
)
.unwrap()
.into();

// Fail execution, assert nonce and balance are unchanged.
let tx_info = declare_account_tx.create_tx_info();
Expand Down

0 comments on commit 1684532

Please sign in to comment.