fn test_sock_cache_add_context_too_many()

in nfm-controller/src/events/sock_cache.rs [355:391]


    fn test_sock_cache_add_context_too_many() {
        let context = SockContext {
            address_family: AF_INET6,
            local_port: 217,
            ..Default::default()
        };
        let now_us = 100;

        // Fill up the sock cache.
        let mut sock_cache = SockCache::new();
        for sock_key in 0..sock_cache.max_entries() {
            let result = sock_cache.add_context(sock_key as SockKey, context, now_us);
            assert_eq!(
                result,
                SockOperationResult {
                    completed: 1,
                    partial: 0,
                    failed: 0,
                }
            );
        }
        assert_eq!(sock_cache.len(), sock_cache.max_entries());

        // Now try to add beyond the limit.
        for sock_key in sock_cache.max_entries()..sock_cache.max_entries() + 10 {
            let result = sock_cache.add_context(sock_key as SockKey, context, now_us);
            assert_eq!(
                result,
                SockOperationResult {
                    completed: 0,
                    partial: 0,
                    failed: 1,
                }
            );
        }
        assert_eq!(sock_cache.len(), sock_cache.max_entries());
    }