Skip to content

Commit

Permalink
evil: clippy + fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Dec 20, 2023
1 parent 82f6fb6 commit 0eb2896
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 116 deletions.
54 changes: 18 additions & 36 deletions sdk/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ impl TxCustom {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_custom(context, self).await
}
}
Expand Down Expand Up @@ -398,8 +397,7 @@ impl TxIbcTransfer {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_ibc_transfer(context, self).await
}
}
Expand Down Expand Up @@ -487,8 +485,7 @@ impl InitProposal {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
let current_epoch = rpc::query_epoch(context.client()).await?;
let governance_parameters =
rpc::query_governance_parameters(context.client()).await;
Expand Down Expand Up @@ -644,8 +641,7 @@ impl VoteProposal {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
let current_epoch = rpc::query_epoch(context.client()).await?;
tx::build_vote_proposal(context, self, current_epoch).await
}
Expand Down Expand Up @@ -717,8 +713,7 @@ impl TxInitAccount {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_init_account(context, self).await
}
}
Expand Down Expand Up @@ -872,8 +867,7 @@ impl TxUpdateAccount {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_update_account(context, self).await
}
}
Expand Down Expand Up @@ -950,8 +944,7 @@ impl Bond {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_bond(context, self).await
}
}
Expand Down Expand Up @@ -1130,8 +1123,7 @@ impl RevealPk {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_reveal_pk(context, &self.tx, &self.public_key).await
}
}
Expand Down Expand Up @@ -1214,8 +1206,7 @@ impl Withdraw {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_withdraw(context, self).await
}
}
Expand Down Expand Up @@ -1251,8 +1242,7 @@ impl ClaimRewards {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_claim_rewards(context, self).await
}
}
Expand Down Expand Up @@ -1384,8 +1374,7 @@ impl CommissionRateChange {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_validator_commission_change(context, self).await
}
}
Expand Down Expand Up @@ -1504,8 +1493,7 @@ impl MetaDataChange {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_validator_metadata_change(context, self).await
}
}
Expand Down Expand Up @@ -1560,8 +1548,7 @@ impl UpdateStewardCommission {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_update_steward_commission(context, self).await
}
}
Expand Down Expand Up @@ -1609,8 +1596,7 @@ impl ResignSteward {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_resign_steward(context, self).await
}
}
Expand Down Expand Up @@ -1658,8 +1644,7 @@ impl TxUnjailValidator {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_unjail_validator(context, self).await
}
}
Expand Down Expand Up @@ -1707,8 +1692,7 @@ impl TxDeactivateValidator {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_deactivate_validator(context, self).await
}
}
Expand Down Expand Up @@ -1756,8 +1740,7 @@ impl TxReactivateValidator {
pub async fn build(
&self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
tx::build_reactivate_validator(context, self).await
}
}
Expand Down Expand Up @@ -2293,8 +2276,7 @@ impl EthereumBridgePool {
pub async fn build(
self,
context: &impl Namada,
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)>
{
) -> crate::error::Result<(crate::proto::Tx, SigningTxData)> {
bridge_pool::build_bridge_pool_tx(context, self).await
}
}
Expand Down
120 changes: 40 additions & 80 deletions wasm/wasm_source/src/vp_user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,14 +550,10 @@ mod tests {
vp_env.all_touched_storage_keys();
let verifiers: BTreeSet<Address> = BTreeSet::default();
vp_host_env::set(vp_env);
assert!(validate_tx(
&CTX,
signed_tx,
vp_owner,
keys_changed,
verifiers
)
.unwrap());
assert!(
validate_tx(&CTX, signed_tx, vp_owner, keys_changed, verifiers)
.unwrap()
);
}

/// Test that a non-validator PoS action that must be authorized is rejected
Expand Down Expand Up @@ -808,14 +804,10 @@ mod tests {
vp_env.all_touched_storage_keys();
let verifiers: BTreeSet<Address> = BTreeSet::default();
vp_host_env::set(vp_env);
assert!(!validate_tx(
&CTX,
tx_data,
validator,
keys_changed,
verifiers
)
.unwrap());
assert!(
!validate_tx(&CTX, tx_data, validator, keys_changed, verifiers)
.unwrap()
);
}

