Skip to content

Commit

Permalink
Add extra close() tests in passing
Browse files Browse the repository at this point in the history
  • Loading branch information
maurolacy committed Sep 27, 2020
1 parent 5e948fd commit 587c958
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions contracts/cw3-fixed-multisig/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ mod tests {
vote: Vote::Yes,
};
let env = mock_env(VOTER3, &[]);
let res = handle(&mut deps, env, vote).unwrap();
let res = handle(&mut deps, env.clone(), vote).unwrap();

// Verify
assert_eq!(
Expand All @@ -906,6 +906,19 @@ mod tests {
}
);

// In passing: Try to close Passed fails
let closing = HandleMsg::Close { proposal_id };
let res = handle(&mut deps, env, closing);

// Verify
assert!(res.is_err());
match res.unwrap_err() {
StdError::GenericErr { msg, .. } => {
assert_eq!(&msg, "Cannot close completed or passed proposals");
}
e => panic!("unexpected error: {}", e),
}

// Execute works. Anybody can execute Passed proposals
let env = mock_env(SOMEBODY, &[]);
let res = handle(&mut deps, env.clone(), execution).unwrap();
Expand All @@ -923,6 +936,19 @@ mod tests {
data: None,
}
);

// In passing: Try to close Executed fails
let closing = HandleMsg::Close { proposal_id };
let res = handle(&mut deps, env, closing);

// Verify
assert!(res.is_err());
match res.unwrap_err() {
StdError::GenericErr { msg, .. } => {
assert_eq!(&msg, "Cannot close completed or passed proposals");
}
e => panic!("unexpected error: {}", e),
}
}

#[test]
Expand Down Expand Up @@ -1004,7 +1030,7 @@ mod tests {
}
);

// Close it again fails
// Trying to close it again fails
let res = handle(&mut deps, env, closing);

// Verify
Expand All @@ -1015,7 +1041,5 @@ mod tests {
}
e => panic!("unexpected error: {}", e),
}

// TODO: Close Passed/Executed fails
}
}

0 comments on commit 587c958

Please sign in to comment.