Skip to content

Commit

Permalink
all tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
ovstinga committed Aug 28, 2023
1 parent 083645d commit 0cdc69c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
23 changes: 8 additions & 15 deletions contracts/examples/multisig/tests/multisig_blackbox_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ enum Action {
AddProposer(Address),
RemoveUser(Address),
ChangeQuorum(usize),
SendTransferExecute(Address, u64, String, MultiValueVec<Vec<u8>>),
SendAsyncCall(Address, u64, String, MultiValueVec<Vec<u8>>),
SendTransferExecute(Address, u64, OptionalValue<String>, MultiValueVec<Vec<u8>>),
SendAsyncCall(Address, u64, OptionalValue<String>, MultiValueVec<Vec<u8>>),
SCDeployFromSource(u64, Address, CodeMetadata, MultiValueVec<Vec<u8>>),
SCUpgradeFromSource(Address, u64, Address, CodeMetadata, MultiValueVec<Vec<u8>>),
}
Expand Down Expand Up @@ -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();
Expand All @@ -415,28 +414,22 @@ 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)),
);

// failed attempt
let new_user_address = AddressValue::from(NEW_USER_ADDRESS_EXPR).to_address();
let opt_function: OptionalValue<String> = OptionalValue::None;

state.world.sc_call(
ScCallStep::new()
.from(PROPOSER_ADDRESS_EXPR)
.call(state.multisig_contract.propose_transfer_execute(
new_user_address.clone(),
0u64,
"".to_string(),
opt_function.clone(),
MultiValueVec::<Vec<u8>>::new(),
))
.expect(TxExpect::err(4, "str:proposed action has no effect")),
Expand All @@ -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::<Vec<u8>>::new(),
));
state.sign(action_id);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 7 additions & 2 deletions framework/scenario/src/scenario/model/step/sc_call_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit 0cdc69c

Please sign in to comment.