Skip to content

Commit

Permalink
add test for ERR_NOT_ENOUGH_DEPOSIT error
Browse files Browse the repository at this point in the history
  • Loading branch information
ctindogaru committed Mar 30, 2022
1 parent b3c5d57 commit fc82b27
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions sputnikdao-factory2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,20 @@ mod tests {

use super::*;

#[test]
#[should_panic(expected = "ERR_NOT_ENOUGH_DEPOSIT")]
fn test_create_error() {
let mut context = VMContextBuilder::new();
testing_env!(context
.current_account_id(accounts(0))
.predecessor_account_id(accounts(0))
.build());
let mut factory = SputnikDAOFactory::new();

testing_env!(context.attached_deposit(to_yocto("5")).build());
factory.create("test".parse().unwrap(), "{}".as_bytes().to_vec().into());
}

#[test]
fn test_basics() {
let mut context = VMContextBuilder::new();
Expand All @@ -410,7 +424,7 @@ mod tests {
.build());
let mut factory = SputnikDAOFactory::new();

testing_env!(context.attached_deposit(to_yocto("10")).build());
testing_env!(context.attached_deposit(to_yocto("6")).build());
factory.create("test".parse().unwrap(), "{}".as_bytes().to_vec().into());

testing_env!(
Expand All @@ -422,7 +436,7 @@ mod tests {
);
factory.on_create(
format!("test.{}", accounts(0)).parse().unwrap(),
U128(to_yocto("10")),
U128(to_yocto("6")),
accounts(0),
);
assert_eq!(
Expand Down

0 comments on commit fc82b27

Please sign in to comment.