| 774 | |
| 775 | #[test] |
| 776 | fn test_realistic_clone_scenario() { |
| 777 | // Scenario: Fresh clone — client has nothing. |
| 778 | let entries: Vec<ChunkManifestEntry> = (0..50) |
| 779 | .map(|i| { |
| 780 | let mut hash = [0u8; 32]; |
| 781 | hash[0] = i; |
| 782 | ChunkManifestEntry::new(i as u32, hash, 30000, 65536) |
| 783 | }) |
| 784 | .collect(); |
| 785 | |
| 786 | let manifest = ChunkManifest::new(entries); |
| 787 | |
| 788 | // Client has nothing |
| 789 | let negotiation = ChunkNegotiation::compute(&manifest, &[]); |
| 790 | |
| 791 | assert!(negotiation.is_full_transfer()); |
| 792 | assert_eq!(negotiation.needed.len(), 50); |
| 793 | assert_eq!(negotiation.bytes_needed, 50 * 30000); |
| 794 | assert!((negotiation.savings_pct() - 0.0).abs() < f64::EPSILON); |
| 795 | } |