Skip to content
This repository has been archived by the owner on Aug 2, 2024. It is now read-only.

added pallet test for InvokeTransaction::V0 #1608

Closed
wants to merge 20 commits into from
Closed
Changes from 1 commit
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
34 changes: 33 additions & 1 deletion crates/pallets/starknet/src/tests/invoke_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,44 @@ fn given_hardcoded_contract_run_invoke_tx_fails_sender_not_deployed() {
})
}

fn get_invoke_dummy_v0(chain_id: u64, nonce: Nonce) -> InvokeTransaction {
let contract_address = ContractAddress(PatriciaKey(
StarkFelt::try_from("0x03e437FB56Bb213f5708Fcd6966502070e276c093ec271aA33433b89E21fd31f").unwrap(),
));
let calldata = Calldata(Arc::new(vec![]));
let value = Fee(0);
let gas_limit = 1000;

let invoke_tx_v0 = starknet_api::transaction::InvokeTransactionV0 {
contract_address,
calldata,
value,
gas_limit,
};

let tx_hash = invoke_tx_v0.compute_hash(chain_id, false);

InvokeTransaction {
tx: invoke_tx_v0.into(),
tx_hash,
only_query: false,
}
}

#[test]
fn given_hardcoded_contract_run_invoke_tx_then_it_works() {
new_test_ext::<MockRuntime>().execute_with(|| {
basic_test_setup(2);

let transaction = get_invoke_dummy(Starknet::chain_id(), NONCE_ZERO);
raizo07 marked this conversation as resolved.
Show resolved Hide resolved
let transaction = get_invoke_dummy_v0(Starknet::chain_id(), NONCE_ZERO);
if let starknet_api::transaction::InvokeTransaction::V0(tx) = &mut transaction.tx {
tx.contract_address = ContractAddress(PatriciaKey(
StarkFelt::try_from("0x03e437FB56Bb213f5708Fcd6966502070e276c093ec271aA33433b89E21fd31f").unwrap(),
));
tx.calldata = Calldata(Arc::new(vec![])); // Empty calldata for simplicity
tx.value = Fee(0);
tx.gas_limit = 1000;
};

assert_ok!(Starknet::invoke(RuntimeOrigin::none(), transaction));

Expand Down
Loading