Skip to content

Commit f5dce22

Browse files
committed
refactor(tests): delete redundant tests, add missing coverage
1 parent faeb1bd commit f5dce22

File tree

116 files changed

+4772
-3749
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+4772
-3749
lines changed

Cargo.lock

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/actors/src/block_producer.rs

Lines changed: 20 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,79 +1694,35 @@ pub fn calculate_chunks_added(txs: &[DataTransactionHeader], chunk_size: u64) ->
16941694
mod oracle_choice_tests {
16951695
use super::choose_oracle_price;
16961696
use irys_types::{UnixTimestamp, storage_pricing::Amount};
1697+
use rstest::rstest;
16971698
use rust_decimal_macros::dec;
16981699

1699-
const MAX_AGE_SECS: u64 = 3 * 60; // 3 minutes
1700-
1701-
#[test]
1702-
fn chooses_parent_when_oracle_is_too_stale() {
1700+
const MAX_AGE_SECS: u64 = 3 * 60;
1701+
1702+
#[rstest]
1703+
#[case::stale_oracle(1000, 1000 - MAX_AGE_SECS - 1, true)]
1704+
#[case::at_tolerance_boundary(1000, 1000 - MAX_AGE_SECS, false)]
1705+
#[case::fresher_oracle(100, 200, false)]
1706+
#[case::equal_timestamps(500, 500, false)]
1707+
fn choose_oracle_price_scenarios(
1708+
#[case] parent_ts_secs: u64,
1709+
#[case] oracle_ts_secs: u64,
1710+
#[case] expect_parent: bool,
1711+
) {
17031712
let parent_price = Amount::token(dec!(2.0)).unwrap();
17041713
let oracle_price = Amount::token(dec!(1.0)).unwrap();
17051714

1706-
// Oracle is more than 3 minutes behind parent - use parent
17071715
let chosen = choose_oracle_price(
1708-
UnixTimestamp::from_secs(1000),
1716+
UnixTimestamp::from_secs(parent_ts_secs),
17091717
parent_price,
17101718
oracle_price,
1711-
UnixTimestamp::from_secs(1000 - MAX_AGE_SECS - 1), // 181 seconds behind
1712-
);
1713-
assert_eq!(
1714-
chosen, parent_price,
1715-
"should choose parent price when oracle is more than 3 minutes stale"
1719+
UnixTimestamp::from_secs(oracle_ts_secs),
17161720
);
1717-
}
17181721

1719-
#[test]
1720-
fn chooses_oracle_when_within_tolerance() {
1721-
let parent_price = Amount::token(dec!(2.0)).unwrap();
1722-
let oracle_price = Amount::token(dec!(1.0)).unwrap();
1723-
1724-
// Oracle is exactly at the 3-minute tolerance boundary - still use oracle
1725-
let chosen = choose_oracle_price(
1726-
UnixTimestamp::from_secs(1000),
1727-
parent_price,
1728-
oracle_price,
1729-
UnixTimestamp::from_secs(1000 - MAX_AGE_SECS), // exactly 180 seconds behind
1730-
);
1731-
assert_eq!(
1732-
chosen, oracle_price,
1733-
"should choose oracle price when exactly at 3-minute tolerance"
1734-
);
1735-
}
1736-
1737-
#[test]
1738-
fn chooses_oracle_when_oracle_is_fresher() {
1739-
let parent_price = Amount::token(dec!(2.0)).unwrap();
1740-
let oracle_price = Amount::token(dec!(1.0)).unwrap();
1741-
1742-
// Oracle is fresher than parent - definitely use oracle
1743-
let chosen = choose_oracle_price(
1744-
UnixTimestamp::from_secs(100),
1745-
parent_price,
1746-
oracle_price,
1747-
UnixTimestamp::from_secs(200),
1748-
);
1749-
assert_eq!(
1750-
chosen, oracle_price,
1751-
"should choose oracle price when oracle is fresher"
1752-
);
1753-
}
1754-
1755-
#[test]
1756-
fn chooses_oracle_when_timestamps_are_equal() {
1757-
let parent_price = Amount::token(dec!(2.0)).unwrap();
1758-
let oracle_price = Amount::token(dec!(1.0)).unwrap();
1759-
1760-
// Both at same second - prefer oracle (authoritative source)
1761-
let chosen = choose_oracle_price(
1762-
UnixTimestamp::from_secs(500),
1763-
parent_price,
1764-
oracle_price,
1765-
UnixTimestamp::from_secs(500),
1766-
);
1767-
assert_eq!(
1768-
chosen, oracle_price,
1769-
"should choose oracle price when timestamps are equal"
1770-
);
1722+
if expect_parent {
1723+
assert_eq!(chosen, parent_price);
1724+
} else {
1725+
assert_eq!(chosen, oracle_price);
1726+
}
17711727
}
17721728
}

crates/actors/src/cache_service.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,26 +1068,6 @@ mod tests {
10681068
Ok(())
10691069
}
10701070

1071-
// ========================================================================
1072-
// FIFO Ordering Property Tests
1073-
// ========================================================================
1074-
1075-
#[cfg(test)]
1076-
mod fifo_properties {
1077-
1078-
use irys_types::UnixTimestamp;
1079-
use proptest::prelude::*;
1080-
1081-
prop_compose! {
1082-
fn unix_timestamps()(
1083-
// Realistic range: 2020-01-01 to 2030-01-01
1084-
secs in 1_577_836_800_u64..1_893_456_000_u64
1085-
) -> UnixTimestamp {
1086-
UnixTimestamp::from_secs(secs)
1087-
}
1088-
}
1089-
}
1090-
10911071
// Chunks should remain when there is an active ingress proof present for the data_root.
10921072
#[tokio::test]
10931073
async fn does_not_prune_chunks_with_active_proof() -> eyre::Result<()> {

crates/actors/src/chunk_ingress_service/chunks.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -922,8 +922,6 @@ mod tests {
922922
}
923923

924924
proptest! {
925-
/// Property: publish ledger data_size is ALWAYS preferred over submit ledger,
926-
/// regardless of the relative sizes.
927925
#[test]
928926
fn publish_ledger_always_preferred_over_submit(
929927
publish_size in 1..u64::MAX,
@@ -939,7 +937,6 @@ mod tests {
939937
prop_assert!(selected.is_from_publish_ledger);
940938
}
941939

942-
/// Property: single ledger type always selects max size
943940
#[test]
944941
fn single_ledger_type_selects_max(
945942
sizes in prop::collection::vec(1..u64::MAX, 1..10),
@@ -961,7 +958,6 @@ mod tests {
961958
prop_assert_eq!(selected.is_from_publish_ledger, is_publish);
962959
}
963960

964-
/// Property: with mixed ledgers, publish ledger max is always selected
965961
#[test]
966962
fn mixed_ledgers_selects_publish_max(
967963
publish_sizes in prop::collection::vec(1..u64::MAX, 1..5),

crates/actors/src/packing_service/guard.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,6 @@ impl Drop for ActiveWorkerGuard {
3535
mod tests {
3636
use super::*;
3737

38-
#[test]
39-
fn test_guard_increments_on_create() {
40-
let counter = Arc::new(AtomicUsize::new(0));
41-
let notify = Arc::new(Notify::new());
42-
43-
{
44-
let _guard = ActiveWorkerGuard::new(counter.clone(), notify);
45-
assert_eq!(counter.load(Ordering::Relaxed), 1);
46-
}
47-
}
48-
4938
#[test]
5039
fn test_guard_decrements_on_drop() {
5140
let counter = Arc::new(AtomicUsize::new(0));

0 commit comments

Comments
 (0)