From 0cdc69ced898b851cc984498a31cbab8c5f3b491 Mon Sep 17 00:00:00 2001 From: Ovidiu Stinga Date: Mon, 28 Aug 2023 12:48:39 +0300 Subject: [PATCH] all tests pass --- .../multisig/tests/multisig_blackbox_test.rs | 23 +++++++------------ .../src/scenario/model/step/sc_call_step.rs | 9 ++++++-- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/contracts/examples/multisig/tests/multisig_blackbox_test.rs b/contracts/examples/multisig/tests/multisig_blackbox_test.rs index 55c21a3360..453bedfc97 100644 --- a/contracts/examples/multisig/tests/multisig_blackbox_test.rs +++ b/contracts/examples/multisig/tests/multisig_blackbox_test.rs @@ -50,8 +50,8 @@ enum Action { AddProposer(Address), RemoveUser(Address), ChangeQuorum(usize), - SendTransferExecute(Address, u64, String, MultiValueVec>), - SendAsyncCall(Address, u64, String, MultiValueVec>), + SendTransferExecute(Address, u64, OptionalValue, MultiValueVec>), + SendAsyncCall(Address, u64, OptionalValue, MultiValueVec>), SCDeployFromSource(u64, Address, CodeMetadata, MultiValueVec>), SCUpgradeFromSource(Address, u64, Address, CodeMetadata, MultiValueVec>), } @@ -396,7 +396,6 @@ fn test_change_quorum() { } #[test] -#[ignore = "not yet implemented"] fn test_transfer_execute_to_user() { let mut state = MultisigTestState::new(); state.deploy_multisig_contract(); @@ -415,13 +414,6 @@ fn test_transfer_execute_to_user() { .call(state.multisig_contract.deposit()), ); - state - .world - .check_state_step(CheckStateStep::new().put_account( - PROPOSER_ADDRESS_EXPR, - CheckAccount::new().balance("99,999,900"), - )); - state.world.check_state_step( CheckStateStep::new() .put_account(MULTISIG_ADDRESS_EXPR, CheckAccount::new().balance(AMOUNT)), @@ -429,6 +421,7 @@ fn test_transfer_execute_to_user() { // failed attempt let new_user_address = AddressValue::from(NEW_USER_ADDRESS_EXPR).to_address(); + let opt_function: OptionalValue = OptionalValue::None; state.world.sc_call( ScCallStep::new() @@ -436,7 +429,7 @@ fn test_transfer_execute_to_user() { .call(state.multisig_contract.propose_transfer_execute( new_user_address.clone(), 0u64, - "".to_string(), + opt_function.clone(), MultiValueVec::>::new(), )) .expect(TxExpect::err(4, "str:proposed action has no effect")), @@ -446,7 +439,7 @@ fn test_transfer_execute_to_user() { let action_id = state.propose(Action::SendTransferExecute( new_user_address.clone(), AMOUNT.parse().unwrap(), - "".to_string(), + opt_function, MultiValueVec::>::new(), )); state.sign(action_id); @@ -467,7 +460,7 @@ fn test_transfer_execute_sc_all() { let action_id = state.propose(Action::SendTransferExecute( adder_contract_address.clone(), 0u64, - "add".to_string(), + OptionalValue::Some("add".to_string()), MultiValueVec::from([top_encode_to_vec_u8_or_panic(&5u64)]), )); state.sign(action_id); @@ -491,7 +484,7 @@ fn test_async_call_to_sc() { let action_id = state.propose(Action::SendAsyncCall( adder_contract_address.clone(), 0u64, - "add".to_string(), + OptionalValue::Some("add".to_string()), MultiValueVec::from([top_encode_to_vec_u8_or_panic(&5u64)]), )); state.sign(action_id); @@ -541,7 +534,7 @@ fn test_deploy_and_upgrade_from_source() { let action_id = state.propose(Action::SendTransferExecute( new_adder_address.clone(), 0u64, - "add".to_string(), + OptionalValue::Some("add".to_string()), MultiValueVec::from([top_encode_to_vec_u8_or_panic(&5u64)]), )); state.sign(action_id); diff --git a/framework/scenario/src/scenario/model/step/sc_call_step.rs b/framework/scenario/src/scenario/model/step/sc_call_step.rs index 7fbe5dbed8..0747f7d491 100644 --- a/framework/scenario/src/scenario/model/step/sc_call_step.rs +++ b/framework/scenario/src/scenario/model/step/sc_call_step.rs @@ -122,8 +122,13 @@ impl ScCallStep { let (to_str, function, egld_value_expr, scenario_args) = process_contract_call(contract_call); self = self.to(to_str.as_str()); - self = self.function(function.as_str()); - self = self.egld_value(egld_value_expr); + + if self.tx.function.is_empty() { + self = self.function(function.as_str()); + } + if self.tx.egld_value.value == 0u32.into() { + self = self.egld_value(egld_value_expr); + } for arg in scenario_args { self = self.argument(arg.as_str()); }