Skip to content

Commit

Permalink
Clippy + fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Feb 6, 2023
1 parent 23a2738 commit 2ef641a
Show file tree
Hide file tree
Showing 12 changed files with 206 additions and 99 deletions.
38 changes: 21 additions & 17 deletions apps/src/lib/node/ledger/shell/process_proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,18 @@ where
return TxResult {
code: ErrorCodes::InvalidChainId.into(),
info: format!(
"Tx carries a wrong chain id: expected {}, found {}",
self.chain_id, tx_chain_id
),
"Tx carries a wrong chain id: expected {}, \
found {}",
self.chain_id, tx_chain_id
),
};
}
TxResult {
code: ErrorCodes::InvalidTx.into(),
info:
"Protocol transactions are a fun new feature that \
is coming soon to a blockchain near you. Patience."
.into(),
info: "Protocol transactions are a fun new feature \
that is coming soon to a blockchain near you. \
Patience."
.into(),
}
}
TxType::Decrypted(tx) => {
Expand All @@ -174,9 +175,10 @@ where
code: ErrorCodes::InvalidChainId
.into(),
info: format!(
"Tx carries a wrong chain id: expected {}, found {}",
self.chain_id, tx.chain_id
),
"Tx carries a wrong chain id: \
expected {}, found {}",
self.chain_id, tx.chain_id
),
};
}
}
Expand Down Expand Up @@ -211,9 +213,10 @@ where
return TxResult {
code: ErrorCodes::InvalidChainId.into(),
info: format!(
"Tx carries a wrong chain id: expected {}, found {}",
self.chain_id, tx_chain_id
),
"Tx carries a wrong chain id: expected {}, \
found {}",
self.chain_id, tx_chain_id
),
};
}

Expand Down Expand Up @@ -1234,7 +1237,7 @@ mod test_process_proposal {
.sign(&keypair, wrong_chain_id.clone())
.expect("Test failed");

let protocol_tx = ProtocolTxType::EthereumStateUpdate(tx.clone()).sign(
let protocol_tx = ProtocolTxType::EthereumStateUpdate(tx).sign(
&keypair.ref_to(),
&keypair,
wrong_chain_id.clone(),
Expand Down Expand Up @@ -1289,9 +1292,10 @@ mod test_process_proposal {
assert_eq!(
res.result.info,
format!(
"Tx carries a wrong chain id: expected {}, found {}",
shell.chain_id, wrong_chain_id
)
"Tx carries a wrong chain id: expected {}, found \
{}",
shell.chain_id, wrong_chain_id
)
);
}
}
Expand Down
3 changes: 1 addition & 2 deletions core/src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ mod tests {
use generated::types::Tx;
use prost::Message;

use crate::types::chain::ChainId;

use super::*;
use crate::types::chain::ChainId;

#[test]
fn encoding_round_trip() {
Expand Down
9 changes: 5 additions & 4 deletions core/src/types/transaction/decrypted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ pub mod decrypted_tx {
tx,
has_valid_pow: _,
} => tx.chain_id.to_owned(),
// If undecrytable we cannot extract the ChainId. The ChainId for the
// wrapper has already been checked previously and the inner transaction
// will fail because undecryptable. Here we simply put an empty string
// as a placeholder
// If undecrytable we cannot extract the ChainId. The ChainId
// for the wrapper has already been checked
// previously and the inner transaction
// will fail because undecryptable. Here we simply put an empty
// string as a placeholder
DecryptedTx::Undecryptable(_) => ChainId(String::new()),
};

Expand Down
4 changes: 3 additions & 1 deletion core/src/types/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ pub mod tx_types {
Tx::new(
vec![],
Some(ty.try_to_vec().unwrap()),
ChainId(String::new()), // No need to provide a valid ChainId when casting back from TxType
ChainId(String::new()), /* No need to provide a valid
* ChainId when casting back from
* TxType */
)
}
}
Expand Down
Loading

0 comments on commit 2ef641a

Please sign in to comment.