Skip to content

Commit

Permalink
[refactor]: lints
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Balashov <[email protected]>
  • Loading branch information
0x009922 committed Feb 16, 2024
1 parent d10f251 commit 60361eb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
6 changes: 3 additions & 3 deletions core/src/gossiper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ impl TransactionGossiper {
let wsv = sumeragi.wsv_clone();
Self {
chain_id,
queue,
sumeragi,
network,
gossip_max_size,
gossip_period,
queue,
network,
sumeragi,
wsv,
}
}
Expand Down
8 changes: 4 additions & 4 deletions core/src/kura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl Kura {
pub fn blank_kura_for_testing() -> Arc<Kura> {
Arc::new(Self {
mode: Mode::Strict,
block_store: Mutex::new(BlockStore::new(&PathBuf::new(), LockStatus::Locked)),
block_store: Mutex::new(BlockStore::new(PathBuf::new(), LockStatus::Locked)),
block_data: Mutex::new(Vec::new()),
block_plain_text_path: None,
})
Expand Down Expand Up @@ -404,8 +404,8 @@ impl BlockStore {
match e.kind() {
std::io::ErrorKind::AlreadyExists => Err(Error::Locked(lock_path)),
std::io::ErrorKind::NotFound => {
match std::fs::create_dir_all(store_path)
.map_err(|e| Error::MkDir(e, store_path.to_path_buf()))
match std::fs::create_dir_all(store_path.as_ref())
.map_err(|e| Error::MkDir(e, store_path.as_ref().to_path_buf()))
{
Err(e) => Err(e),
Ok(()) => {
Expand All @@ -428,7 +428,7 @@ impl BlockStore {
}
}
BlockStore {
path_to_blockchain: store_path.to_path_buf(),
path_to_blockchain: store_path.as_ref().to_path_buf(),
}
}

Expand Down
21 changes: 11 additions & 10 deletions core/src/sumeragi/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ mod tests {
fn create_data_for_test(
chain_id: &ChainId,
topology: &Topology,
leader_key_pair: KeyPair,
leader_key_pair: &KeyPair,
) -> (WorldStateView, Arc<Kura>, SignedBlock) {
// Predefined world state
let alice_id: AccountId = "alice@wonderland".parse().expect("Valid");
Expand Down Expand Up @@ -1225,7 +1225,7 @@ mod tests {
// Creating a block of two identical transactions and validating it
let block = BlockBuilder::new(vec![tx.clone(), tx], topology.clone(), Vec::new())
.chain(0, &mut wsv)
.sign(&leader_key_pair);
.sign(leader_key_pair);

let genesis = block.commit(topology).expect("Block is valid");
wsv.apply(&genesis).expect("Failed to apply block");
Expand Down Expand Up @@ -1263,7 +1263,7 @@ mod tests {
// Creating a block of two identical transactions and validating it
let block = BlockBuilder::new(vec![tx1, tx2], topology.clone(), Vec::new())
.chain(0, &mut wsv.clone())
.sign(&leader_key_pair);
.sign(leader_key_pair);

(wsv, kura, block.into())
}
Expand All @@ -1279,7 +1279,7 @@ mod tests {
leader_key_pair.public_key().clone(),
)]);
let (finalized_wsv, _, mut block) =
create_data_for_test(&chain_id, &topology, leader_key_pair);
create_data_for_test(&chain_id, &topology, &leader_key_pair);
let wsv = finalized_wsv.clone();

// Malform block to make it invalid
Expand All @@ -1299,7 +1299,7 @@ mod tests {
leader_key_pair.public_key().clone(),
)]);
let (finalized_wsv, kura, mut block) =
create_data_for_test(&chain_id, &topology, leader_key_pair);
create_data_for_test(&chain_id, &topology, &leader_key_pair);
let mut wsv = finalized_wsv.clone();

let validated_block =
Expand Down Expand Up @@ -1327,7 +1327,7 @@ mod tests {
let topology = Topology::new(UniqueVec::new());
let leader_key_pair = KeyPair::generate().unwrap();
let (finalized_wsv, _, mut block) =
create_data_for_test(&chain_id, &topology, leader_key_pair);
create_data_for_test(&chain_id, &topology, &leader_key_pair);
let wsv = finalized_wsv.clone();

// Change block height
Expand Down Expand Up @@ -1356,7 +1356,8 @@ mod tests {
"127.0.0.1:8080".parse().unwrap(),
leader_key_pair.public_key().clone(),
)]);
let (finalized_wsv, _, block) = create_data_for_test(&chain_id, &topology, leader_key_pair);
let (finalized_wsv, _, block) =
create_data_for_test(&chain_id, &topology, &leader_key_pair);
let wsv = finalized_wsv.clone();
let result = handle_block_sync(&chain_id, block, &wsv, &finalized_wsv);
assert!(matches!(result, Ok(BlockSyncOk::CommitBlock(_, _))))
Expand All @@ -1372,7 +1373,7 @@ mod tests {
leader_key_pair.public_key().clone(),
)]);
let (finalized_wsv, kura, mut block) =
create_data_for_test(&chain_id, &topology, leader_key_pair);
create_data_for_test(&chain_id, &topology, &leader_key_pair);
let mut wsv = finalized_wsv.clone();

let validated_block =
Expand Down Expand Up @@ -1400,7 +1401,7 @@ mod tests {
leader_key_pair.public_key().clone(),
)]);
let (finalized_wsv, kura, mut block) =
create_data_for_test(&chain_id, &topology, leader_key_pair);
create_data_for_test(&chain_id, &topology, &leader_key_pair);
let mut wsv = finalized_wsv.clone();

// Increase block view change index
Expand Down Expand Up @@ -1438,7 +1439,7 @@ mod tests {
let topology = Topology::new(UniqueVec::new());
let leader_key_pair = KeyPair::generate().unwrap();
let (finalized_wsv, _, mut block) =
create_data_for_test(&chain_id, &topology, leader_key_pair);
create_data_for_test(&chain_id, &topology, &leader_key_pair);
let wsv = finalized_wsv.clone();

// Change block height and view change index
Expand Down

0 comments on commit 60361eb

Please sign in to comment.