Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(blockifier): impl .into() from api executable tx to blockifier AccountTransaction #1868

Merged
merged 1 commit into from
Nov 11, 2024
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
5 changes: 4 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,9 @@ 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);
// TODO(AvivG): use starknet_api::test_utils::declare::executable_declare_tx to
// create executable_declare.
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 @@ -16,5 +16,6 @@ pub fn deploy_account_tx(
// TODO(AvivG): use the "new" method.
let executable_deploy_account_tx =
DeployAccountTransaction { tx: deploy_account_tx, only_query: false };
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
Loading