/// Test that a non-validator PoS action that must be authorized is accepted
Expand Down Expand Up @@ -907,14 +899,10 @@ mod tests {
vp_env.all_touched_storage_keys();
let verifiers: BTreeSet<Address> = BTreeSet::default();
vp_host_env::set(vp_env);
assert!(validate_tx(
&CTX,
signed_tx,
vp_owner,
keys_changed,
verifiers
)
.unwrap());
assert!(
validate_tx(&CTX, signed_tx, vp_owner, keys_changed, verifiers)
.unwrap()
);
}

/// Test that a signed PoS action to become validator that must be
Expand Down Expand Up @@ -1005,14 +993,10 @@ mod tests {
vp_env.all_touched_storage_keys();
let verifiers: BTreeSet<Address> = BTreeSet::default();
vp_host_env::set(vp_env);
assert!(validate_tx(
&CTX,
signed_tx,
vp_owner,
keys_changed,
verifiers
)
.unwrap());
assert!(
validate_tx(&CTX, signed_tx, vp_owner, keys_changed, verifiers)
.unwrap()
);
}

/// Test that a validator PoS action that must be authorized is accepted
Expand Down Expand Up @@ -1114,14 +1098,10 @@ mod tests {
vp_env.all_touched_storage_keys();
let verifiers: BTreeSet<Address> = BTreeSet::default();
vp_host_env::set(vp_env);
assert!(validate_tx(
&CTX,
signed_tx,
validator,
keys_changed,
verifiers
)
.unwrap());
assert!(
validate_tx(&CTX, signed_tx, validator, keys_changed, verifiers)
.unwrap()
);
}

/// Test that a transfer on with accounts other than self is accepted.
Expand Down Expand Up @@ -1364,14 +1344,10 @@ mod tests {
vp_env.all_touched_storage_keys();
let verifiers: BTreeSet<Address> = BTreeSet::default();
vp_host_env::set(vp_env);
assert!(validate_tx(
&CTX,
signed_tx,
vp_owner,
keys_changed,
verifiers
)
.unwrap());
assert!(
validate_tx(&CTX, signed_tx, vp_owner, keys_changed, verifiers)
.unwrap()
);
}

/// Test that a validity predicate update is rejected if not whitelisted
Expand Down Expand Up @@ -1423,14 +1399,10 @@ mod tests {
vp_env.all_touched_storage_keys();
let verifiers: BTreeSet<Address> = BTreeSet::default();
vp_host_env::set(vp_env);
assert!(!validate_tx(
&CTX,
signed_tx,
vp_owner,
keys_changed,
verifiers
)
.unwrap());
assert!(
!validate_tx(&CTX, signed_tx, vp_owner, keys_changed, verifiers)
.unwrap()
);
}

/// Test that a validity predicate update is accepted if whitelisted
Expand Down Expand Up @@ -1483,14 +1455,10 @@ mod tests {
vp_env.all_touched_storage_keys();
let verifiers: BTreeSet<Address> = BTreeSet::default();
vp_host_env::set(vp_env);
assert!(validate_tx(
&CTX,
signed_tx,
vp_owner,
keys_changed,
verifiers
)
.unwrap());
assert!(
validate_tx(&CTX, signed_tx, vp_owner, keys_changed, verifiers)
.unwrap()
);
}

/// Test that a tx is rejected if not whitelisted
Expand Down Expand Up @@ -1543,14 +1511,10 @@ mod tests {
vp_env.all_touched_storage_keys();
let verifiers: BTreeSet<Address> = BTreeSet::default();
vp_host_env::set(vp_env);
assert!(!validate_tx(
&CTX,
signed_tx,
vp_owner,
keys_changed,
verifiers
)
.unwrap());
assert!(
!validate_tx(&CTX, signed_tx, vp_owner, keys_changed, verifiers)
.unwrap()
);
}

#[test]
Expand Down Expand Up @@ -1603,13 +1567,9 @@ mod tests {
vp_env.all_touched_storage_keys();
let verifiers: BTreeSet<Address> = BTreeSet::default();
vp_host_env::set(vp_env);
assert!(validate_tx(
&CTX,
signed_tx,
vp_owner,
keys_changed,
verifiers
)
.unwrap());
assert!(
validate_tx(&CTX, signed_tx, vp_owner, keys_changed, verifiers)
.unwrap()
);
}
}

0 comments on commit 0eb2896

Please sign in to comment.