testnumbat_wasm_debug/testdenali_step/
sc_query.rs1use testdenali::{TxExpect, TxQuery};
2use num_bigint::BigUint;
3
4use crate::{execute_helper_functions::*, BlockchainMock, ContractMap, TxContext, TxInput};
5
6pub fn execute(
7 state: &mut BlockchainMock,
8 contract_map: &ContractMap<TxContext>,
9 tx_id: &str,
10 tx: &TxQuery,
11 expect: &Option<TxExpect>,
12) {
13 let tx_input = TxInput {
14 from: tx.to.value.into(),
15 to: tx.to.value.into(),
16 call_value: BigUint::from(0u32),
17 dcdt_value: BigUint::from(0u32),
18 dcdt_token_identifier: Vec::new(),
19 func_name: tx.function.as_bytes().to_vec(),
20 args: tx
21 .arguments
22 .iter()
23 .map(|scen_arg| scen_arg.value.clone())
24 .collect(),
25 gas_limit: u64::MAX,
26 gas_price: 0u64,
27 tx_hash: generate_tx_hash_dummy(tx_id),
28 };
29
30 let (tx_result, opt_async_data) = sc_call(tx_input, state, contract_map).unwrap();
31 assert!(
32 tx_result.result_status != 0 || !opt_async_data.is_some(),
33 "Can't query a view function that performs an async call"
34 );
35 if let Some(tx_expect) = expect {
36 check_tx_output(tx_id, tx_expect, &tx_result);
37 }
38}