Skip to content

Commit

Permalink
add simulation test
Browse files Browse the repository at this point in the history
  • Loading branch information
constantindogaru committed Nov 25, 2021
1 parent 7b5ef97 commit 7ca7e1f
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions sputnikdao2/tests/test_general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,56 @@ fn test_create_dao_and_use_token() {
);
}

#[test]
fn test_check_daos_activity() {
let (root, dao_factory) = setup_dao_factory();

call!(
&root,
dao_factory.create(
"dao1".parse().unwrap(),
None,
"{\"config\": {\"name\": \"Test1\", \"purpose\": \"to test1\", \"metadata\": \"\"}, \"policy\": [\"dao1\"]}".as_bytes().to_vec().into()
),
deposit = to_yocto("10")
).assert_success();

call!(
&root,
dao_factory.create(
"dao2".parse().unwrap(),
None,
"{\"config\": {\"name\": \"Test2\", \"purpose\": \"to test2\", \"metadata\": \"\", \"self_destruct_config\": {\"max_days_of_inactivity\": \"0\", \"dedicated_account\": \"root\"}}, \"policy\": [\"dao2\"]}".as_bytes().to_vec().into()
),
deposit = to_yocto("10")
).assert_success();

call!(
&root,
dao_factory.create(
"dao3".parse().unwrap(),
None,
"{\"config\": {\"name\": \"Test3\", \"purpose\": \"to test3\", \"metadata\": \"\", \"self_destruct_config\": {\"max_days_of_inactivity\": \"7\", \"dedicated_account\": \"root\"}}, \"policy\": [\"dao3\"]}".as_bytes().to_vec().into()
),
deposit = to_yocto("10")
).assert_success();

let dao_list = view!(dao_factory.get_dao_list()).unwrap_json::<Vec<AccountId>>();
assert_eq!(3, dao_list.len());
assert_eq!("dao1.dao_factory", dao_list[0].as_str());
assert_eq!("dao2.dao_factory", dao_list[1].as_str());
assert_eq!("dao3.dao_factory", dao_list[2].as_str());

// TODO: add a proposal to dao2

// call!(&root, dao_factory.check_daos_activity()).assert_success();

// let dao_list = view!(dao_factory.get_dao_list()).unwrap_json::<Vec<AccountId>>();
// assert_eq!(2, dao_list.len());
// assert_eq!("dao1.dao_factory", dao_list[0].as_str());
// assert_eq!("dao3.dao_factory", dao_list[1].as_str());
}

/// Test various cases that must fail.
#[test]
fn test_failures() {
Expand Down

0 comments on commit 7ca7e1f

Please sign in to comment.