Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amityadav0 committed Sep 21, 2023
1 parent 6e8d31d commit 068be65
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions astra/src/bounties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ mod tests {
},
});
assert_eq!(contract.get_last_bounty_id(), id);
contract.act_proposal(id, Action::VoteApprove, None, None);
contract.act_proposal(id, Action::VoteApprove, None, Some(false));
id
}

Expand Down Expand Up @@ -269,7 +269,7 @@ mod tests {
"bounty_done"
);

contract.act_proposal(1, Action::VoteApprove, None, None);
contract.act_proposal(1, Action::VoteApprove, None, Some(false));
testing_env!(
context.build(),
near_sdk::VMConfig::test(),
Expand Down
8 changes: 5 additions & 3 deletions astra/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ mod tests {
let mut contract = Contract::new(
Config::test_config(),
VersionedPolicy::Default(vec![accounts(1)]),
ndc_trust()
);

let id = create_proposal(&mut context, &mut contract);
Expand All @@ -502,6 +503,7 @@ mod tests {
let mut contract = Contract::new(
Config::test_config(),
VersionedPolicy::Default(vec![accounts(1)]),
ndc_trust()
);

let id = create_proposal(&mut context, &mut contract);
Expand Down Expand Up @@ -596,12 +598,12 @@ mod tests {
// Other members vote
context.predecessor_account_id = council(2);
testing_env!(context.clone());
contract.act_proposal(id, Action::VoteApprove, Some("vote on prosposal".to_string()));
contract.act_proposal(id, Action::VoteApprove, Some("vote on prosposal".to_string()), None);
assert!(contract.get_proposal(id).proposal.votes.contains_key(&council(2)));

context.predecessor_account_id = council(3);
testing_env!(context.clone());
contract.act_proposal(id, Action::VoteReject, Some("vote on prosposal".to_string()));
contract.act_proposal(id, Action::VoteReject, Some("vote on prosposal".to_string()), None);
assert!(contract.get_proposal(id).proposal.votes.contains_key(&council(3)));

// Voting body vetos
Expand All @@ -612,7 +614,7 @@ mod tests {
// no more members should be able to vote
context.predecessor_account_id = council(4);
testing_env!(context);
contract.act_proposal(id, Action::VoteApprove, Some("vote on prosposal".to_string()));
contract.act_proposal(id, Action::VoteApprove, Some("vote on prosposal".to_string()), None);
}


Expand Down
1 change: 0 additions & 1 deletion astra/src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ mod tests {
"*:VoteReject".to_string(),
"*:VoteRemove".to_string(),
"*:Finalize".to_string(),
"*:Execute".to_string(),
]
.into_iter()
.collect();
Expand Down
6 changes: 1 addition & 5 deletions astra/src/proposals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,15 +541,11 @@ impl Contract {

/// Act on given proposal by id, if permissions allow.
/// Memo is logged but not stored in the state. Can be used to leave notes or explain the action.
<<<<<<< HEAD
pub fn act_proposal(&mut self, id: u64, action: Action, memo: Option<String>, skip_execution: Option<bool>) {
let execute = !skip_execution.unwrap_or(true);
=======
pub fn act_proposal(&mut self, id: u64, action: Action, memo: Option<String>) {
if self.status == ContractStatus::Dissolved {
panic!("Cannot perform this action, dao is dissolved!")
}
>>>>>>> c5fac1d2368e58353dbf6ee3520886889121b9c2
let execute = !skip_execution.unwrap_or(true);
let mut proposal: Proposal = self.proposals.get(&id).expect("ERR_NO_PROPOSAL").into();
let policy = self.policy.get().unwrap().to_policy();
// Check permissions for the given action.
Expand Down
2 changes: 1 addition & 1 deletion astra/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub enum Action {
/// Move a proposal to the hub to shift into another DAO.
MoveToHub,
/// Execute proposal and update proposal status
Execute
Execute,
/// Veto hook
VetoProposal,
/// Dissovle hook
Expand Down
2 changes: 1 addition & 1 deletion astra/tests/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub async fn vote(users: Vec<Account>, dao: &Contract, proposal_id: u64) -> anyh
for user in users.into_iter() {
let res = user
.call(dao.id(), "act_proposal")
.args_json(json!({"id": proposal_id, "action": Action::VoteApprove}))
.args_json(json!({"id": proposal_id, "action": Action::VoteApprove, "skip_execution": false}))
.max_gas()
.transact()
.await?;
Expand Down

0 comments on commit 068be65

Please sign in to comment.