Upgrade Rust to 1.52.0 (#17096)

* Upgrade Rust to 1.52.0
update nightly_version to newly pushed docker image
fix clippy lint errors
1.52 comes with grcov 0.8.0, include this version to script

* upgrade to Rust 1.52.1

* disabling Serum from downstream projects until it is upgraded to Rust 1.52.1
This commit is contained in:
Tao Zhu 2021-05-19 09:31:47 -05:00 committed by GitHub
parent 4788976517
commit 0781fe1b4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
54 changed files with 345 additions and 423 deletions

1
Cargo.lock generated
View File

@ -4519,7 +4519,6 @@ dependencies = [
name = "solana-frozen-abi-macro"
version = "1.7.0"
dependencies = [
"lazy_static",
"proc-macro2 1.0.24",
"quote 1.0.6",
"rustc_version",

View File

@ -1,4 +1,4 @@
FROM solanalabs/rust:1.51.0
FROM solanalabs/rust:1.52.1
ARG date
RUN set -x \

View File

@ -1,6 +1,6 @@
# Note: when the rust version is changed also modify
# ci/rust-version.sh to pick up the new image tag
FROM rust:1.51.0
FROM rust:1.52.1
# Add Google Protocol Buffers for Libra's metrics library.
ENV PROTOC_VERSION 3.8.0

View File

@ -18,13 +18,13 @@
if [[ -n $RUST_STABLE_VERSION ]]; then
stable_version="$RUST_STABLE_VERSION"
else
stable_version=1.51.0
stable_version=1.52.1
fi
if [[ -n $RUST_NIGHTLY_VERSION ]]; then
nightly_version="$RUST_NIGHTLY_VERSION"
else
nightly_version=2021-04-18
nightly_version=2021-05-18
fi

View File

@ -231,18 +231,9 @@ mod tests {
mocks.insert(RpcRequest::GetBalance, account_balance_response);
let rpc_client = RpcClient::new_mock_with_mocks("".to_string(), mocks);
assert_eq!(
check_account_for_balance(&rpc_client, &pubkey, 1).unwrap(),
true
);
assert_eq!(
check_account_for_balance(&rpc_client, &pubkey, account_balance).unwrap(),
true
);
assert_eq!(
check_account_for_balance(&rpc_client, &pubkey, account_balance + 1).unwrap(),
false
);
assert!(check_account_for_balance(&rpc_client, &pubkey, 1).unwrap());
assert!(check_account_for_balance(&rpc_client, &pubkey, account_balance).unwrap());
assert!(!check_account_for_balance(&rpc_client, &pubkey, account_balance + 1).unwrap());
}
#[test]

View File

@ -10,7 +10,6 @@ macro_rules! ACCOUNT_STRING {
};
}
#[macro_use]
macro_rules! pubkey {
($arg:expr, $help:expr) => {
$arg.takes_value(true)

View File

@ -72,7 +72,7 @@ fn test_cli_program_deploy_non_upgradeable() {
let account0 = rpc_client.get_account(&program_id).unwrap();
assert_eq!(account0.lamports, minimum_balance_for_rent_exemption);
assert_eq!(account0.owner, bpf_loader::id());
assert_eq!(account0.executable, true);
assert!(account0.executable);
let mut file = File::open(pathbuf.to_str().unwrap().to_string()).unwrap();
let mut elf = Vec::new();
file.read_to_end(&mut elf).unwrap();
@ -93,7 +93,7 @@ fn test_cli_program_deploy_non_upgradeable() {
.unwrap();
assert_eq!(account1.lamports, minimum_balance_for_rent_exemption);
assert_eq!(account1.owner, bpf_loader::id());
assert_eq!(account1.executable, true);
assert!(account1.executable);
assert_eq!(account1.data, account0.data);
// Attempt to redeploy to the same address
@ -129,7 +129,7 @@ fn test_cli_program_deploy_non_upgradeable() {
.unwrap();
assert_eq!(account2.lamports, 2 * minimum_balance_for_rent_exemption);
assert_eq!(account2.owner, bpf_loader::id());
assert_eq!(account2.executable, true);
assert!(account2.executable);
assert_eq!(account2.data, account0.data);
}
@ -289,7 +289,7 @@ fn test_cli_program_deploy_with_authority() {
let program_account = rpc_client.get_account(&program_keypair.pubkey()).unwrap();
assert_eq!(program_account.lamports, minimum_balance_for_program);
assert_eq!(program_account.owner, bpf_loader_upgradeable::id());
assert_eq!(program_account.executable, true);
assert!(program_account.executable);
let (programdata_pubkey, _) = Pubkey::find_program_address(
&[program_keypair.pubkey().as_ref()],
&bpf_loader_upgradeable::id(),
@ -300,7 +300,7 @@ fn test_cli_program_deploy_with_authority() {
minimum_balance_for_programdata
);
assert_eq!(programdata_account.owner, bpf_loader_upgradeable::id());
assert_eq!(programdata_account.executable, false);
assert!(!programdata_account.executable);
assert_eq!(
programdata_account.data[UpgradeableLoaderState::programdata_data_offset().unwrap()..],
program_data[..]
@ -332,7 +332,7 @@ fn test_cli_program_deploy_with_authority() {
let program_account = rpc_client.get_account(&program_pubkey).unwrap();
assert_eq!(program_account.lamports, minimum_balance_for_program);
assert_eq!(program_account.owner, bpf_loader_upgradeable::id());
assert_eq!(program_account.executable, true);
assert!(program_account.executable);
let (programdata_pubkey, _) =
Pubkey::find_program_address(&[program_pubkey.as_ref()], &bpf_loader_upgradeable::id());
let programdata_account = rpc_client.get_account(&programdata_pubkey).unwrap();
@ -341,7 +341,7 @@ fn test_cli_program_deploy_with_authority() {
minimum_balance_for_programdata
);
assert_eq!(programdata_account.owner, bpf_loader_upgradeable::id());
assert_eq!(programdata_account.executable, false);
assert!(!programdata_account.executable);
assert_eq!(
programdata_account.data[UpgradeableLoaderState::programdata_data_offset().unwrap()..],
program_data[..]
@ -364,7 +364,7 @@ fn test_cli_program_deploy_with_authority() {
let program_account = rpc_client.get_account(&program_pubkey).unwrap();
assert_eq!(program_account.lamports, minimum_balance_for_program);
assert_eq!(program_account.owner, bpf_loader_upgradeable::id());
assert_eq!(program_account.executable, true);
assert!(program_account.executable);
let (programdata_pubkey, _) =
Pubkey::find_program_address(&[program_pubkey.as_ref()], &bpf_loader_upgradeable::id());
let programdata_account = rpc_client.get_account(&programdata_pubkey).unwrap();
@ -373,7 +373,7 @@ fn test_cli_program_deploy_with_authority() {
minimum_balance_for_programdata
);
assert_eq!(programdata_account.owner, bpf_loader_upgradeable::id());
assert_eq!(programdata_account.executable, false);
assert!(!programdata_account.executable);
assert_eq!(
programdata_account.data[UpgradeableLoaderState::programdata_data_offset().unwrap()..],
program_data[..]
@ -418,7 +418,7 @@ fn test_cli_program_deploy_with_authority() {
let program_account = rpc_client.get_account(&program_pubkey).unwrap();
assert_eq!(program_account.lamports, minimum_balance_for_program);
assert_eq!(program_account.owner, bpf_loader_upgradeable::id());
assert_eq!(program_account.executable, true);
assert!(program_account.executable);
let (programdata_pubkey, _) =
Pubkey::find_program_address(&[program_pubkey.as_ref()], &bpf_loader_upgradeable::id());
let programdata_account = rpc_client.get_account(&programdata_pubkey).unwrap();
@ -427,7 +427,7 @@ fn test_cli_program_deploy_with_authority() {
minimum_balance_for_programdata
);
assert_eq!(programdata_account.owner, bpf_loader_upgradeable::id());
assert_eq!(programdata_account.executable, false);
assert!(!programdata_account.executable);
assert_eq!(
programdata_account.data[UpgradeableLoaderState::programdata_data_offset().unwrap()..],
program_data[..]

View File

@ -2034,7 +2034,7 @@ mod tests {
// Send erroneous parameter
let blockhash: ClientResult<String> =
rpc_client.send(RpcRequest::GetRecentBlockhash, json!(["parameter"]));
assert_eq!(blockhash.is_err(), true);
assert!(blockhash.is_err());
}
#[test]

View File

@ -1547,7 +1547,7 @@ mod tests {
.collect();
trace!("done");
assert_eq!(entries.len(), genesis_config.ticks_per_slot as usize);
assert_eq!(entries.verify(&start_hash), true);
assert!(entries.verify(&start_hash));
assert_eq!(entries[entries.len() - 1].hash, bank.last_blockhash());
banking_stage.join().unwrap();
}
@ -1656,7 +1656,7 @@ mod tests {
.map(|(_bank, (entry, _tick_height))| entry)
.collect();
assert_eq!(entries.verify(&blockhash), true);
assert!(entries.verify(&blockhash));
if !entries.is_empty() {
blockhash = entries.last().unwrap().hash;
for entry in entries {
@ -2124,7 +2124,7 @@ mod tests {
}
trace!("done ticking");
assert_eq!(done, true);
assert!(done);
let transactions = vec![system_transaction::transfer(
&mint_keypair,

View File

@ -2369,6 +2369,7 @@ impl ClusterInfo {
}
}
#[allow(clippy::needless_collect)]
fn handle_batch_push_messages(
&self,
messages: Vec<(Pubkey, Vec<CrdsValue>)>,
@ -3229,6 +3230,7 @@ mod tests {
}
#[test]
#[allow(clippy::needless_collect)]
fn test_handle_ping_messages() {
let mut rng = rand::thread_rng();
let this_node = Arc::new(Keypair::new());
@ -3583,7 +3585,7 @@ mod tests {
.unwrap()
.new_push_messages(cluster_info.drain_push_queue(), timestamp());
// there should be some pushes ready
assert_eq!(push_messages.is_empty(), false);
assert!(!push_messages.is_empty());
push_messages
.values()
.for_each(|v| v.par_iter().for_each(|v| assert!(v.verify())));
@ -3934,6 +3936,7 @@ mod tests {
}
#[test]
#[allow(clippy::needless_collect)]
fn test_split_messages_packet_size() {
// Test that if a value is smaller than payload size but too large to be wrapped in a vec
// that it is still dropped
@ -3967,9 +3970,10 @@ mod tests {
let expected_len = (NUM_VALUES + num_values_per_payload - 1) / num_values_per_payload;
let msgs = vec![value; NUM_VALUES as usize];
let split: Vec<_> =
ClusterInfo::split_gossip_messages(PUSH_MESSAGE_MAX_PAYLOAD_SIZE, msgs).collect();
assert!(split.len() as u64 <= expected_len);
assert!(
ClusterInfo::split_gossip_messages(PUSH_MESSAGE_MAX_PAYLOAD_SIZE, msgs).count() as u64
<= expected_len
);
}
#[test]

View File

@ -91,6 +91,8 @@ pub type Stake = u64;
pub type VotedStakes = HashMap<Slot, Stake>;
pub type PubkeyVotes = Vec<(Pubkey, Slot)>;
// lint warning "bank_weight is never read"
#[allow(dead_code)]
pub(crate) struct ComputedBankState {
pub voted_stakes: VotedStakes,
pub total_stake: Stake,

View File

@ -1476,11 +1476,13 @@ mod test {
}
}
fn run_test_mask(mask_bits: u32) {
let masks: Vec<_> = (0..2u64.pow(mask_bits))
.map(|seed| CrdsFilter::compute_mask(seed, mask_bits))
.dedup()
.collect();
assert_eq!(masks.len(), 2u64.pow(mask_bits) as usize)
assert_eq!(
(0..2u64.pow(mask_bits))
.map(|seed| CrdsFilter::compute_mask(seed, mask_bits))
.dedup()
.count(),
2u64.pow(mask_bits) as usize
)
}
#[test]

View File

@ -382,7 +382,7 @@ mod tests {
assert_eq!(slots.to_slots(1), vec![1, 2, 10]);
assert_eq!(slots.to_slots(2), vec![2, 10]);
assert_eq!(slots.to_slots(3), vec![10]);
assert_eq!(slots.to_slots(11).is_empty(), true);
assert!(slots.to_slots(11).is_empty());
}
#[test]
fn test_epoch_slots_compressed() {
@ -452,7 +452,7 @@ mod tests {
assert_eq!(slots.wallclock, 1);
assert_eq!(slots.to_slots(0), range);
assert_eq!(slots.to_slots(4999), vec![4999]);
assert_eq!(slots.to_slots(5000).is_empty(), true);
assert!(slots.to_slots(5000).is_empty());
}
#[test]
fn test_epoch_slots_fill_sparce_range() {

View File

@ -342,19 +342,19 @@ mod tests {
let spy_ref = Arc::new(cluster_info);
let (met_criteria, secs, _, tvu_peers) = spy(spy_ref.clone(), None, Some(1), None, None);
assert_eq!(met_criteria, false);
assert!(!met_criteria);
assert_eq!(secs, 1);
assert_eq!(tvu_peers, spy_ref.tvu_peers());
// Find num_nodes
let (met_criteria, _, _, _) = spy(spy_ref.clone(), Some(1), None, None, None);
assert_eq!(met_criteria, true);
assert!(met_criteria);
let (met_criteria, _, _, _) = spy(spy_ref.clone(), Some(2), None, None, None);
assert_eq!(met_criteria, true);
assert!(met_criteria);
// Find specific node by pubkey
let (met_criteria, _, _, _) = spy(spy_ref.clone(), None, None, Some(peer0), None);
assert_eq!(met_criteria, true);
assert!(met_criteria);
let (met_criteria, _, _, _) = spy(
spy_ref.clone(),
None,
@ -362,13 +362,13 @@ mod tests {
Some(solana_sdk::pubkey::new_rand()),
None,
);
assert_eq!(met_criteria, false);
assert!(!met_criteria);
// Find num_nodes *and* specific node by pubkey
let (met_criteria, _, _, _) = spy(spy_ref.clone(), Some(1), None, Some(peer0), None);
assert_eq!(met_criteria, true);
assert!(met_criteria);
let (met_criteria, _, _, _) = spy(spy_ref.clone(), Some(3), Some(0), Some(peer0), None);
assert_eq!(met_criteria, false);
assert!(!met_criteria);
let (met_criteria, _, _, _) = spy(
spy_ref.clone(),
Some(1),
@ -376,12 +376,12 @@ mod tests {
Some(solana_sdk::pubkey::new_rand()),
None,
);
assert_eq!(met_criteria, false);
assert!(!met_criteria);
// Find specific node by gossip address
let (met_criteria, _, _, _) =
spy(spy_ref.clone(), None, None, None, Some(&peer0_info.gossip));
assert_eq!(met_criteria, true);
assert!(met_criteria);
let (met_criteria, _, _, _) = spy(
spy_ref,
@ -390,6 +390,6 @@ mod tests {
None,
Some(&"1.1.1.1:1234".parse().unwrap()),
);
assert_eq!(met_criteria, false);
assert!(!met_criteria);
}
}

View File

@ -2685,7 +2685,7 @@ mod test {
let mut tower = Tower::new_for_tests(10, 0.9);
tower.record_vote(1, Hash::default());
assert_eq!(tower.is_stray_last_vote(), false);
assert!(!tower.is_stray_last_vote());
assert_eq!(
heaviest_subtree_fork_choice.heaviest_slot_on_same_voted_fork(&tower),
Some((2, Hash::default()))
@ -2700,7 +2700,7 @@ mod test {
.adjust_lockouts_after_replay(0, &slot_history)
.unwrap();
assert_eq!(tower.is_stray_last_vote(), true);
assert!(tower.is_stray_last_vote());
assert_eq!(
heaviest_subtree_fork_choice.heaviest_slot_on_same_voted_fork(&tower),
Some((2, Hash::default()))
@ -2712,7 +2712,7 @@ mod test {
.adjust_lockouts_after_replay(0, &slot_history)
.unwrap();
assert_eq!(tower.is_stray_last_vote(), true);
assert!(tower.is_stray_last_vote());
assert_eq!(
heaviest_subtree_fork_choice.heaviest_slot_on_same_voted_fork(&tower),
None

View File

@ -1,4 +1,4 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))]
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
//! The `solana` library implements the Solana high-performance blockchain architecture.
//! It includes a full Rust implementation of the architecture (see

View File

@ -1413,7 +1413,7 @@ mod tests {
let bootstrap_validator_id = leader_schedule_cache.slot_leader_at(0, None).unwrap();
assert_eq!(poh_recorder.reached_leader_tick(0), true);
assert!(poh_recorder.reached_leader_tick(0));
let grace_ticks = bank.ticks_per_slot() * MAX_GRACE_SLOTS;
let new_tick_height = NUM_CONSECUTIVE_LEADER_SLOTS * bank.ticks_per_slot();
@ -1475,11 +1475,11 @@ mod tests {
);
// Test that with no next leader slot, we don't reach the leader slot
assert_eq!(poh_recorder.reached_leader_slot().0, false);
assert!(!poh_recorder.reached_leader_slot().0);
// Test that with no next leader slot in reset(), we don't reach the leader slot
poh_recorder.reset(bank.last_blockhash(), 0, None);
assert_eq!(poh_recorder.reached_leader_slot().0, false);
assert!(!poh_recorder.reached_leader_slot().0);
// Provide a leader slot one slot down
poh_recorder.reset(bank.last_blockhash(), 0, Some((2, 2)));
@ -1507,13 +1507,13 @@ mod tests {
.unwrap();
// Test that we don't reach the leader slot because of grace ticks
assert_eq!(poh_recorder.reached_leader_slot().0, false);
assert!(!poh_recorder.reached_leader_slot().0);
// reset poh now. we should immediately be leader
poh_recorder.reset(bank.last_blockhash(), 1, Some((2, 2)));
let (reached_leader_slot, grace_ticks, leader_slot, ..) =
poh_recorder.reached_leader_slot();
assert_eq!(reached_leader_slot, true);
assert!(reached_leader_slot);
assert_eq!(grace_ticks, 0);
assert_eq!(leader_slot, 2);
@ -1527,7 +1527,7 @@ mod tests {
}
// We are not the leader yet, as expected
assert_eq!(poh_recorder.reached_leader_slot().0, false);
assert!(!poh_recorder.reached_leader_slot().0);
// Send the grace ticks
for _ in 0..bank.ticks_per_slot() / GRACE_TICKS_FACTOR {
@ -1537,7 +1537,7 @@ mod tests {
// We should be the leader now
let (reached_leader_slot, grace_ticks, leader_slot, ..) =
poh_recorder.reached_leader_slot();
assert_eq!(reached_leader_slot, true);
assert!(reached_leader_slot);
assert_eq!(grace_ticks, bank.ticks_per_slot() / GRACE_TICKS_FACTOR);
assert_eq!(leader_slot, 3);
@ -1551,13 +1551,13 @@ mod tests {
}
// We are not the leader yet, as expected
assert_eq!(poh_recorder.reached_leader_slot().0, false);
assert!(!poh_recorder.reached_leader_slot().0);
poh_recorder.reset(bank.last_blockhash(), 3, Some((4, 4)));
// without sending more ticks, we should be leader now
let (reached_leader_slot, grace_ticks, leader_slot, ..) =
poh_recorder.reached_leader_slot();
assert_eq!(reached_leader_slot, true);
assert!(reached_leader_slot);
assert_eq!(grace_ticks, 0);
assert_eq!(leader_slot, 4);
@ -1575,7 +1575,7 @@ mod tests {
// We are overdue to lead
let (reached_leader_slot, grace_ticks, leader_slot, ..) =
poh_recorder.reached_leader_slot();
assert_eq!(reached_leader_slot, true);
assert!(reached_leader_slot);
assert_eq!(grace_ticks, overshoot_factor * bank.ticks_per_slot());
assert_eq!(leader_slot, 9);
}
@ -1605,47 +1605,29 @@ mod tests {
);
// Test that with no leader slot, we don't reach the leader tick
assert_eq!(
poh_recorder.would_be_leader(2 * bank.ticks_per_slot()),
false
);
assert!(!poh_recorder.would_be_leader(2 * bank.ticks_per_slot()));
poh_recorder.reset(bank.last_blockhash(), 0, None);
assert_eq!(
poh_recorder.would_be_leader(2 * bank.ticks_per_slot()),
false
);
assert!(!poh_recorder.would_be_leader(2 * bank.ticks_per_slot()));
// We reset with leader slot after 3 slots
let bank_slot = bank.slot() + 3;
poh_recorder.reset(bank.last_blockhash(), 0, Some((bank_slot, bank_slot)));
// Test that the node won't be leader in next 2 slots
assert_eq!(
poh_recorder.would_be_leader(2 * bank.ticks_per_slot()),
false
);
assert!(!poh_recorder.would_be_leader(2 * bank.ticks_per_slot()));
// Test that the node will be leader in next 3 slots
assert_eq!(
poh_recorder.would_be_leader(3 * bank.ticks_per_slot()),
true
);
assert!(poh_recorder.would_be_leader(3 * bank.ticks_per_slot()));
assert_eq!(
poh_recorder.would_be_leader(2 * bank.ticks_per_slot()),
false
);
assert!(!poh_recorder.would_be_leader(2 * bank.ticks_per_slot()));
// Move the bank up a slot (so that max_tick_height > slot 0's tick_height)
let bank = Arc::new(Bank::new_from_parent(&bank, &Pubkey::default(), 1));
// If we set the working bank, the node should be leader within next 2 slots
poh_recorder.set_bank(&bank);
assert_eq!(
poh_recorder.would_be_leader(2 * bank.ticks_per_slot()),
true
);
assert!(poh_recorder.would_be_leader(2 * bank.ticks_per_slot()));
}
}

View File

@ -739,7 +739,7 @@ mod tests {
let mut packets = Packets::new(vec![]);
solana_streamer::packet::recv_from(&mut packets, &me_retransmit, 1).unwrap();
assert_eq!(packets.packets.len(), 1);
assert_eq!(packets.packets[0].meta.repair, false);
assert!(!packets.packets[0].meta.repair);
let mut repair = packet.clone();
repair.meta.repair = true;
@ -752,7 +752,7 @@ mod tests {
let mut packets = Packets::new(vec![]);
solana_streamer::packet::recv_from(&mut packets, &me_retransmit, 1).unwrap();
assert_eq!(packets.packets.len(), 1);
assert_eq!(packets.packets[0].meta.repair, false);
assert!(!packets.packets[0].meta.repair);
}
#[test]

View File

@ -153,7 +153,7 @@ pub mod tests {
batch[0].packets[1].meta.size = shred.payload.len();
let rv = verifier.verify_batch(batch);
assert_eq!(rv[0].packets[0].meta.discard, false);
assert_eq!(rv[0].packets[1].meta.discard, true);
assert!(!rv[0].packets[0].meta.discard);
assert!(rv[0].packets[1].meta.discard);
}
}

View File

@ -105,7 +105,7 @@ mod tests {
// Only the nonempty packet had a timestamp greater than 1
let (new_update_version, updates) = verified_vote_packets.get_latest_votes(1);
assert_eq!(new_update_version, 2);
assert_eq!(updates.packets.is_empty(), false);
assert!(!updates.packets.is_empty());
// If the given timestamp is greater than all timestamps in any update,
// returned timestamp should be the same as the given timestamp, and

View File

@ -671,63 +671,94 @@ mod test {
let mut shreds = local_entries_to_shred(&[Entry::default()], 0, 0, &leader_keypair);
// with a Bank for slot 0, shred continues
assert_eq!(
should_retransmit_and_persist(&shreds[0], Some(bank.clone()), &cache, &me_id, 0, 0),
true
);
assert!(should_retransmit_and_persist(
&shreds[0],
Some(bank.clone()),
&cache,
&me_id,
0,
0
));
// with the wrong shred_version, shred gets thrown out
assert_eq!(
should_retransmit_and_persist(&shreds[0], Some(bank.clone()), &cache, &me_id, 0, 1),
false
);
assert!(!should_retransmit_and_persist(
&shreds[0],
Some(bank.clone()),
&cache,
&me_id,
0,
1
));
// If it's a coding shred, test that slot >= root
let (common, coding) = Shredder::new_coding_shred_header(5, 5, 5, 6, 6, 0);
let mut coding_shred =
Shred::new_empty_from_header(common, DataShredHeader::default(), coding);
Shredder::sign_shred(&leader_keypair, &mut coding_shred);
assert_eq!(
should_retransmit_and_persist(&coding_shred, Some(bank.clone()), &cache, &me_id, 0, 0),
true
);
assert_eq!(
should_retransmit_and_persist(&coding_shred, Some(bank.clone()), &cache, &me_id, 5, 0),
true
);
assert_eq!(
should_retransmit_and_persist(&coding_shred, Some(bank.clone()), &cache, &me_id, 6, 0),
false
);
assert!(should_retransmit_and_persist(
&coding_shred,
Some(bank.clone()),
&cache,
&me_id,
0,
0
));
assert!(should_retransmit_and_persist(
&coding_shred,
Some(bank.clone()),
&cache,
&me_id,
5,
0
));
assert!(!should_retransmit_and_persist(
&coding_shred,
Some(bank.clone()),
&cache,
&me_id,
6,
0
));
// with a Bank and no idea who leader is, shred gets thrown out
shreds[0].set_slot(MINIMUM_SLOTS_PER_EPOCH as u64 * 3);
assert_eq!(
should_retransmit_and_persist(&shreds[0], Some(bank.clone()), &cache, &me_id, 0, 0),
false
);
assert!(!should_retransmit_and_persist(
&shreds[0],
Some(bank.clone()),
&cache,
&me_id,
0,
0
));
// with a shred where shred.slot() == root, shred gets thrown out
let slot = MINIMUM_SLOTS_PER_EPOCH as u64 * 3;
let shreds = local_entries_to_shred(&[Entry::default()], slot, slot - 1, &leader_keypair);
assert_eq!(
should_retransmit_and_persist(&shreds[0], Some(bank.clone()), &cache, &me_id, slot, 0),
false
);
assert!(!should_retransmit_and_persist(
&shreds[0],
Some(bank.clone()),
&cache,
&me_id,
slot,
0
));
// with a shred where shred.parent() < root, shred gets thrown out
let slot = MINIMUM_SLOTS_PER_EPOCH as u64 * 3;
let shreds =
local_entries_to_shred(&[Entry::default()], slot + 1, slot - 1, &leader_keypair);
assert_eq!(
should_retransmit_and_persist(&shreds[0], Some(bank), &cache, &me_id, slot, 0),
false
);
assert!(!should_retransmit_and_persist(
&shreds[0],
Some(bank),
&cache,
&me_id,
slot,
0
));
// if the shred came back from me, it doesn't continue, whether or not I have a bank
assert_eq!(
should_retransmit_and_persist(&shreds[0], None, &cache, &me_id, 0, 0),
false
);
assert!(!should_retransmit_and_persist(
&shreds[0], None, &cache, &me_id, 0, 0
));
}
#[test]

View File

@ -100,7 +100,7 @@ fn test_rpc_send_tx() {
sleep(Duration::from_millis(500));
}
assert_eq!(confirmed_tx, true);
assert!(confirmed_tx);
use solana_account_decoder::UiAccountEncoding;
use solana_client::rpc_config::RpcAccountInfoConfig;

View File

@ -16,7 +16,6 @@ proc-macro = true
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "1.0", features = ["full", "extra-traits"] }
lazy_static = "1.4.0"
[build-dependencies]
rustc_version = "0.2"

View File

@ -1,9 +1,5 @@
extern crate proc_macro;
#[cfg(RUSTC_WITH_SPECIALIZATION)]
#[macro_use]
extern crate lazy_static;
// This file littered with these essential cfgs so ensure them.
#[cfg(not(any(RUSTC_WITH_SPECIALIZATION, RUSTC_WITHOUT_SPECIALIZATION)))]
compile_error!("rustc_version is missing in build dependency and build.rs is not specified");
@ -71,37 +67,6 @@ fn filter_allow_attrs(attrs: &mut Vec<Attribute>) {
});
}
#[allow(deprecated)]
#[cfg(RUSTC_WITH_SPECIALIZATION)]
fn quote_for_specialization_detection() -> TokenStream2 {
lazy_static! {
static ref SPECIALIZATION_DETECTOR_INJECTED: std::sync::atomic::AtomicBool =
std::sync::atomic::AtomicBool::new(false);
}
if !SPECIALIZATION_DETECTOR_INJECTED.compare_and_swap(
false,
true,
std::sync::atomic::Ordering::AcqRel,
) {
quote! {
mod specialization_detector {
trait SpecializedTrait {
fn specialized_fn() {}
}
impl<T: Sized> SpecializedTrait for T {
default fn specialized_fn() {}
}
impl<T: Sized + Default> SpecializedTrait for T {
fn specialized_fn() {}
}
}
}
} else {
quote! {}
}
}
#[cfg(RUSTC_WITH_SPECIALIZATION)]
fn derive_abi_sample_enum_type(input: ItemEnum) -> TokenStream {
let type_name = &input.ident;
@ -162,10 +127,8 @@ fn derive_abi_sample_enum_type(input: ItemEnum) -> TokenStream {
let mut attrs = input.attrs.clone();
filter_allow_attrs(&mut attrs);
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
let injection = quote_for_specialization_detection();
let result = quote! {
#injection
#[automatically_derived]
#( #attrs )*
impl #impl_generics ::solana_frozen_abi::abi_example::AbiExample for #type_name #ty_generics #where_clause {
@ -216,10 +179,8 @@ fn derive_abi_sample_struct_type(input: ItemStruct) -> TokenStream {
filter_allow_attrs(&mut attrs);
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
let turbofish = ty_generics.as_turbofish();
let injection = quote_for_specialization_detection();
let result = quote! {
#injection
#[automatically_derived]
#( #attrs )*
impl #impl_generics ::solana_frozen_abi::abi_example::AbiExample for #type_name #ty_generics #where_clause {

View File

@ -1200,7 +1200,8 @@ impl Blockstore {
just_inserted_data_shreds.insert((slot, shred_index), shred);
index_meta_working_set_entry.did_insert_occur = true;
slot_meta_entry.did_insert_occur = true;
if !erasure_metas.contains_key(&(slot, set_index)) {
if let std::collections::hash_map::Entry::Vacant(_) = erasure_metas.entry((slot, set_index))
{
if let Some(meta) = self
.erasure_meta_cf
.get((slot, set_index))
@ -5381,17 +5382,14 @@ pub mod tests {
panic!("Shred in unexpected format")
}
};
assert_eq!(
blockstore.should_insert_data_shred(
&shred7,
&slot_meta,
&HashMap::new(),
&last_root,
None,
false
),
assert!(!blockstore.should_insert_data_shred(
&shred7,
&slot_meta,
&HashMap::new(),
&last_root,
None,
false
);
));
assert!(blockstore.has_duplicate_shreds_in_slot(0));
// Insert all pending shreds
@ -5405,17 +5403,14 @@ pub mod tests {
} else {
panic!("Shred in unexpected format")
}
assert_eq!(
blockstore.should_insert_data_shred(
&shred7,
&slot_meta,
&HashMap::new(),
&last_root,
None,
false
),
assert!(!blockstore.should_insert_data_shred(
&shred7,
&slot_meta,
&HashMap::new(),
&last_root,
None,
false
);
));
}
Blockstore::destroy(&blockstore_path).expect("Expected successful database destruction");
}

View File

@ -115,7 +115,7 @@ impl Blockstore {
.batch()
.expect("Database Error: Failed to get write batch");
// delete range cf is not inclusive
let to_slot = to_slot.checked_add(1).unwrap_or(std::u64::MAX);
let to_slot = to_slot.saturating_add(1);
let mut delete_range_timer = Measure::start("delete_range");
let mut columns_purged = self

View File

@ -868,17 +868,14 @@ mod tests {
solana_logger::setup();
let zero = Hash::default();
let one = hash(&zero.as_ref());
assert_eq!(vec![][..].verify(&zero), true); // base case
assert_eq!(vec![Entry::new_tick(0, &zero)][..].verify(&zero), true); // singleton case 1
assert_eq!(vec![Entry::new_tick(0, &zero)][..].verify(&one), false); // singleton case 2, bad
assert_eq!(
vec![next_entry(&zero, 0, vec![]); 2][..].verify(&zero),
true
); // inductive step
assert!(vec![][..].verify(&zero)); // base case
assert!(vec![Entry::new_tick(0, &zero)][..].verify(&zero)); // singleton case 1
assert!(!vec![Entry::new_tick(0, &zero)][..].verify(&one)); // singleton case 2, bad
assert!(vec![next_entry(&zero, 0, vec![]); 2][..].verify(&zero)); // inductive step
let mut bad_ticks = vec![next_entry(&zero, 0, vec![]); 2];
bad_ticks[1].hash = one;
assert_eq!(bad_ticks.verify(&zero), false); // inductive step, bad
assert!(!bad_ticks.verify(&zero)); // inductive step, bad
}
#[test]
@ -887,18 +884,18 @@ mod tests {
let zero = Hash::default();
let one = hash(&zero.as_ref());
let two = hash(&one.as_ref());
assert_eq!(vec![][..].verify(&one), true); // base case
assert_eq!(vec![Entry::new_tick(1, &two)][..].verify(&one), true); // singleton case 1
assert_eq!(vec![Entry::new_tick(1, &two)][..].verify(&two), false); // singleton case 2, bad
assert!(vec![][..].verify(&one)); // base case
assert!(vec![Entry::new_tick(1, &two)][..].verify(&one)); // singleton case 1
assert!(!vec![Entry::new_tick(1, &two)][..].verify(&two)); // singleton case 2, bad
let mut ticks = vec![next_entry(&one, 1, vec![])];
ticks.push(next_entry(&ticks.last().unwrap().hash, 1, vec![]));
assert_eq!(ticks.verify(&one), true); // inductive step
assert!(ticks.verify(&one)); // inductive step
let mut bad_ticks = vec![next_entry(&one, 1, vec![])];
bad_ticks.push(next_entry(&bad_ticks.last().unwrap().hash, 1, vec![]));
bad_ticks[1].hash = one;
assert_eq!(bad_ticks.verify(&one), false); // inductive step, bad
assert!(!bad_ticks.verify(&one)); // inductive step, bad
}
#[test]
@ -910,15 +907,9 @@ mod tests {
let alice_pubkey = Keypair::new();
let tx0 = create_sample_payment(&alice_pubkey, one);
let tx1 = create_sample_timestamp(&alice_pubkey, one);
assert_eq!(vec![][..].verify(&one), true); // base case
assert_eq!(
vec![next_entry(&one, 1, vec![tx0.clone()])][..].verify(&one),
true
); // singleton case 1
assert_eq!(
vec![next_entry(&one, 1, vec![tx0.clone()])][..].verify(&two),
false
); // singleton case 2, bad
assert!(vec![][..].verify(&one)); // base case
assert!(vec![next_entry(&one, 1, vec![tx0.clone()])][..].verify(&one)); // singleton case 1
assert!(!vec![next_entry(&one, 1, vec![tx0.clone()])][..].verify(&two)); // singleton case 2, bad
let mut ticks = vec![next_entry(&one, 1, vec![tx0.clone()])];
ticks.push(next_entry(
@ -926,12 +917,12 @@ mod tests {
1,
vec![tx1.clone()],
));
assert_eq!(ticks.verify(&one), true); // inductive step
assert!(ticks.verify(&one)); // inductive step
let mut bad_ticks = vec![next_entry(&one, 1, vec![tx0])];
bad_ticks.push(next_entry(&bad_ticks.last().unwrap().hash, 1, vec![tx1]));
bad_ticks[1].hash = one;
assert_eq!(bad_ticks.verify(&one), false); // inductive step, bad
assert!(!bad_ticks.verify(&one)); // inductive step, bad
}
#[test]

View File

@ -1,4 +1,4 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))]
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
#[macro_use]
extern crate solana_bpf_loader_program;

View File

@ -197,95 +197,77 @@ mod tests {
let one_with_zero = hashv(&[&zero.as_ref(), &zero.as_ref()]);
let mut poh = Poh::new(zero, None);
assert_eq!(
verify(
zero,
&[
(poh.tick().unwrap(), None),
(poh.record(zero).unwrap(), Some(zero)),
(poh.record(zero).unwrap(), Some(zero)),
(poh.tick().unwrap(), None),
],
),
true
);
assert!(verify(
zero,
&[
(poh.tick().unwrap(), None),
(poh.record(zero).unwrap(), Some(zero)),
(poh.record(zero).unwrap(), Some(zero)),
(poh.tick().unwrap(), None),
],
));
assert_eq!(
verify(
zero,
&[(
PohEntry {
num_hashes: 1,
hash: one,
},
None
)],
),
true
);
assert_eq!(
verify(
zero,
&[(
PohEntry {
num_hashes: 2,
hash: two,
},
None
)]
),
true
);
assert!(verify(
zero,
&[(
PohEntry {
num_hashes: 1,
hash: one,
},
None
)],
));
assert!(verify(
zero,
&[(
PohEntry {
num_hashes: 2,
hash: two,
},
None
)]
));
assert_eq!(
verify(
zero,
&[(
assert!(verify(
zero,
&[(
PohEntry {
num_hashes: 1,
hash: one_with_zero,
},
Some(zero)
)]
));
assert!(!verify(
zero,
&[(
PohEntry {
num_hashes: 1,
hash: zero,
},
None
)]
));
assert!(verify(
zero,
&[
(
PohEntry {
num_hashes: 1,
hash: one_with_zero,
},
Some(zero)
)]
),
true
);
assert_eq!(
verify(
zero,
&[(
),
(
PohEntry {
num_hashes: 1,
hash: zero,
hash: hash(&one_with_zero.as_ref()),
},
None
)]
),
false
);
assert_eq!(
verify(
zero,
&[
(
PohEntry {
num_hashes: 1,
hash: one_with_zero,
},
Some(zero)
),
(
PohEntry {
num_hashes: 1,
hash: hash(&one_with_zero.as_ref()),
},
None
)
]
),
true
);
)
]
));
}
#[test]

View File

@ -384,7 +384,7 @@ fn get_and_verify_slot_entries(
last_entry: &Hash,
) -> Vec<Entry> {
let entries = blockstore.get_slot_entries(slot, 0).unwrap();
assert_eq!(entries.verify(last_entry), true);
assert!(entries.verify(last_entry));
entries
}

View File

@ -315,7 +315,7 @@ mod tests {
assert_eq!(mem[0], 50);
assert_eq!(mem[1], 10);
assert_eq!(mem.len(), 2);
assert_eq!(mem.is_empty(), false);
assert!(!mem.is_empty());
let mut iter = mem.iter();
assert_eq!(*iter.next().unwrap(), 50);
assert_eq!(*iter.next().unwrap(), 10);

View File

@ -71,6 +71,7 @@ fn warm_recyclers() -> bool {
}
impl<T: Default + Reset + Sized> Recycler<T> {
#[allow(clippy::needless_collect)]
pub fn warmed(num: usize, size_hint: usize) -> Self {
let new = Self::default();
if warm_recyclers() {

View File

@ -495,9 +495,9 @@ mod tests {
batch.packets.push(Packet::default());
let mut batches: Vec<Packets> = vec![batch];
mark_disabled(&mut batches, &[vec![0]]);
assert_eq!(batches[0].packets[0].meta.discard, true);
assert!(batches[0].packets[0].meta.discard);
mark_disabled(&mut batches, &[vec![1]]);
assert_eq!(batches[0].packets[0].meta.discard, false);
assert!(!batches[0].packets[0].meta.discard);
}
#[test]

View File

@ -3245,7 +3245,6 @@ dependencies = [
name = "solana-frozen-abi-macro"
version = "1.7.0"
dependencies = [
"lazy_static",
"proc-macro2 1.0.24",
"quote 1.0.6",
"rustc_version",

View File

@ -2810,6 +2810,8 @@ mod tests {
let bytes1 = "Gaggablaghblagh!";
let bytes2 = "flurbos";
// lint warns field addr and len "never read"
#[allow(dead_code)]
struct MockSlice {
pub addr: u64,
pub len: usize,

View File

@ -1,4 +1,4 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))]
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
use solana_sdk::genesis_config::GenesisConfig;

View File

@ -1881,22 +1881,16 @@ mod tests {
#[test]
fn test_stake_is_bootstrap() {
assert_eq!(
Delegation {
activation_epoch: std::u64::MAX,
..Delegation::default()
}
.is_bootstrap(),
true
);
assert_eq!(
Delegation {
activation_epoch: 0,
..Delegation::default()
}
.is_bootstrap(),
false
);
assert!(Delegation {
activation_epoch: std::u64::MAX,
..Delegation::default()
}
.is_bootstrap());
assert!(!Delegation {
activation_epoch: 0,
..Delegation::default()
}
.is_bootstrap());
}
#[test]
@ -5719,65 +5713,50 @@ mod tests {
custodian,
};
// neither time
assert_eq!(
lockup.is_in_force(
&Clock {
epoch: 0,
unix_timestamp: 0,
..Clock::default()
},
None
),
true
);
assert!(lockup.is_in_force(
&Clock {
epoch: 0,
unix_timestamp: 0,
..Clock::default()
},
None
));
// not timestamp
assert_eq!(
lockup.is_in_force(
&Clock {
epoch: 2,
unix_timestamp: 0,
..Clock::default()
},
None
),
true
);
assert!(lockup.is_in_force(
&Clock {
epoch: 2,
unix_timestamp: 0,
..Clock::default()
},
None
));
// not epoch
assert_eq!(
lockup.is_in_force(
&Clock {
epoch: 0,
unix_timestamp: 2,
..Clock::default()
},
None
),
true
);
assert!(lockup.is_in_force(
&Clock {
epoch: 0,
unix_timestamp: 2,
..Clock::default()
},
None
));
// both, no custodian
assert_eq!(
lockup.is_in_force(
&Clock {
epoch: 1,
unix_timestamp: 1,
..Clock::default()
},
None
),
false
);
assert!(!lockup.is_in_force(
&Clock {
epoch: 1,
unix_timestamp: 1,
..Clock::default()
},
None
));
// neither, but custodian
assert_eq!(
lockup.is_in_force(
&Clock {
epoch: 0,
unix_timestamp: 0,
..Clock::default()
},
Some(&custodian),
),
false,
);
assert!(!lockup.is_in_force(
&Clock {
epoch: 0,
unix_timestamp: 0,
..Clock::default()
},
Some(&custodian),
));
}
#[test]

View File

@ -1,4 +1,4 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))]
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
pub mod authorized_voters;

View File

@ -260,7 +260,7 @@ mod tests {
);
assert_eq!(optimistically_confirmed_bank.read().unwrap().bank.slot(), 2);
assert_eq!(pending_optimistically_confirmed_banks.len(), 1);
assert_eq!(pending_optimistically_confirmed_banks.contains(&3), true);
assert!(pending_optimistically_confirmed_banks.contains(&3));
// Test bank will only be cached when frozen
let bank3 = bank_forks.read().unwrap().get(3).unwrap().clone();
@ -286,7 +286,7 @@ mod tests {
);
assert_eq!(optimistically_confirmed_bank.read().unwrap().bank.slot(), 3);
assert_eq!(pending_optimistically_confirmed_banks.len(), 1);
assert_eq!(pending_optimistically_confirmed_banks.contains(&4), true);
assert!(pending_optimistically_confirmed_banks.contains(&4));
let bank4 = bank_forks.read().unwrap().get(4).unwrap().clone();
let bank5 = Bank::new_from_parent(&bank4, &Pubkey::default(), 5);
@ -301,7 +301,7 @@ mod tests {
);
assert_eq!(optimistically_confirmed_bank.read().unwrap().bank.slot(), 5);
assert_eq!(pending_optimistically_confirmed_banks.len(), 0);
assert_eq!(pending_optimistically_confirmed_banks.contains(&4), false);
assert!(!pending_optimistically_confirmed_banks.contains(&4));
// Banks <= root do not get added to pending list, even if not frozen
let bank5 = bank_forks.read().unwrap().get(5).unwrap().clone();
@ -323,6 +323,6 @@ mod tests {
);
assert_eq!(optimistically_confirmed_bank.read().unwrap().bank.slot(), 5);
assert_eq!(pending_optimistically_confirmed_banks.len(), 0);
assert_eq!(pending_optimistically_confirmed_banks.contains(&6), false);
assert!(!pending_optimistically_confirmed_banks.contains(&6));
}
}

View File

@ -1968,18 +1968,18 @@ pub(crate) mod tests {
assert_eq!(subscriptions.get(&0).unwrap().len(), 2);
assert_eq!(subscriptions.get(&1).unwrap().len(), 1);
assert_eq!(
remove_subscription(&mut subscriptions, &SubscriptionId::Number(0)),
true
);
assert!(remove_subscription(
&mut subscriptions,
&SubscriptionId::Number(0)
));
assert_eq!(subscriptions.len(), num_keys as usize);
assert_eq!(subscriptions.get(&0).unwrap().len(), 1);
assert_eq!(
remove_subscription(&mut subscriptions, &SubscriptionId::Number(0)),
false
);
assert!(!remove_subscription(
&mut subscriptions,
&SubscriptionId::Number(0)
));
assert_eq!(remove_subscription(&mut subscriptions, &extra_sub_id), true);
assert!(remove_subscription(&mut subscriptions, &extra_sub_id));
assert_eq!(subscriptions.len(), (num_keys - 1) as usize);
assert!(subscriptions.get(&0).is_none());
}

View File

@ -833,6 +833,7 @@ impl Accounts {
/// This function will prevent multiple threads from modifying the same account state at the
/// same time
#[must_use]
#[allow(clippy::needless_collect)]
pub fn lock_accounts<'a>(
&self,
txs: impl Iterator<Item = &'a Transaction>,

View File

@ -3203,6 +3203,7 @@ impl AccountsDb {
}
}
#[allow(clippy::needless_collect)]
fn purge_slots(&self, slots: &HashSet<Slot>) {
// `add_root()` should be called first
let mut safety_checks_elapsed = Measure::start("safety_checks_elapsed");
@ -6502,7 +6503,7 @@ pub mod tests {
let mut pubkeys: Vec<Pubkey> = vec![];
create_account(&accounts, &mut pubkeys, 0, 100, 0, 0);
update_accounts(&accounts, &pubkeys, 0, 99);
assert_eq!(check_storage(&accounts, 0, 100), true);
assert!(check_storage(&accounts, 0, 100));
}
#[test]
@ -7100,7 +7101,7 @@ pub mod tests {
// do some updates to those accounts and re-check
modify_accounts(&accounts, &pubkeys, 0, 100, 2);
assert_eq!(check_storage(&accounts, 0, 100), true);
assert!(check_storage(&accounts, 0, 100));
check_accounts(&accounts, &pubkeys, 0, 100, 2);
accounts.get_accounts_delta_hash(0);
accounts.add_root(0);

View File

@ -883,7 +883,7 @@ pub mod tests {
let executable_bool: &bool = &account.account_meta.executable;
// Depending on use, *executable_bool can be truthy or falsy due to direct memory manipulation
// assert_eq! thinks *executable_bool is equal to false but the if condition thinks it's not, contradictorily.
assert_eq!(*executable_bool, false);
assert!(!*executable_bool);
const FALSE: bool = false; // keep clippy happy
if *executable_bool == FALSE {
panic!("This didn't occur if this test passed.");
@ -894,7 +894,7 @@ pub mod tests {
// we can NOT observe crafted value by value
{
let executable_bool: bool = account.account_meta.executable;
assert_eq!(executable_bool, false);
assert!(!executable_bool);
assert_eq!(account.get_executable_byte(), 0); // Wow, not crafted_executable!
}

View File

@ -8777,15 +8777,15 @@ pub(crate) mod tests {
let tx_transfer_mint_to_1 =
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_config.hash());
assert_eq!(bank.process_transaction(&tx_transfer_mint_to_1), Ok(()));
assert_eq!(bank.is_delta.load(Relaxed), true);
assert!(bank.is_delta.load(Relaxed));
let bank1 = new_from_parent(&bank);
let hash1 = bank1.hash_internal_state();
assert_eq!(bank1.is_delta.load(Relaxed), false);
assert!(!bank1.is_delta.load(Relaxed));
assert_ne!(hash1, bank.hash());
// ticks don't make a bank into a delta or change its state unless a block boundary is crossed
bank1.register_tick(&Hash::default());
assert_eq!(bank1.is_delta.load(Relaxed), false);
assert!(!bank1.is_delta.load(Relaxed));
assert_eq!(bank1.hash_internal_state(), hash1);
}
@ -8796,13 +8796,13 @@ pub(crate) mod tests {
let key1 = Keypair::new();
// The zeroth bank is empty becasue there are no transactions
assert_eq!(bank0.is_empty(), true);
assert!(bank0.is_empty());
// Set is_delta to true, bank is no longer empty
let tx_transfer_mint_to_1 =
system_transaction::transfer(&mint_keypair, &key1.pubkey(), 1, genesis_config.hash());
assert_eq!(bank0.process_transaction(&tx_transfer_mint_to_1), Ok(()));
assert_eq!(bank0.is_empty(), false);
assert!(!bank0.is_empty());
}
#[test]

View File

@ -1,4 +1,4 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))]
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
pub mod accounts;
pub mod accounts_background_service;

View File

@ -1389,22 +1389,22 @@ mod tests {
fn test_is_zeroed() {
const ZEROS_LEN: usize = 1024;
let mut buf = [0; ZEROS_LEN];
assert_eq!(PreAccount::is_zeroed(&buf), true);
assert!(PreAccount::is_zeroed(&buf));
buf[0] = 1;
assert_eq!(PreAccount::is_zeroed(&buf), false);
assert!(!PreAccount::is_zeroed(&buf));
let mut buf = [0; ZEROS_LEN - 1];
assert_eq!(PreAccount::is_zeroed(&buf), true);
assert!(PreAccount::is_zeroed(&buf));
buf[0] = 1;
assert_eq!(PreAccount::is_zeroed(&buf), false);
assert!(!PreAccount::is_zeroed(&buf));
let mut buf = [0; ZEROS_LEN + 1];
assert_eq!(PreAccount::is_zeroed(&buf), true);
assert!(PreAccount::is_zeroed(&buf));
buf[0] = 1;
assert_eq!(PreAccount::is_zeroed(&buf), false);
assert!(!PreAccount::is_zeroed(&buf));
let buf = vec![];
assert_eq!(PreAccount::is_zeroed(&buf), true);
assert!(PreAccount::is_zeroed(&buf));
}
#[test]

View File

@ -101,4 +101,4 @@ EOF
_ example_helloworld
_ spl
_ serum_dex
# _ serum_dex

View File

@ -10,7 +10,7 @@ if ! command -v grcov; then
exit 1
fi
if [[ ! "$(grcov --version)" =~ 0.[67].1 ]]; then
if [[ ! "$(grcov --version)" =~ 0.[678].[01] ]]; then
echo Error: Required grcov version not installed
echo "Installed version: $(grcov --version)"

View File

@ -865,12 +865,12 @@ mod tests {
instructions: vec![],
};
let demote_sysvar_write_locks = true;
assert_eq!(message.is_writable(0, demote_sysvar_write_locks), true);
assert_eq!(message.is_writable(1, demote_sysvar_write_locks), false);
assert_eq!(message.is_writable(2, demote_sysvar_write_locks), false);
assert_eq!(message.is_writable(3, demote_sysvar_write_locks), true);
assert_eq!(message.is_writable(4, demote_sysvar_write_locks), true);
assert_eq!(message.is_writable(5, demote_sysvar_write_locks), false);
assert!(message.is_writable(0, demote_sysvar_write_locks));
assert!(!message.is_writable(1, demote_sysvar_write_locks));
assert!(!message.is_writable(2, demote_sysvar_write_locks));
assert!(message.is_writable(3, demote_sysvar_write_locks));
assert!(message.is_writable(4, demote_sysvar_write_locks));
assert!(!message.is_writable(5, demote_sysvar_write_locks));
}
#[test]

View File

@ -133,11 +133,10 @@ pub fn create_test_recent_blockhashes(start: usize) -> RecentBlockhashes {
)
})
.collect();
let bhq: Vec<_> = blocks
blocks
.iter()
.map(|(i, hash, fee_calc)| IterItem(*i, hash, fee_calc))
.collect();
bhq.into_iter().collect()
.collect()
}
#[cfg(test)]

View File

@ -700,8 +700,8 @@ pub mod tests {
assert_eq!(account.data().len(), 2);
assert_eq!(account.owner, key);
assert_eq!(account.owner(), &key);
assert_eq!(account.executable, true);
assert_eq!(account.executable(), true);
assert!(account.executable);
assert!(account.executable());
assert_eq!(account.rent_epoch, 4);
assert_eq!(account.rent_epoch(), 4);
let account = account2;
@ -711,8 +711,8 @@ pub mod tests {
assert_eq!(account.data().len(), 2);
assert_eq!(account.owner, key);
assert_eq!(account.owner(), &key);
assert_eq!(account.executable, true);
assert_eq!(account.executable(), true);
assert!(account.executable);
assert!(account.executable());
assert_eq!(account.rent_epoch, 4);
assert_eq!(account.rent_epoch(), 4);
}

View File

@ -72,6 +72,7 @@ impl fmt::Debug for Packet {
}
}
#[allow(clippy::uninit_assumed_init)]
impl Default for Packet {
fn default() -> Packet {
Packet {

View File

@ -423,6 +423,7 @@ fn distribute_allocations(
Ok(())
}
#[allow(clippy::needless_collect)]
fn read_allocations(
input_csv: &str,
transfer_amount: Option<u64>,

View File

@ -1,4 +1,4 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(specialization))]
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
extern crate serde_derive;
use serde_derive::{Deserialize, Serialize};