Skip to content

Commit

Permalink
fmt, clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianmarco Fraccaroli committed Dec 14, 2023
1 parent 803ffe2 commit eba1e3b
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 28 deletions.
6 changes: 2 additions & 4 deletions src/checks/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct StorageCheckParametersDto {
pub struct StorageCheckParameters {
step: u64,
field: String,
value: String
value: String,
}

impl CheckParam for StorageCheckParameters {
Expand All @@ -50,9 +50,7 @@ impl CheckParam for StorageCheckParameters {
let step = dto.step;
let field = dto.field;
let value = match dto.value {
Value::Ref { value, field } => {
state.get_step_item(&value, &field)
},
Value::Ref { value, field } => state.get_step_item(&value, &field),
Value::Value { value } => value,
Value::Fuzz {} => unimplemented!(),
};
Expand Down
3 changes: 1 addition & 2 deletions src/queries/validators.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use async_trait::async_trait;

use namada_sdk::{rpc, Namada};
use serde::Deserialize;
use namada_sdk::core::types::storage::Epoch;

use crate::{
entity::address::{AccountIndentifier, ADDRESS_PREFIX},
scenario::StepResult,
sdk::namada::Sdk,
state::state::{StepStorage, Storage},
Expand Down
20 changes: 11 additions & 9 deletions src/scenario.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ use crate::{
balance::{BalanceCheck, BalanceCheckParametersDto},
bonds::{BondsCheck, BondsCheckParametersDto},
step::{StepCheck, StepCheckParametersDto},
Check, storage::{StorageCheck, StorageCheckParametersDto},
storage::{StorageCheck, StorageCheckParametersDto},
Check,
},
queries::{
account::{AccountQuery, AccountQueryParametersDto},
balance::{BalanceQuery, BalanceQueryParametersDto},
bonded_stake::{BondedStakeQuery, BondedStakeQueryParametersDto},
proposal::{ProposalQuery, ProposalQueryParametersDto},
Query, validators::{ValidatorsQueryParametersDto, ValidatorsQuery},
validators::{ValidatorsQuery, ValidatorsQueryParametersDto},
Query,
},
sdk::namada::Sdk,
state::state::{StateAddress, StepOutcome, StepStorage, Storage},
Expand Down Expand Up @@ -97,12 +99,12 @@ pub enum StepType {
},
#[serde(rename = "check-storage")]
CheckStorage {
parameters: StorageCheckParametersDto
parameters: StorageCheckParametersDto,
},
#[serde(rename = "query-validators")]
QueryValidators {
parameters: ValidatorsQueryParametersDto
}
parameters: ValidatorsQueryParametersDto,
},
}

impl Display for StepType {
Expand All @@ -127,7 +129,6 @@ impl Display for StepType {
StepType::VoteProposal { .. } => write!(f, "tx-vote-proposal"),
StepType::CheckStorage { .. } => write!(f, "check-storage"),
StepType::QueryValidators { .. } => write!(f, "query-validators"),

}
}
}
Expand Down Expand Up @@ -200,9 +201,10 @@ impl Step {
.await
}
StepType::QueryValidators { parameters } => {
ValidatorsQuery::default().run(sdk, parameters, storage).await
},

ValidatorsQuery::default()
.run(sdk, parameters, storage)
.await
}
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/tasks/bond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
scenario::StepResult,
sdk::namada::Sdk,
state::state::{StepStorage, Storage},
utils::{value::Value},
utils::value::Value,
};

use super::{Task, TaskParam};
Expand Down Expand Up @@ -166,7 +166,6 @@ impl TaskParam for TxBondParameters {
source,
validator,
amount,

}
}
}
11 changes: 6 additions & 5 deletions src/tasks/init_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use namada_sdk::{
signing::default_sign, Namada,
};

use rand::Rng;

use serde::Deserialize;

use crate::{
Expand All @@ -15,7 +15,7 @@ use crate::{
sdk::namada::Sdk,
state::state::{StepStorage, Storage},
utils::{
proposal::{ProposalType, Proposal},
proposal::{Proposal, ProposalType},
value::Value,
},
};
Expand Down Expand Up @@ -93,7 +93,8 @@ impl Task for TxInitProposal {
end_epoch,
grace_epoch,
proposal_type,
).build_proposal();
)
.build_proposal();

// Eventually use the generate proposal.json file and then load it
let proposal_data = proposal.as_bytes().to_vec();
Expand Down Expand Up @@ -226,14 +227,14 @@ impl TaskParam for TxInitProposalParameters {
unimplemented!() // can't refertence a past epoch as end epoch
}
Value::Value { value } => value.parse::<u64>().unwrap(),
Value::Fuzz {} => unimplemented!()
Value::Fuzz {} => unimplemented!(),
});
let end_epoch = dto.end_epoch.map(|end_epoch| match end_epoch {
Value::Ref { value: _, field: _ } => {
unimplemented!() // can't refertence a past epoch as end epoch
}
Value::Value { value } => value.parse::<u64>().unwrap(),
Value::Fuzz {} => unimplemented!()
Value::Fuzz {} => unimplemented!(),
});
let grace_epoch = dto.grace_epoch.map(|grace_epoch| match grace_epoch {
Value::Ref { value: _, field: _ } => unimplemented!(), // can't refertence a past epoch as grace epoch
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub mod settings;
pub mod proposal;
pub mod settings;
pub mod value;
5 changes: 1 addition & 4 deletions src/utils/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ impl Proposal {
}

#[allow(dead_code)]
fn write_proposal(
proposal_path: &PathBuf,
proposal_content: &str,
) {
fn write_proposal(proposal_path: &PathBuf, proposal_content: &str) {
let intent_writer = std::fs::OpenOptions::new()
.create(true)
.write(true)
Expand Down
2 changes: 1 addition & 1 deletion src/waits/epoch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl WaitParam for EpochWaitParameters {
let to = dto.to.map(|to| match to {
Value::Ref { value, field } => {
state.get_step_item(&value, &field).parse::<u64>().unwrap()
},
}
Value::Value { value } => value.parse::<u64>().unwrap(),
Value::Fuzz {} => unimplemented!(),
});
Expand Down

0 comments on commit eba1e3b

Please sign in to comment.