diff --git a/tvm_block/tests/test_config_params.rs b/tvm_block/tests/test_config_params.rs index 037a77019..4d7c62b7e 100644 --- a/tvm_block/tests/test_config_params.rs +++ b/tvm_block/tests/test_config_params.rs @@ -157,14 +157,14 @@ fn test_config_msg_forward_prices() { fn get_cat_chain_config() -> CatchainConfig { let mut rng = rand::thread_rng(); - let mut cc = CatchainConfig::default(); - cc.shuffle_mc_validators = rng.gen(); - cc.isolate_mc_validators = rng.gen(); - cc.mc_catchain_lifetime = rng.gen(); - cc.shard_catchain_lifetime = rng.gen(); - cc.shard_validators_lifetime = rng.gen(); - cc.shard_validators_num = rng.gen(); - cc + CatchainConfig { + shuffle_mc_validators: rng.gen(), + isolate_mc_validators: rng.gen(), + mc_catchain_lifetime: rng.gen(), + shard_catchain_lifetime: rng.gen(), + shard_validators_lifetime: rng.gen(), + shard_validators_num: rng.gen(), + } } #[test] @@ -215,16 +215,13 @@ fn get_validator_set() -> ValidatorSet { #[test] fn test_config_param_32_34_36() { - let mut cp32 = ConfigParam32::default(); - cp32.prev_validators = get_validator_set(); + let cp32 = ConfigParam32 { prev_validators: get_validator_set() }; write_read_and_assert(cp32); - let mut cp34 = ConfigParam34::default(); - cp34.cur_validators = get_validator_set(); + let cp34 = ConfigParam34 { cur_validators: get_validator_set() }; write_read_and_assert(cp34); - let mut cp36 = ConfigParam36::default(); - cp36.next_validators = get_validator_set(); + let cp36 = ConfigParam36 { next_validators: get_validator_set() }; write_read_and_assert(cp36); } @@ -493,8 +490,7 @@ fn test_config_params() { ); assert!(!cp.prev_validator_set_present().unwrap()); - let mut cp32 = ConfigParam32::default(); - cp32.prev_validators = get_validator_set(); + let cp32 = ConfigParam32 { prev_validators: get_validator_set() }; let c32 = ConfigParamEnum::ConfigParam32(cp32); cp.set_config(c32.clone()).unwrap(); let c = cp.config(32).unwrap().unwrap(); @@ -503,8 +499,7 @@ fn test_config_params() { assert!(cp.prev_validator_set_present().unwrap()); write_read_and_assert(cp.clone()); - let mut cp34 = ConfigParam34::default(); - cp34.cur_validators = get_validator_set(); + let cp34 = ConfigParam34 { cur_validators: get_validator_set() }; let c34 = ConfigParamEnum::ConfigParam34(cp34); cp.set_config(c34.clone()).unwrap(); let c = cp.config(34).unwrap().unwrap(); @@ -520,8 +515,7 @@ fn test_config_params() { ); assert!(!cp.next_validator_set_present().unwrap()); - let mut cp36 = ConfigParam36::default(); - cp36.next_validators = get_validator_set(); + let cp36 = ConfigParam36 { next_validators: get_validator_set() }; let c36 = ConfigParamEnum::ConfigParam36(cp36); cp.set_config(c36.clone()).unwrap(); let c = cp.config(36).unwrap().unwrap(); diff --git a/tvm_block/tests/test_signature.rs b/tvm_block/tests/test_signature.rs index b6d6afb66..4af1f495e 100644 --- a/tvm_block/tests/test_signature.rs +++ b/tvm_block/tests/test_signature.rs @@ -253,7 +253,7 @@ fn test_crypto_signature_read_from_invalid_tag() { // Create data with wrong tag (not 0x5) let mut builder = BuilderData::new(); - builder.append_bits(0x7 as usize, 4).unwrap(); // wrong tag + builder.append_bits(0x7_usize, 4).unwrap(); // wrong tag builder.append_raw(&[1; 64], 64 * 8).unwrap(); let cell = builder.into_cell().unwrap(); let mut slice = SliceData::load_cell(cell).unwrap(); @@ -892,7 +892,7 @@ fn test_crypto_signature_to_bytes() { fn test_crypto_signature_signature_method() { let cs = CryptoSignature::from_r_s(&[1; 32], &[2; 32]).unwrap(); let sig_ref = cs.signature(); - assert!(sig_ref.to_bytes().len() > 0); + assert!(!sig_ref.to_bytes().is_empty()); } #[test] @@ -939,7 +939,7 @@ fn test_block_signatures_pure_signatures_method() { bsp.add_sigpair(csp); let sigs = bsp.signatures(); - assert!(sigs.is_empty() == false || bsp.count() > 0); + assert!(!sigs.is_empty() || bsp.count() > 0); } #[test] @@ -1166,7 +1166,7 @@ fn test_sig_pub_key_verify_signature_error_branch() { let invalid_key = SigPubKey::from_bytes(&[0; 32]).unwrap(); let cs = CryptoSignature::from_r_s(&[1; 32], &[2; 32]).unwrap(); let result = invalid_key.verify_signature(b"test", &cs); - assert!(result == true || result == false); + assert!(result || !result); } #[test] diff --git a/tvm_block_json/src/serialize.rs b/tvm_block_json/src/serialize.rs index 0a9b6c407..809af114a 100644 --- a/tvm_block_json/src/serialize.rs +++ b/tvm_block_json/src/serialize.rs @@ -1548,7 +1548,7 @@ pub fn serialize_config_param(config: &ConfigParams, config_number: u32) -> Resu if let Some(cp) = serialize_known_config_param(config_number, param, SerializationMode::Standart)? { - master_map.insert(format!("p{}", &config_number), cp); + master_map.insert(format!("p{}", config_number), cp); } } let json = serde_json::to_string_pretty(&master_map)?; diff --git a/tvm_executor/src/transaction_executor.rs b/tvm_executor/src/transaction_executor.rs index 6e5d7240b..5236763ea 100644 --- a/tvm_executor/src/transaction_executor.rs +++ b/tvm_executor/src/transaction_executor.rs @@ -2148,6 +2148,7 @@ mod tests { use tvm_block::TrActionPhase; use tvm_block::Transaction; use tvm_block::TransactionDescr; + use tvm_block::TransactionDescrOrdinary; use tvm_types::BuilderData; use tvm_types::Cell; use tvm_types::DataCell; @@ -2157,6 +2158,7 @@ mod tests { use tvm_types::UInt256; use tvm_vm::executor::MVConfig; use tvm_vm::stack::Stack; + use tvm_vm::stack::StackItem; use super::*; use crate::BlockchainConfig; @@ -2370,13 +2372,17 @@ mod tests { } fn executor_config() -> BlockchainConfig { + executor_config_with_capabilities(0x572e) + } + + fn executor_config_with_capabilities(capabilities: u64) -> BlockchainConfig { let mut config = ConfigParams { config_addr: UInt256::with_array([0x55; 32]), ..ConfigParams::default() }; config .set_config(ConfigParamEnum::ConfigParam8(ConfigParam8 { - global_version: GlobalVersion { version: 42, capabilities: 0x572e }, + global_version: GlobalVersion { version: 42, capabilities }, })) .unwrap(); config.set_config(ConfigParamEnum::ConfigParam18(storage_prices())).unwrap(); @@ -2416,6 +2422,220 @@ mod tests { .unwrap() } + fn internal_message(src: u8, dst: u8) -> Message { + Message::with_int_header(InternalMessageHeader::with_addresses( + address(src), + address(dst), + CurrencyCollection::with_grams(1_000_000_000), + )) + } + + fn execute_node_contract( + code: &str, + params: ExecuteParams, + ) -> std::result::Result<(Transaction, i128), anyhow::Error> { + execute_node_contract_with_config(code, params, executor_config()) + } + + fn execute_node_contract_with_config( + code: &str, + params: ExecuteParams, + config: BlockchainConfig, + ) -> std::result::Result<(Transaction, i128), anyhow::Error> { + let executor = OrdinaryTransactionExecutor::new(config); + let code = tvm_assembler::compile_code_to_cell(code).unwrap(); + let account = active_account_with_code(7, code); + let mut account_root = account.serialize().unwrap(); + executor.execute_with_libs_and_params( + Some(&internal_message(1, 7)), + &mut account_root, + params, + ) + } + + fn ordinary_description(tx: &Transaction) -> TransactionDescrOrdinary { + match tx.read_description().unwrap() { + TransactionDescr::Ordinary(description) => description, + _ => panic!("unexpected transaction description"), + } + } + + fn vm_phase(tx: &Transaction) -> TrComputePhaseVm { + match ordinary_description(tx).compute_ph { + TrComputePhase::Vm(phase) => phase, + _ => panic!("unexpected compute phase"), + } + } + + fn run_mint_shellq_action( + available_credit: i128, + initial_minted_shell: i128, + requested: u64, + ) -> (ActionPhaseResult, i128, u128) { + let executor = DummyExecutor::new(); + let mut account = active_account(8); + let mut tx = Transaction::with_address_and_status(address(8).address(), account.status()); + let original_balance = account.balance().cloned().unwrap(); + let mut acc_balance = original_balance.clone(); + let mut msg_balance = CurrencyCollection::default(); + let mut actions = OutActions::default(); + actions.push_back(OutAction::new_mint_shellq(requested)); + let mut minted_shell = initial_minted_shell; + + let result = executor + .action_phase_with_copyleft( + &mut tx, + &mut account, + &original_balance, + &mut acc_balance, + &mut msg_balance, + &Grams::zero(), + actions.serialize().unwrap(), + None, + &address(8), + false, + available_credit, + &mut minted_shell, + Grams::zero(), + Some(UInt256::with_array([0x99; 32])), + ) + .unwrap(); + + (result, minted_shell, acc_balance.grams.as_u128() - original_balance.grams.as_u128()) + } + + fn bytes_to_hex(bytes: &[u8]) -> String { + bytes.iter().map(|byte| format!("{byte:02x}")).collect() + } + + #[cfg(feature = "wasmtime")] + fn bytes_from_hex(hex: &str) -> Vec { + (0..hex.len()) + .step_by(2) + .map(|index| u8::from_str_radix(&hex[index..index + 2], 16).unwrap()) + .collect() + } + + #[cfg(feature = "wasmtime")] + fn run_wasm_hash_stack(wasm_hash: &[u8]) -> Stack { + use tvm_abi::TokenValue; + use tvm_abi::contract::ABI_VERSION_2_4; + + let hash_cell = + TokenValue::write_bytes(wasm_hash, &ABI_VERSION_2_4).unwrap().into_cell().unwrap(); + let args_cell = + TokenValue::write_bytes(&[1u8, 2u8], &ABI_VERSION_2_4).unwrap().into_cell().unwrap(); + let function_cell = tvm_vm::utils::pack_data_to_cell(b"add", &mut 0).unwrap(); + let instance_cell = + tvm_vm::utils::pack_data_to_cell(b"docs:adder/add-interface@0.1.0", &mut 0).unwrap(); + let dict_cell = + TokenValue::write_bytes(&[], &ABI_VERSION_2_4).unwrap().into_cell().unwrap(); + + let mut stack = Stack::new(); + stack.push(StackItem::cell(hash_cell)); + stack.push(StackItem::cell(args_cell)); + stack.push(StackItem::cell(function_cell)); + stack.push(StackItem::cell(instance_cell)); + stack.push(StackItem::cell(dict_cell)); + stack + } + + #[allow(deprecated)] + fn compute_node_contract( + code: &str, + argument_stack: Stack, + params: ExecuteParams, + ) -> TrComputePhaseVm { + let executor = OrdinaryTransactionExecutor::new(executor_config()); + let code = tvm_assembler::compile_code_to_cell(code).unwrap(); + let mut account = active_account_with_code(7, code); + let mut msg = internal_message(1, 7); + let mut acc_balance = account.balance().cloned().unwrap(); + let mut msg_balance = CurrencyCollection::with_grams(1_000_000_000); + let smc_info = + executor.build_contract_info(&acc_balance, &address(7), 0, 0, 0, UInt256::default()); + let mut stack = executor.build_stack(Some(&msg), &account); + for index in (0..argument_stack.depth()).rev() { + stack.push(argument_stack.get(index).clone()); + } + + let (phase, _, _) = executor + .compute_phase( + Some(&mut msg), + &mut account, + &mut acc_balance, + &mut msg_balance, + smc_info, + stack, + 0, + false, + false, + ¶ms, + ) + .unwrap(); + match phase { + TrComputePhase::Vm(phase) => phase, + _ => panic!("unexpected compute phase"), + } + } + + fn currency_other_u64(balance: &CurrencyCollection, key: u32) -> u64 { + let Some(value) = balance.get_other(key).unwrap() else { + return 0; + }; + value.value().iter_u64_digits().next().unwrap_or(0) + } + + fn cross_dapp_exchange_balance(engine_version: semver::Version) -> CurrencyCollection { + let executor = OrdinaryTransactionExecutor::new(executor_config()); + let code = tvm_assembler::compile_code_to_cell("PUSHINT 1\n").unwrap(); + let account = active_account_with_code(7, code); + let mut account_root = account.serialize().unwrap(); + let mut msg_value = CurrencyCollection::with_grams(1_000_000_000); + msg_value.set_other(2, 123).unwrap(); + let mut header = InternalMessageHeader::with_addresses(address(1), address(7), msg_value); + header.set_src_dapp_id(Some(UInt256::with_array([0x33; 32]))); + header.set_exchange(true); + let msg = Message::with_int_header(header); + + let mut fixture = BuildActionsExecuteParamsFixture::regular(); + fixture.dapp_id = Some(UInt256::with_array([0x22; 32])); + fixture.engine_version = engine_version; + let (tx, _) = executor + .execute_with_libs_and_params(Some(&msg), &mut account_root, fixture.build()) + .unwrap(); + let phase = vm_phase(&tx); + assert!(phase.success, "{phase:?}"); + + Account::construct_from_cell(account_root).unwrap().balance_checked() + } + + fn uint64_array_cell(values: &[u64]) -> Cell { + use tvm_abi::TokenValue; + use tvm_abi::contract::ABI_VERSION_2_2; + use tvm_abi::param_type::ParamType; + + let items = values + .iter() + .map(|value| TokenValue::Uint(tvm_abi::Uint::new(*value as u128, 64))) + .collect(); + TokenValue::Array(ParamType::Uint(64), items) + .pack_into_chain(&ABI_VERSION_2_2) + .unwrap() + .into_cell() + .unwrap() + } + + fn calc_mv_reward_stack() -> Stack { + let mut stack = Stack::new(); + stack.push(StackItem::int(0)); + stack.push(StackItem::int(0)); + stack.push(StackItem::cell(uint64_array_cell(&[1, 1]))); + stack.push(StackItem::int(2)); + stack.push(StackItem::int(1_000_000_000)); + stack + } + #[test] fn action_phase_result_from_phase_starts_empty() { let phase = TrActionPhase { @@ -2581,6 +2801,245 @@ mod tests { reset_cell_tls(); } + #[test] + fn node_params_available_credit_reaches_get_available_balance() { + for (available_credit, expected_balance) in [(0, 0), (42, 42), (INFINITY_CREDIT, 0)] { + let mut fixture = BuildActionsExecuteParamsFixture::regular(); + fixture.available_credit = available_credit; + + let (tx, minted_shell) = execute_node_contract( + &format!( + "GETAVAILABLEBALANCE\n\ + PUSHINT {}\n\ + EQUAL\n\ + THROWIFNOT 201\n", + expected_balance + ), + fixture.build(), + ) + .unwrap(); + + let phase = vm_phase(&tx); + assert!(phase.success, "{phase:?}"); + assert_eq!(phase.exit_code, 0); + assert_eq!(minted_shell, 0); + } + } + + #[test] + fn node_params_dapp_id_reaches_my_dapp_id() { + let dapp_id = UInt256::with_array([0x31; 32]); + let mut fixture = BuildActionsExecuteParamsFixture::regular(); + fixture.dapp_id = Some(dapp_id); + + let (tx, _) = execute_node_contract( + "MYDAPPID\n\ + PUSHINT 0x3131313131313131313131313131313131313131313131313131313131313131\n\ + EQUAL\n\ + THROWIFNOT 202\n", + fixture.build(), + ) + .unwrap(); + + let phase = vm_phase(&tx); + assert!(phase.success, "{phase:?}"); + assert_eq!(phase.exit_code, 0); + } + + #[test] + fn node_params_missing_dapp_id_is_observable_in_my_dapp_id() { + let fixture = BuildActionsExecuteParamsFixture::regular(); + + let (tx, _) = execute_node_contract("MYDAPPID\n", fixture.build()).unwrap(); + + let phase = vm_phase(&tx); + assert!(!phase.success, "{phase:?}"); + assert_eq!(phase.exit_code, ExceptionCode::DAppIdNotSet as i32); + } + + #[test] + fn node_params_reached_termination_deadline_aborts_execution() { + let mut fixture = BuildActionsExecuteParamsFixture::regular(); + fixture.termination_deadline = Some(Instant::now() - Duration::from_secs(1)); + + let err = execute_node_contract("PUSHINT 1\n", fixture.build()).unwrap_err(); + + assert!(matches!( + err.downcast_ref::(), + Some(ExecutorError::TerminationDeadlineReached) + )); + } + + #[test] + fn node_params_zero_execution_timeout_reaches_vm_compute_phase() { + let mut fixture = BuildActionsExecuteParamsFixture::regular(); + fixture.execution_timeout = Some(Duration::ZERO); + + let (tx, _) = execute_node_contract("PUSHINT 1\n", fixture.build()).unwrap(); + + let phase = vm_phase(&tx); + assert!(!phase.success, "{phase:?}"); + assert_eq!(phase.exit_code, ExceptionCode::ExecutionTimeout as i32); + } + + #[test] + fn node_params_minted_shellq_limits_cover_zero_limited_and_infinite_credit() { + let (result, minted_shell, credited) = run_mint_shellq_action(0, 0, 20); + assert!(result.phase.success, "{:?}", result.phase); + assert_eq!(result.phase.spec_actions, 1); + assert_eq!(minted_shell, 0); + assert_eq!(credited, 0); + + let (result, minted_shell, credited) = run_mint_shellq_action(13, 5, 20); + assert!(result.phase.success, "{:?}", result.phase); + assert_eq!(result.phase.spec_actions, 1); + assert_eq!(minted_shell, 13); + assert_eq!(credited, 8); + + let (result, minted_shell, credited) = run_mint_shellq_action(INFINITY_CREDIT, 0, 20); + assert!(result.phase.success, "{:?}", result.phase); + assert_eq!(result.phase.spec_actions, 1); + assert_eq!(minted_shell, 20); + assert_eq!(credited, 20); + } + + #[test] + fn node_params_engine_version_reaches_cross_dapp_exchange() { + let pre_1_0_3_balance = cross_dapp_exchange_balance(semver::Version::new(1, 0, 2)); + let post_1_0_3_balance = cross_dapp_exchange_balance(semver::Version::new(1, 0, 3)); + + assert_eq!(currency_other_u64(&pre_1_0_3_balance, 2), 123); + assert_eq!(currency_other_u64(&post_1_0_3_balance, 2), 0); + assert_eq!(post_1_0_3_balance.grams.as_u128() - pre_1_0_3_balance.grams.as_u128(), 123); + } + + #[test] + fn node_params_mvconfig_reaches_calc_mv_reward() { + let fixture = BuildActionsExecuteParamsFixture::regular(); + let phase = compute_node_contract( + "CALCMVREWARD\n\ + PUSHINT 0\n\ + EQUAL\n\ + THROWIFNOT 205\n", + calc_mv_reward_stack(), + fixture.build(), + ); + assert!(phase.success, "{phase:?}"); + + let mut fixture = BuildActionsExecuteParamsFixture::regular(); + fixture.mvconfig.set_config(vec![1, 3]); + let phase = compute_node_contract( + "CALCMVREWARD\n\ + PUSHINT 0\n\ + GREATER\n\ + THROWIFNOT 206\n", + calc_mv_reward_stack(), + fixture.build(), + ); + assert!(phase.success, "{phase:?}"); + } + + #[cfg(feature = "signature_with_id")] + #[test] + fn node_params_signature_id_reaches_chksignu() { + let signature_id = 17i32; + let data_hash = [0x42; 32]; + let key = tvm_types::Ed25519KeyOption::from_private_key(&[0x11; 32]).unwrap(); + let mut signed_data = signature_id.to_be_bytes().to_vec(); + signed_data.extend_from_slice(&data_hash); + let signature = key.sign(&signed_data).unwrap(); + let code = format!( + "PUSHINT 0x{}\n\ + PUSHSLICE x{}\n\ + PUSHINT 0x{}\n\ + CHKSIGNU\n\ + THROWIFNOT 203\n", + bytes_to_hex(&data_hash), + bytes_to_hex(&signature), + bytes_to_hex(key.pub_key().unwrap()) + ); + + let mut fixture = BuildActionsExecuteParamsFixture::regular(); + fixture.signature_id = signature_id; + let config = executor_config_with_capabilities( + 0x572e | GlobalCapabilities::CapSignatureWithId as u64, + ); + let (tx, _) = + execute_node_contract_with_config(&code, fixture.build(), config.clone()).unwrap(); + let phase = vm_phase(&tx); + assert!(phase.success, "{phase:?}"); + assert_eq!(phase.exit_code, 0); + + let mut fixture = BuildActionsExecuteParamsFixture::regular(); + fixture.signature_id = signature_id + 1; + let (tx, _) = execute_node_contract_with_config(&code, fixture.build(), config).unwrap(); + let phase = vm_phase(&tx); + assert!(!phase.success, "{phase:?}"); + assert_eq!(phase.exit_code, 203); + } + + #[cfg(feature = "wasmtime")] + #[test] + fn node_params_wasm_hash_whitelist_reaches_run_wasm() { + let hash_str = "7b7f96a857a4ada292d7c6b1f47940dde33112a2c2bc15b577dff9790edaeef2"; + let wasm_hash = bytes_from_hex(hash_str); + let mut fixture = BuildActionsExecuteParamsFixture::regular(); + fixture.wasm_cache.wasm_binary_root_path = "../tvm_vm/config/wasm".to_owned(); + fixture.wasm_cache.wasm_hash_whitelist.clear(); + fixture.wasm_cache.wasm_engine = + tvm_vm::executor::Engine::extern_wasm_engine_init().unwrap(); + + let phase = + compute_node_contract("RUNWASM\n", run_wasm_hash_stack(&wasm_hash), fixture.build()); + assert!(!phase.success, "{phase:?}"); + assert_eq!(phase.exit_code, ExceptionCode::WasmWhitelistForbiddenHash as i32); + } + + #[cfg(feature = "wasmtime")] + #[test] + fn node_params_wasm_whitelist_and_cache_allow_run_wasm() { + let hash_str = "7b7f96a857a4ada292d7c6b1f47940dde33112a2c2bc15b577dff9790edaeef2"; + let wasm_hash: [u8; 32] = bytes_from_hex(hash_str).try_into().unwrap(); + let wasm_engine = tvm_vm::executor::Engine::extern_wasm_engine_init().unwrap(); + let wasm_hash_whitelist: std::collections::HashSet<[u8; 32]> = + [wasm_hash].into_iter().collect(); + let wasm_component_cache = + tvm_vm::executor::Engine::extern_precompile_all_wasm_from_hash_list( + "../tvm_vm/config/wasm".to_owned(), + wasm_engine.clone(), + wasm_hash_whitelist.clone(), + ); + let mut fixture = BuildActionsExecuteParamsFixture::regular(); + fixture.wasm_cache.wasm_binary_root_path = "../tvm_vm/config/wasm".to_owned(); + fixture.wasm_cache.wasm_engine = wasm_engine.clone(); + fixture.wasm_cache.wasm_hash_whitelist = wasm_hash_whitelist.clone(); + fixture.wasm_cache.wasm_component_cache = wasm_component_cache; + + let phase = + compute_node_contract("RUNWASM\n", run_wasm_hash_stack(&wasm_hash), fixture.build()); + assert!(phase.success, "{phase:?}"); + assert_eq!(phase.exit_code, 0); + + let wrong_binary = std::fs::read( + "../tvm_vm/config/wasm/65b6403f531ba6504e590905712af3208ddcba3d0c4ea4c003d1ef9685ec4947", + ) + .unwrap(); + let wrong_component = + wasmtime::component::Component::new(&wasm_engine, wrong_binary.as_slice()).unwrap(); + let mut poisoned_cache = std::collections::HashMap::new(); + poisoned_cache.insert(wasm_hash, wrong_component); + let mut fixture = BuildActionsExecuteParamsFixture::regular(); + fixture.wasm_cache.wasm_binary_root_path = "../tvm_vm/config/wasm".to_owned(); + fixture.wasm_cache.wasm_engine = wasm_engine; + fixture.wasm_cache.wasm_hash_whitelist = wasm_hash_whitelist; + fixture.wasm_cache.wasm_component_cache = poisoned_cache; + + let phase = + compute_node_contract("RUNWASM\n", run_wasm_hash_stack(&wasm_hash), fixture.build()); + assert!(!phase.success, "{phase:?}"); + assert_ne!(phase.exit_code, 0); + } + #[test] fn action_phase_caps_shell_minting_and_applies_dapp_config_action() { let executor = DummyExecutor::new(); diff --git a/tvm_tl_codegen/src/lib.rs b/tvm_tl_codegen/src/lib.rs index 0305460f9..b85fe6ae4 100644 --- a/tvm_tl_codegen/src/lib.rs +++ b/tvm_tl_codegen/src/lib.rs @@ -2072,7 +2072,7 @@ impl Constructors { fn as_enum_doc(&self) -> String { use std::fmt::Write; let mut ret = - format!("TL-derived from `{}`\n\n```text\n", &self.first_constructor().original_output); + format!("TL-derived from `{}`\n\n```text\n", self.first_constructor().original_output); for (e, cm) in self.0.iter().enumerate() { if e != 0 { ret.write_str("\n\n").unwrap(); diff --git a/tvm_types/src/bls.rs b/tvm_types/src/bls.rs index 279b2bcef..dc30174b5 100644 --- a/tvm_types/src/bls.rs +++ b/tvm_types/src/bls.rs @@ -200,7 +200,7 @@ pub fn aggregate_bls_signatures(sig_bytes_with_nodes_info_vec: &[&[u8]]) -> Resu for it in &bls_sigs_refs { nodes_info_refs.push(&it.nodes_info); let sig = convert_signature_bytes_to_signature(&it.sig_bytes)?; - println!("{:?}", &sig.to_bytes()); + println!("{:?}", sig.to_bytes()); // return this part to exclude zero sig // let res = sig.validate(true); // if res.is_err() { @@ -294,11 +294,11 @@ impl BlsKeyPair { println!("BLS key pair:"); println!("--------------------------------------------------"); println!("Secret key bytes:"); - println!("{:?}", &self.sk_bytes); - println!("Secret key len: {}", &self.sk_bytes.len()); + println!("{:?}", self.sk_bytes); + println!("Secret key len: {}", self.sk_bytes.len()); println!("Public key bytes:"); - println!("{:?}", &self.pk_bytes); - println!("Public key len: {}", &self.pk_bytes.len()); + println!("{:?}", self.pk_bytes); + println!("Public key len: {}", self.pk_bytes.len()); println!("--------------------------------------------------"); } @@ -404,7 +404,7 @@ impl NodesInfo { pub fn print(&self) { println!("--------------------------------------------------"); - println!("Total number of nodes: {}", &self.total_num_of_nodes); + println!("Total number of nodes: {}", self.total_num_of_nodes); println!("Indexes -- occurrences: "); for (index, number_of_occurrence) in &self.map { println!("{}: \"{}\"", index, number_of_occurrence); @@ -609,7 +609,7 @@ impl BlsSignature { println!("Aggregated BLS signature:"); println!("--------------------------------------------------"); println!("Signature bytes:"); - println!("{:?}", &self.sig_bytes); + println!("{:?}", self.sig_bytes); self.nodes_info.print(); println!("--------------------------------------------------"); }