## Summary Many tests proved a specific change when it landed but don't need to run on every CI build forever. This removes **202 test methods and 9 files: 313 test cases, 2,247 → 1,934**. UOContent.Tests drops from about 14s to about 5s locally. Removed: - **Tautologies.** Asserting a constant, a constructor readback or a trivial getter, or testing BCL behavior. - **Exact duplicates** of a surviving test on the same code path. - **Obsolete regressions** whose failure can no longer be expressed. - **Game-content values** shard owners customize (era drop rates, loot and skill tables, single-creature tuning). Each customization would otherwise force a test fix. ## How it was decided 1. Every test was classified, with a reason, by a per-shard sweep over all 287 test files. 2. Each proposed deletion was then checked by a second, adversarial reviewer against the surviving tests and the production code. 3. Anything that was the only coverage of a separate code path was **kept**, even where it looked like a duplicate. Examples: the unsigned `SpanReader`/`SpanWriter` methods, the at-location versus bounds enumerators, null-map enumerables, the security filters, archive-journal state transitions. About 130 proposed deletions were rejected this way. Whole files removed: - `FishingTests`, apart from 3 tests: the map-edge scan, serpent cleanup, and SOS chest consumption. The SOS test now stops at the first chest instead of measuring a catch rate. The multi-million-cast rate simulations are gone. - `LordOaksTests` and `MeerEnragedTests` (single-creature tests). - `AutoArchiveHelperTests`, `JsonDiscoverableTypeAttributeTests`, `DecimalSerializationTests` and `EnumConversionTests` (tautologies, or tests of their own local helpers). - `NetworkStatsTests`. - `MigratedDataLoadTests` (a subset of `AllSpawnFilesLoadTests`). - `SpawnerFixtureCapture`: a capture tool, not a test, and its `version == 12` assert can no longer pass. The `.bin` fixtures it produced stay. ## Tests - Server.Tests: 811 pass. - UOContent.Tests: 1,123 pass. A follow-up PR, stacked on this one, fixes how the remaining tests behave: shared state, CI-vacuous tests, harness duplication.
72 lines
2.2 KiB
C#
72 lines
2.2 KiB
C#
using System;
|
|
using Server.Network;
|
|
using Xunit;
|
|
|
|
namespace Server.Tests.Network;
|
|
|
|
/// <summary>
|
|
/// Bounds behaviour of the Huffman compressor when the destination is too small.
|
|
///
|
|
/// This is reachable in production: NetState only checks that the send buffer has *some* writable
|
|
/// space before handing the remainder to Compress, so a nearly-full buffer can offer a span of one
|
|
/// to three bytes. The internal guard is computed as an unsigned <c>output.Length - 4</c>, which
|
|
/// underflows for those sizes and stops bounding the writes at all.
|
|
/// </summary>
|
|
public class NetworkCompressionBoundsTests
|
|
{
|
|
[Theory]
|
|
[InlineData(0)]
|
|
[InlineData(1)]
|
|
[InlineData(2)]
|
|
[InlineData(3)]
|
|
public void RefusesOutputTooSmallToBound(int outputSize)
|
|
{
|
|
var input = new byte[64];
|
|
Array.Fill(input, (byte)'A');
|
|
|
|
// Sentinel-filled backing array; only the middle window is offered to the compressor, so
|
|
// any write past the span shows up as a modified sentinel rather than silent corruption.
|
|
var backing = new byte[256];
|
|
Array.Fill(backing, (byte)0xCC);
|
|
|
|
const int windowStart = 64;
|
|
var output = backing.AsSpan(windowStart, outputSize);
|
|
|
|
var written = NetworkCompression.Compress(input, output);
|
|
|
|
Assert.Equal(0, written);
|
|
|
|
for (var i = 0; i < backing.Length; i++)
|
|
{
|
|
Assert.Equal(0xCC, backing[i]);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void ReportsFailureRatherThanOverrunningATightOutput()
|
|
{
|
|
// Large input against a small-but-bounded output: the guard is well-defined here, so this
|
|
// must fail cleanly rather than write past the end.
|
|
var input = new byte[4096];
|
|
Array.Fill(input, (byte)'A');
|
|
|
|
var backing = new byte[256];
|
|
Array.Fill(backing, (byte)0xCC);
|
|
|
|
const int windowStart = 64;
|
|
const int windowSize = 16;
|
|
var output = backing.AsSpan(windowStart, windowSize);
|
|
|
|
NetworkCompression.Compress(input, output);
|
|
|
|
for (var i = 0; i < windowStart; i++)
|
|
{
|
|
Assert.Equal(0xCC, backing[i]);
|
|
}
|
|
|
|
for (var i = windowStart + windowSize; i < backing.Length; i++)
|
|
{
|
|
Assert.Equal(0xCC, backing[i]);
|
|
}
|
|
}
|
|
}
|