derive TransactionCost::{PartialEq, Eq} (#31626)

This commit is contained in:
Andrew Fitzgerald 2023-05-15 12:27:17 -07:00 committed by GitHub
parent 31aafc8ae6
commit e5effa38b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 0 deletions

View File

@ -55,6 +55,27 @@ impl Default for TransactionCost {
}
}
#[cfg(test)]
impl PartialEq for TransactionCost {
fn eq(&self, other: &Self) -> bool {
fn to_hash_set(v: &[Pubkey]) -> std::collections::HashSet<&Pubkey> {
v.iter().collect()
}
self.signature_cost == other.signature_cost
&& self.write_lock_cost == other.write_lock_cost
&& self.data_bytes_cost == other.data_bytes_cost
&& self.builtins_execution_cost == other.builtins_execution_cost
&& self.bpf_execution_cost == other.bpf_execution_cost
&& self.account_data_size == other.account_data_size
&& self.is_simple_vote == other.is_simple_vote
&& to_hash_set(&self.writable_accounts) == to_hash_set(&other.writable_accounts)
}
}
#[cfg(test)]
impl Eq for TransactionCost {}
impl TransactionCost {
pub fn new_with_capacity(capacity: usize) -> Self {
Self {