Skip to content

Commit

Permalink
Clippy + fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Jan 26, 2023
1 parent 630767d commit 66a38ee
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 27 deletions.
10 changes: 5 additions & 5 deletions apps/src/lib/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2241,11 +2241,11 @@ pub mod args {
DATA_PATH_OPT.name,
]),
)
.arg(
PROPOSAL_VOTE
.def()
.about("The vote for the proposal. Either yay or nay (with optional memo).\nDefault vote: yay | nay\nPGF vote: yay $council1 $cap1 $council2 $cap2 ... | nay"),
)
.arg(PROPOSAL_VOTE.def().about(
"The vote for the proposal. Either yay or nay (with \
optional memo).\nDefault vote: yay | nay\nPGF vote: yay \
$council1 $cap1 $council2 $cap2 ... | nay",
))
.arg(
PROPOSAL_OFFLINE
.def()
Expand Down
6 changes: 3 additions & 3 deletions apps/src/lib/client/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1788,9 +1788,9 @@ pub async fn query_bonded_stake(ctx: Context, args: args::QueryBondedStake) {
};
let is_active = validator_set.active.contains(&weighted);
if !is_active {
debug_assert!(validator_set
.inactive
.contains(&weighted));
debug_assert!(
validator_set.inactive.contains(&weighted)
);
}
println!(
"Validator {} is {}, bonded stake: {}",
Expand Down
28 changes: 18 additions & 10 deletions apps/src/lib/client/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2042,10 +2042,12 @@ pub async fn submit_vote_proposal(mut ctx: Context, args: args::VoteProposal) {
let proposal_type: ProposalType =
rpc::query_storage_value(&client, &proposal_type_key)
.await
.expect(&format!(
"Didn't find type of proposal id {} in storage",
proposal_id
));
.unwrap_or_else(|| {
panic!(
"Didn't find type of proposal id {} in storage",
proposal_id
)
});

if let ProposalVote::Yay(ref vote_type) = args.vote {
if &proposal_type != vote_type {
Expand All @@ -2055,23 +2057,29 @@ pub async fn submit_vote_proposal(mut ctx: Context, args: args::VoteProposal) {
);
safe_exit(1);
} else if let VoteType::PGFCouncil(set) = vote_type {
// Check that addresses proposed as council are established and are present in storage
// Check that addresses proposed as council are established and
// are present in storage
for (address, _) in set {
match address {
Address::Established(_) => {
let vp_key = Key::validity_predicate(&address);
let vp_key = Key::validity_predicate(address);
if !rpc::query_has_storage_key(&client, &vp_key)
.await
{
eprintln!("Proposed PGF council {} cannot be found in storage", address);
eprintln!(
"Proposed PGF council {} cannot be found \
in storage",
address
);
safe_exit(1);
}
}
_ => {
eprintln!(
"PGF council vote contains a non-established address: {}",
address
);
"PGF council vote contains a non-established \
address: {}",
address
);
safe_exit(1);
}
}
Expand Down
11 changes: 5 additions & 6 deletions core/src/types/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl FromStr for ProposalVote {

fn from_str(s: &str) -> Result<Self, Self::Err> {
let splits = s.trim().split_ascii_whitespace();
let mut iter = splits.clone().into_iter();
let mut iter = splits.clone();

match iter.next() {
Some(t) => match t {
Expand Down Expand Up @@ -119,11 +119,10 @@ impl ProposalVote {

/// Check if vote is of type default
pub fn is_default_vote(&self) -> bool {
match self {
ProposalVote::Yay(VoteType::Default) => true,
ProposalVote::Nay => true,
_ => false,
}
matches!(
self,
ProposalVote::Yay(VoteType::Default) | ProposalVote::Nay
)
}
}

Expand Down
5 changes: 3 additions & 2 deletions shared/src/ledger/native_vp/governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ where
) => {
if let ProposalVote::Yay(vote_type) = vote {
if proposal_type != vote_type {
//FIXME: technically this is needed only for Yay votes
// FIXME: technically this is needed only for Yay votes
return Ok(false);
}

Expand All @@ -214,7 +214,8 @@ where
for (address, _) in set {
match address {
Address::Established(_) => {
// Check that established address exists in storage
// Check that established address exists in
// storage
let vp_key =
Key::validity_predicate(&address);
if !self.ctx.has_key_pre(&vp_key)? {
Expand Down
3 changes: 2 additions & 1 deletion tests/src/e2e/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2789,7 +2789,8 @@ fn pgf_governance_proposal() -> Result<()> {
client.assert_success();

// FIXME: test not 1/3 of total voting power (vote with just the delegator)
// FIXME: test majority when 1/3 of votes (vote with both BERTHA and validator 0 anche check that validtor 0 won)
// FIXME: test majority when 1/3 of votes (vote with both BERTHA and
// validator 0 anche check that validtor 0 won)

// 12. Wait proposal grace and check proposal author funds
let mut epoch = get_epoch(&test, &validator_one_rpc).unwrap();
Expand Down

0 comments on commit 66a38ee

Please sign in to comment.