Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added create job tests #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions contracts/warp-controller/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ pub enum ContractError {

#[error("Variable vector contains unused variables.")]
ExcessVariablesInVector {},

#[error("Account balance smaller than job reward.")]
AccountBalanceSmallerThanJobReward {},
}

impl From<serde_json_wasm::de::Error> for ContractError {
Expand Down
16 changes: 11 additions & 5 deletions contracts/warp-controller/src/execute/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ pub fn create_job(
return Err(ContractError::ExcessVariablesInVector {});
}

if !msgs_valid(&data.msgs, &data.vars)? {
return Err(ContractError::MsgError {
msg: "msgs are invalid".to_string(),
});
}
msgs_valid(&data.msgs, &data.vars)?;

let q = ACCOUNTS()
.idx
Expand All @@ -76,6 +72,16 @@ pub fn create_job(
Some(q) => q.1,
};

// compare contract balance with job reward
let account_balance = deps
.querier
.query_balance(&account.account, "uluna")?
.amount;

if account_balance < data.reward {
Err(ContractError::AccountBalanceSmallerThanJobReward {})?;
}

// let mut msgs = vec![];
// for msg in data.msgs {
// msgs.push(serde_json_wasm::from_str::<CosmosMsg>(msg.as_str())?)
Expand Down
Loading