Skip to content

Commit

Permalink
Merge pull request #4 from FigureTechnologies/ck/update-deposit-valid…
Browse files Browse the repository at this point in the history
…ation

removed validation for funds being present when depositing
  • Loading branch information
ChrisKenison authored Aug 30, 2023
2 parents 5b3a8bd + 0a9df9d commit 1af3854
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
28 changes: 9 additions & 19 deletions crates/contract/src/execute/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,10 @@ impl Validate for ExecuteMsg {
}

fn validate_msg_funds(&self, funds: &[Coin]) -> ValidateResult {
match self {
ExecuteMsg::DepositCommitment { securities: _ } => {
if funds.is_empty() {
return Err(ContractError::MissingFunds {});
}
Ok(())
}
_ => {
if !funds.is_empty() {
return Err(ContractError::UnexpectedFunds {});
}
Ok(())
}
if !funds.is_empty() {
return Err(ContractError::UnexpectedFunds {});
}
Ok(())
}
}

Expand Down Expand Up @@ -205,9 +195,12 @@ mod tests {
amount: Uint128::new(5),
}],
};
let funds = vec![];
let funds = vec![Coin {
denom: "denom".to_string(),
amount: Uint128::new(5),
}];
let output = msg.validate_msg_funds(&funds).unwrap_err();
let expected = ContractError::MissingFunds {}.to_string();
let expected = ContractError::UnexpectedFunds {}.to_string();
assert_eq!(expected, output.to_string());
}

Expand All @@ -219,10 +212,7 @@ mod tests {
amount: Uint128::new(5),
}],
};
let funds = vec![Coin {
denom: "denom".to_string(),
amount: Uint128::new(5),
}];
let funds = vec![];
msg.validate_msg_funds(&funds)
.expect("should pass with valid funds");
}
Expand Down
8 changes: 2 additions & 6 deletions crates/contract/src/util/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,8 @@ pub fn deposit_test(
sender: &str,
deposit: &[SecurityCommitment],
) -> ProvTxResponse {
let funds = deposit
.iter()
.fold(Coin::new(0, "denom".to_string()), |acc, commit| -> Coin {
Coin::new((commit.amount.u128() * 100) + acc.amount.u128(), acc.denom)
});
let info = mock_info(sender, &vec![funds]);
let funds = Vec::new();
let info = mock_info(sender, &funds);
let msg = test_deposit_message(deposit);
execute(deps, env, info, msg)
}
Expand Down

0 comments on commit 1af3854

Please sign in to comment.